PHP calls Ethereum interface

Source: Internet
Author: User
Ethereum Specifies the JSON RPC application development interface that each node needs to implement, and if you want to use PHP to develop a de-centric application (DAPP) on a ethereum blockchain, the first thing to solve is how to invoke the Ethereum JSON RPC interface using PHP:

If you want to quickly access Ethereum, for example, to support an ethereum payment, or to issue your own tokens, this
The PHP Ethereum Development Course provides the best learning path.

Although the interface specification does not contract the transport layer, most ethereum node software implements the HTTP protocol support.
So we can use PHP's HTTP development package to make the call. For example, the following code uses guzzle, the HTTP development package, to obtain the version information of the Ethereum node:

<?php$client = new GuzzleHttp\Client();$opts = [  ‘json‘ => [    ‘jsonrpc‘ => ‘2.0‘,    ‘method‘ => ‘web3_clientVersion‘,    ‘params‘ => [],    ‘id‘ => time()  ]];$rsp = $client->post(‘http://localhost:8545‘,$opts);echo $rsp->getBody() . PHP_EOL;?>

Of course you can also take advantage of some open source packaging, but in the PHP community, there is currently a lack of a unified and relatively mature ethereum development package, so in the development process of dapp, understanding the implementation of these open source code is essential, And often need to comprehensive use of various code resources to solve the problem.

Original: PHP Ethereum Development detailed

PHP calls Ethereum interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.