I have a question about ink!. Is it possible from a smart contract A to manage the transfer of tokens of contract B IF contract B will be deployed later ?

I want a user to call a function of smart contract A (deployed and that we can't modity), put as argument the hash of contract B and make the transfer of tokens of the contract B (from the smart contract A). And this without put use smartcontractB in the smartcontract A.

  • From my understanding you want to call contract A which takes as argument another contract B. Contract A will then transfer its tokens to contract B. What kind of token do you want to transfer? Commented Apr 18, 2023 at 14:11
  • Yes, you understood correctly ! It could be ERC20 but aswell erc721 and erc 1155 ! I want it rather wide ! Does it makes sense ?
    – Matthiew
    Commented Apr 18, 2023 at 15:12

1 Answer 1


Yes this is possible.

When instantiating a smart contract it gets an account id, just like a user has an account id. This means that transfering tokens to/from smart contracts works the same.

Therefore, e.g. for the ERC20 contract, you can call fn transfer with parameter to the account id of contract B.

I'm not sure if you still need contract A with this knowledge. But if you do, you can do something similar like:

        fn transfer_from_contract_a(&self, to: AccountId, value: Balance) {
             .unreachable!("set_tail_call = true");

In this example the erc20 contract that it interacts with is stored in contract A. This can, however, be given as an argument as well:

        fn transfer_from_contract_a(&self, to: AccountId, value: Balance, erc20_as_argument: AccountId) {

  • Thanks you very Daan ! It is really clear, I will implement that ! I appreciated your time :)
    – Matthiew
    Commented Apr 18, 2023 at 17:07

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.