current position:Home>How can smart contracts receive various token transfers from others?

How can smart contracts receive various token transfers from others?

2022-02-03 20:53:42 Q & A of Denglian community

I think I can receive other people's deposits in the smart contract Token. At present, we can pass payble receive ETH, however ERC20 Token I don't know how to receive ?




Take the answer 1:

You need to be in your own contract , Carry out the outside token Into your contract ?

You can use... In the contract :

function transferFrom(address from,  address recipient, uint256 amount) public returns (bool)

But before calling , You need to get from Authorization of address , The authorization method is :

//  The contract authorized to you :// spender   Fill out your contract , use from  Address to call this method .function approve(address spender, uint256 value) public returns (bool) 

If you can't, you can't use other people's money when your contract token.






Other answers 1:


Other answers 2:


Other answers 3:


Other answers 4:


Other answers 5:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032053381892.html

Random recommended