substratepolkadotpolkadot-js

polkadot-js balances.transfer throws error


In my webapp balances.transfer is throwing an error but staking.bondExtra is working as expected. Its connected to westend network.

Error:

Error: createType(Call):: Call: failed decoding balances.transfer:: Struct: failed on args: {"dest":"LookupSource","value":"Compact<Balance>"}:: Struct: failed on value: Compact<Balance>:: Assertion failed

Code snippet:

transactions = []
transactions.push(
    api.tx.staking.bondExtra(rawAmount),
    api.tx.balances.transfer(Address, commission);
);

const bondExtraFee = await api.tx.utility.batch(transactions).paymentInfo(substrateStashId);
return bondExtraFee.partialFee.toNumber();

Solution

  • This is likely caused by the large number of decimals in your chain. Make sure to specify balance value as BigInt or BN instead of just number.