Skip to content

Commit

Permalink
chore: readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ohager committed Jan 14, 2025
1 parent 0cb06e5 commit cb5caaa
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ yarn add @signumjs/core
#### Example

```js
import {composeApi, ApiSettings} from '@signumjs/core'
import {LedgerClientFactory} from '@signumjs/core'
import {Amount} from '@signumjs/util'

const apiSettings = new ApiSettings('https://testnet.signum.network:6876');
const api = composeApi(apiSettings);
const ledger = LedgerClientFactory.createClient({
nodeHost: "https://europe3.testnet.network"
});

// this self-executing file makes turns this file into a starting point of your app

(async () => {
try{
const {balanceNQT} = await api.account.getAccountBalance('13036514135565182944')
try {
const {balanceNQT} = await ledger.account.getAccountBalance('13036514135565182944')
console.log(`Account Balance: ${Amount.fromPlanck(balanceNQT).toString()}`)
}
catch(e){ // e is of type HttpError (as part of @signumjs/http)
} catch (e) { // e is of type HttpError (as part of @signumjs/http)
console.error(`Whooops, something went wrong: ${e.message}`)
}
})()
Expand All @@ -57,12 +57,42 @@ Just import the package using the HTML `<script>` tag.
#### Example

```js
(function(){
const api = sig$.composeApi({nodeHost: "https://testnet.burstcoin.network:6876"});
api.network.getBlockchainStatus().then(console.log).catch(console.error);
(() => {
const ledger = sig$. LedgerClientFactory.createClient( {nodeHost: "https://europe3.testnet.network"});
ledger.network.getBlockchainStatus().then(console.log).catch(console.error);
})()
```

## Initialize Crypto Module

The above examples don't need any specific cryptographic features. But when it comes up to signing/creating transactions, deciphering P2P messages you may encounter the following error:

```
No Crypto Adapter provided - Use [Crypto.init()] first
```

You have to initialize the Crypto Module according to your platform somewhere in your apps entry point

__NodeJS__

```ts
import {Crypto} from "@signumjs/crypto"
import {NodeJSCryptoAdapter} from "@signumjs/crypto/adapters"

Crypto.init(new NodeJSCryptoAdapter());
```

__Web/Browser__

```ts
import {Crypto} from "@signumjs/crypto"
import {WebCryptoAdapter} from "@signumjs/crypto/adapters"

Crypto.init(new WebCryptoAdapter());
```

> For React Native/Expo see [here](https://github.com/signum-network/signumjs-react-native-crypto-adapter)

See more here:
[@signumjs/core Online Documentation](https://signum-network.github.io/signumjs/modules/core.html)

0 comments on commit cb5caaa

Please sign in to comment.