0

Here is a business case. Two people own an asset, and they estimate the annual maintenance on that asset is $1000 over the next year. So they each want to put $500 and lock it up in my smart contract. An administrator of the asset can spend the funds as needed. Can't use ETH, because of the volatility. If price drops, then no money to pay the maintenance.

Can only ETH be sent to a smart contract? Or can any other ERC-20 token be sent?

If any stable coin can be used, then I can work on the technicalities. If not, then the only solution I see is to create my own stable coin. Am I understanding correctly?

This question is related but somewhat different from Smart Contract with stable coin.

1 Answer 1

1

Sure, smart contract may receive, hold, and send ERC-20 tokens. There are many smart contracts out there that do this.

The usual patter for a smart contract receiving tokens from user looks like this:

  1. User allows smart contract to take his tokens by calling approve on token smart contract.
  2. User calls smart contract and tells it to take user's tokens,optionally providing additional information.
  3. Smart contract takes user's tokens by calling transferFrom on token smart contract.

See EIP-20 for details.

3
  • Thanks. I've been doing a tutorial that does an ERC-20 token, and it had an "approve", but I was having trouble understanding what that was about. And now that I think about it, that's the only way exchanges work. Commented Nov 7, 2019 at 23:48
  • Okay, was thinking on this more, and think I've got it. What really happens internally is that the ERC-20 token deducts funds from one user in it's contract, and puts those funds under the address of my smart contract, within their ERC-20 contract. The tokens don't really come into my contract. More reading to do... Thanks for the references. Commented Nov 8, 2019 at 1:55
  • Another good reference: ethereum.stackexchange.com/questions/50239/… Commented Nov 8, 2019 at 2:13

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.