1

api.tx.balances.transfer was working perfectly some time ago. I tried to re-run my testcase today and I'm getting this error.

const rawTX = api.tx.balances.transfer(alice.address, 30)
                              ^
TypeError: api.tx.balances.transfer is not a function

I didn't change anything here. I'm connecting to the local substrate node but have also tested with Rococo RPC wss://rococo-contracts-rpc.polkadot.io

what is the issue here, I didn't even upgrade the polkadot version. My current version is

"@polkadot/api": "10.9.1"

I'm out of ideas any help is appreciated.

here's the code snippet

    const api = await ApiPromise.create({ provider: wsProvider });
    await api.isReady
    const keyring = new Keyring({type: 'sr25519'})
    const alice = keyring.createFromUri('//Alice')
    const rawTX = api.tx.balances.transfer(alice.address, 30)
    console.log(rawTX)

UPDATE: I tracked the issue, I had rebuilt the docker image that is using the substrate node, I checked my code with old image and its working fine but with the new image the issue still persists. I still don't know why is this happening and I cannot use my old image as it doesn't have healthcheck. Any help is appreciated.

1 Answer 1

3

since Polkadot v0.9.42 Balances::transfer has been renamed to Balances::transfer_allow_death (PR). This means you now have to either use api.tx.balances.transferAllowDeath or api.tx.balances.transferKeepAlive! :)

For reference, see the transfer-helpers in our useInkathon library. 🫡

1
  • This problem is also in py-substrate-interface and exactly changing the call_function:transfer to call_function:transfer_allow_death solves the problem, Thank you. Commented Feb 22 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.