I am trying to implement batch transactions alongside the normal balances.transfer. Because of several reasons (constructing transaction more than one stage and polkadot lib is not helping there) i am using @substrate/txwrapper-polkadot
methods.balances.transfer and now i am trying methods.utility.batchAll. However i am facing something weird.
For transfer i used this:
const unsigned = methods.balances.transfer(
{
dest: toAddress,
value,
},
{
address: account.address,
blockHash,
blockNumber,
eraPeriod: 64,
genesisHash,
metadataRpc,
nonce,
specVersion,
tip,
transactionVersion,
},
{
metadataRpc,
registry,
},
);
This function takes 3 parameter:
function transfer(args: BalancesTransferArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction
This args: BalancesTransferArgs takes dest
and value
.
utility.batch however uses UtilityBatch
as args :
calls: ({
callIndex?: string;
args?: string;
} | string)[];
I tried to use same args part (first part of the unsigned that i wrote up there) of batch transfer from another transaction which i get with api.rpc.chain.getBlock
:
[{"callIndex":"0x0500","args":{"dest":{"id":"1w3QEceeCRN2Rv3GfUohY6yTpRUoo4BRdQ2b7s2jTgK4q4y"},"value":142062126800}}, {"callIndex":"0x0500","args":{"dest":{"id":"157xqEJLZDUmhc1RFvUDitKP3ygFDsJeXHifJw1Th2Pn7khH"},"value":130297371500}}, {"callIndex":"0x0500","args":{"dest":{"id":"13qkt6YBJyqzh4jdtJ4dooJDsTgAGKWoM2MwHreWN7LpYEHc"},"value":428418876800}}, {"callIndex":"0x0500","args":{"dest":{"id":"15sSvgpSsonimLWpHv7ZUhyNoXjd4VNMm2wpDeDVtcp2W58"},"value":999200000000}}, {"callIndex":"0x0500","args":{"dest":{"id":"13ee8dYeLBR7iaGEcSjbaC7ooRw2U5iSNexdFdTEo4VBVvVN"},"value":150723408800}}, {"callIndex":"0x0500","args":{"dest":{"id":"1555Ub7YF1tiyDv7JzUNToVjbUzAoK6X8k9RGGUYMK7ZUwAk"},"value":14200000000}}]
but its not accepting parameter as object like this because it wants it as string and i really couldn't figure what should i put there.
And what is callIndex? What it should be?
Can Anyone help? Thanks