I want to build a functionality that allows following: 1) Transfer between ETH and MyToken for same address. 2) Transfer between ETH and MyToken between two different addresses.

Since solidity does not allow changing balance of my "ETH" account, I will need to write some part of code in web3js and some part is smart contract. Is that correct? What will be the right design for this?

Please note that at present I'm writing this in my Private Net for demo purpose only.

  • You seem to want to implement an exchange, if you send ether to the contract it should credit you with tokens, an if you send tokens you will receive ether. To receive ether you have to make a function payable, and to send ether to an address you have to use <address>.transfer(). – Ismael Aug 17 '17 at 3:35

Your Answer

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

Browse other questions tagged or ask your own question.