Skip to content

Commit

Permalink
chore: added multisend on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Apr 18, 2024
1 parent 76c84b4 commit 4de0220
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions source/includes/_bank.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,60 @@ func main() {
fmt.Println("gas fee:", gasFee, "INJ")
}
```

```ts
import { MsgMultiSend, MsgBroadcasterWithPk } from '@injectivelabs/sdk-ts'
import { BigNumberInBase, BigNumberInWei } from '@injectivelabs/utils'
import { Network } from '@injectivelabs/networks'

const privateKey = '0x...'
const injectiveAddress = 'inj1...'
const denom = 'inj'
const decimals = 18
const records = [/** add records here */] as {
address: string;
amount: string; /* in a human readable number */
}[];
const totalToSend = records.reduce((acc, record) => {
return acc.plus(new BigNumberInBase(record.amount).toWei(decimals));
}, new BigNumberInWei(0));

const msg = MsgMultiSend.fromJSON({
inputs: [
{
address: injectiveAddress,
coins: [
{
denom,
amount: totalToSend.toFixed(),
},
],
},
],
outputs: records.map((record) => {
return {
address: record.address,
coins: [
{
amount: new BigNumberInBase(record.amount)
.toWei(decimals)
.toFixed(),
denom,
},
],
};
}),
});

const txHash = await new MsgBroadcasterWithPk({
privateKey,
network: Network.Testnet
}).broadcast({
msgs: msg
})

console.log(txHash)
```
<!-- MARKDOWN-AUTO-DOCS:END -->

|Parameter|Type|Description|Required|
Expand Down

0 comments on commit 4de0220

Please sign in to comment.