0

I have a smart contract. All what I need is to make a PHP script that will get some public data from smart contract using it's address. How can I do that? Maybe there is some libraries?

1 Answer 1

1

Yes, this is possible. I don't know if there are PHP libraries available, but as long as you can make an HTTP request and deal with JSON, this is pretty easy to do. See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call.

You can send such a JSON-RPC call to any Ethereum node. Infura is a public node that you could use.

5
  • Ok. But how I can get data from mapping in the contract? How I need to send JSON request?
    – M. Jhon
    Jan 9, 2018 at 18:08
  • Give github.com/sc0Vu/web3.php a try. Specifically, $contract->at($contractAddress)->call($functionName, $params, $callback);.
    – user19510
    Jan 9, 2018 at 19:45
  • You could use a library like Ethereum-PHP which is documented. Mar 21, 2018 at 0:25
  • @digitaldonkey Documentation site seems to be down?
    – majick
    May 8, 2022 at 5:03
  • Just migrated ethereum-php.org yesterday. Should be online again. May 9, 2022 at 8:24

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.