If I wanted a smart contract to send tokens based on the exchange price of the ERC20 token received, or any agreed upon value in US dollars how would I do so?

For example, If i wanted my tokens to have a value of $.01 and I wanted to accept Patientory (PTOY) tokens which currently trade at $.13, (or the equivalent exchange rate in PTOY/ETHER) is there a way to have the contract automatically send 13 tokens for each PTOY received and to determine that value at the time it is sent?

Essentially, I want to import the GDAX, coinmarketcap, Poloniex price, etc into the smart contract. The ultimate goal would be to be able to accept almost any ERC20 token at its current exchange value when sent. Or is the only option to manually change the contract in a given interval (daily, hourly etc).

  • 2
    You would need to find or create a trustworthy Oracle service to retrieve exchange prices for each token you wish to support – Earlz Jul 13 '17 at 15:56
  • You should put a better tittle like "how to get token prices from exchanges in a contract?" – Ismael Jul 14 '17 at 3:38
  • @cryptonewbie did you manage to find a solution? if so can you please share the solution – Nerdroid Aug 19 '17 at 11:04

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.