4

In ink! smart contract, we usually use AccountID and save the balances in array using mapping or HashMap. This is the traditional way of ERC20 smart contract.

I am now developing on my local chain, and main token is MMM.

What I want is to transfer our own token (MMM) via smart contract, not deployed token.

Is my idea correct? and can anyone help me?

1 Answer 1

6

If I understand your question correctly, you want to invoke a function in your smart contract that transfers your native chain token to another account.

In ink! there is the function ink_env::transfer to do this.

You can take a look at the give_me function in our contract-transfer example, it does exactly this plus some error handling around it.

2
  • How would you transfer the native chain token from one account to another? I can't find any example for that online, and the example you provided only shows how to transfer a native token from the contract to the caller.
    – rajohs
    Commented Sep 12, 2022 at 16:10
  • I know this is old, but for others who bump into this, I think what you were looking at was this: github.com/paritytech/ink-examples/blob/… Commented May 3, 2023 at 16:19

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.