I am learning Eos smart contract. But there are no information except Eos wiki. In ethereum, ethers can be transferred by payable function. How can I transfer Eos in Eos smart contract?
1 Answer
Each smart contract has it's very own account so if you simply wanna transfer a token to it just transfer to it's account.
However, should you want to keep a record of who's sent the token and how many then you need to set up a listener on the contract which calls a function to add a record to a multi-index container or do whatever else it should do upon receiving a token.
Listening to this action is something I've struggled with as I believe it's not supported by the EOSIO_ABI macro in the contract and can only be done by tinkering with it, an update should resolve this and create a better developer experience.
Check out these other answers...
- require_auth differs from the auth check of INLINE_ACTION_SENDER but how?
- How to do an action in a contract to transfer tokens to other user accounts without adding permission in dawn4.0?
Let me know how you go.
-
Thank you for your answer. I will read articles you choose. I know basic concept of Eos transaction and action, but I couldn't find that how to transfer Eos(not token). I want to know the basic process of transfer Eos(like payable function in solidity).– ThunniniCommented Jun 8, 2018 at 3:38
-
1Sorry, can you spell it out further then, there is no such thing as a 'payable' function like in Solidity. Pure transfers can be accomplished like on MeW for Ethereum, doing a transfer on EOS can be done with cleos like
cleos push action eosio.token transfer '["me", "you", "1.0000 EOS, "memo"]'
-p me Commented Jun 8, 2018 at 3:42 -
Very thank you for your response. But I have one more question... EOS(native coin) is also handled like token?– ThunniniCommented Jun 8, 2018 at 3:46
-