1

I found the as_derivative() function call in the FRAME Utility pallet which suggests that I can use it to call a function from address_A on behalf of address_B, provided that address_B was made as a derivative account from address_A.

Using the polkadot.js extension I created a derivative account from address_A and funded it with some test tokens. Then using the polkadot.js/apps extrinsics tab I wrapped a basic transfer_keep_alive() in a call to as_derivative() so that I would be able to submit and pay for transaction fees using address_A, but the transfer amount would be sent from address_B.

However, when I submit the transaction I receive a Balance.InsufficientBalance error. I have double-checked that the derivative address I made with the polkadot.js extension does in fact have a sufficient amount of tokens, so I am not sure what I am missing.

1 Answer 1

3

It turns out this is a bit of a naming collision. The derived account that I created using the polkadot.js extension (known as /soft-path or //hard-path derivation) is different from the type of derived address the Utility pallet requires for the as_derivative() function.

In order to create a derived address that works with as_derivative(), I needed to use a different function found in the polkdot-js/util-crypto library called encodeDerivedAddress()

By passing in the raw byte array along with an index number, I was able to generate a usable derivative address. Once funded, the as_derivative() function call I attempted above worked as expected.

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.