6

Can you do POST or submit a form from an external site using a smart contract? And how can this be done? Are there any examples of live code out there?

  • Hi and welcome to Ethereum SE. Could you improve your question style by adding information on what you have tried so far and forming sentences with at least 1 verb? :) – Afr Feb 2 '16 at 1:09
11

Ethereum contracts are sandboxed from the world and cannot do much more than add/subtract/multiply/send on ether/invoke other contracts, etc. (There's a complete list of opcodes, I hope you get the idea.) This is to prevent DDoS attacks. (Imagine if you just told all Ethereum miners to access some web page a million times.)

A server can monitor the data from a contract and perform actions based upon it.

One such pay service is called Oraclize. (I hope some day there will be others? But Oraclize has a way to prove that they didn't mess with the data called TLSNotary.)

Oraclize does have a way to do a POST request.

You have to be extremely careful because any data you put in your POST will be visible to everyone. (Don't put a secret API key in there!)

They have a demo of this here: https://docs.oraclize.it/#simple-query

// the only data-source accepting 2 string arguments is 'URL' when we want it to send an HTTP POST request
// with the 2nd argument being the query-string we want to send to the given server.
// note that when the 2nd argument is a valid JSON string it will be automatically sent as JSON
oraclize_query("URL", "json(https://shapeshift.io/sendamount).success.deposit", '{"pair": "eth_btc", "amount": "1", "withdrawal": "1AAcCo21EUc1jbocjssSQDzLna9Vem2UN5"}');
|improve this answer|||||
  • what would be the basic structure of a simple oracle used internally and where I wouldn't need proof the data hasn't been tampered ? – euri10 Apr 12 '16 at 12:07
  • The link is broken. Could you please update the link? – Guido May 26 '16 at 21:04

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.