1

I have created a smart contract (smart contract per invoice) now the contract is between seller and buyer but the money is provided to the smart contract is from the financier. Financier pays the money(eth) to the smart contract and gets the token (ERC20 XXXTokens) from a smart contract as a check.

Now the question is when the financier wants a money-back he has to return the tokens(ERC20 XXXTokens) so, how should I check in a smart contract that the user returning the token is the same token that this smart contract generated?

Or any matter of fact how do we check the tokens are from a specific smart contract?

0

It sounds like you've got some things mixed up.

Let's start with a more abstract description of things.

Consider the following two conceptual ways for you to hold money:

  1. You have N dollars in your wallet
  2. The bank has a record indicating that you own N dollars

On the blockchain, whenever we say that user k has N tokens of type XXX, we mean that the XXXToken contract stores a record which indicates that user k has N tokens.

These tokens are of course of type XXX, because that's all the XXXToken contract "knows".

In other words, on the blockchain, your equity is maintained in a manner similar to #2 above.

So whenever user k wants to change his/her XXX tokens to ether, all they have to do is to interact with the XXXToken contract (the "XXX bank" if you will), and ask it to sell their tokens for ether (i.e., call function XXXToken.sell with the desired amount of tokens).

| improve this answer | |
  • thanks a ton. I misunderstood while I was reading about ERC20. totally makes sense now. – iamsujit Jan 16 at 8:58
  • @iamsujit: You're welcome. It took me a while to formulate that difference even to myself. Most people think - "if I have money, then it's gotta be in my wallet". So it's probably confusing for many. – goodvibration Jan 16 at 9:01
  • does it mean that the smart contract can destroy the tokens even if someone is holding in his metamask wallet? (assuming smart contract has the destroy functionality) – iamsujit Jan 17 at 3:26
  • @iamsujit: Yes, just like the bank can theoretically steal your money, erase it or move it into someone else's account. But if the contract's code allows for something like that to happen, then since this code is publicly visible to everyone, no one will ever trade with that contract's token to begin with. – goodvibration Jan 17 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.