0

I have two simple questions.

  1. Does all the smart contracts that creates ERC20 tokens have the same function names like balanceOf and transfer? Or developer select those names as they want?

  2. Lets say i want to be intermediary, i create smart contract, people send me ether and after sometime they claim X tokens from contract. To do that i have to create instance of X tokens contract. When i do that and do transfer function does the X contract see contracts address as a sender or does it see the ones address who interacted with my contract?

  3. Who has to pay gas if contracts communicate with each other?

2
  • Also, who has to pay gas if contracts communicate with each other? Commented Apr 3, 2018 at 9:26
  • Point 3: The contract will have to pay for the transaction fee. For your point 1: As everyone said, If you don't follow the standards, you will have to let each and every contract or user know, How they can communicate with your contract. Commented Sep 2, 2020 at 6:34

3 Answers 3

0

As far as first question is concerned, I believe after reading the documentation of Ethereum, in order to implement ERC20 token one has to specifically use those names. Usage of those names is logical because that alone makes it "universal" or compliant. Besides, it is a way to ensure one token can communicate with another

0

1)

Yes. It is part of the standard. The balanceOf is a public mapping whose getter is generated by the EVM transfer is a transaction function, as part of the standard, it needs to have this name

2

Lets say i want to be intermediary, i create smart contract, people send me ether and after sometime they claim X tokens from contract. To do that i have to create instance of X tokens contract. When i do that and do transfer function does the X contract see contracts address as a sender or does it see the ones address who interacted with my contract?

Why would you create x instance? Your smart contract is made to handle your tokens. Just use it.

3) Who pays for gasif contracts communicate with each other?

It always is the transaction sender.

1
  • concerning second question, maybe i was not clear enough. The token contract is not mine. To be very clear: I will have access to good presale ICO. Through smart contract i want to create a pool, people send ether to that contract. I will send that ether to ico ant they will send tokens to that contract. And i want to distribute tokens to addresses who sent ether to my contract. So i assumed i need to create an instance of token contract. Commented Apr 3, 2018 at 11:48
0

Answer(1): If your smart contract deployed on ethereum then you should follow the ERC20 standard for any action regarding token. A developer can't choose a custom name for token transfer, issue, allocation..etc...They should follow ERC20 standard.

Answer(2): you can alter your contract in a way that, if the contract address receives any ether from outside, a fixed number of X tokens will be sent to them.

Answer(3): When it comes to the gas fee, it's the price for the miners for validating your transaction. No matter if what action actually occurs. If you are pushing a transaction then the gas fee will be deducted from you.

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.