Skip to content

Commit

Permalink
Merge pull request #100 from CityOfZion/CU-86a15ft14
Browse files Browse the repository at this point in the history
CU-86a15ft14 - Document calculateFee on WcSdk
  • Loading branch information
luc10921 authored Nov 24, 2023
2 parents ecc81d8 + 6f682fc commit 1655ab0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions USAGE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,33 @@ const messageDecrypted = wcSdk.decryptFromArray(encryptedMessages)
This method is slower than the `decrypt` method, so you should use it only if you are not sure which encrypted message
is the correct one.

### Calculate Fee

It's important to know how much a transaction will cost before invoking.

The `calculateFee` function facilitates this by allowing users to input the same arguments they would use in the
`invokeFunction`. This process yields detailed information about the `networkFee`, `systemFee`, and the aggregate `total`.

See the example below:

```ts
const resp = await wcSdk.calculateFee({
invocations: [{
scriptHash: '0xd2a4cff31913016155e38e474a2c06d08be276cf',
operation: 'transfer',
args: [
{ type: 'Hash160', value: account.address },
{ type: 'Hash160', value: 'NbnjKGMBJzJ6j5PHeYhjJDaQ5Vy5UYu4Fv' },
{ type: 'Integer', value: '100000000' },
{ type: 'Array', value: [] },
],
}],
signers: [{ scopes: 'CalledByEntry' }],
})

console.log(resp) // will print an object with `networkFee`, `systemFee` and `total`
```

## Get Wallet Info

To get information about the wallet, such as if it is a Ledger wallet, you can use the `getWalletInfo` method.
Expand Down

0 comments on commit 1655ab0

Please sign in to comment.