Position: Home page » Ethereum » Ethereum RPC interface PHP

Ethereum RPC interface PHP

Publish: 2021-05-23 21:32:23
1. How to run Ethereum source code go Ethereum
install MIPS based Linux header file
$CD $prjroot / kernel
$tar - xjvf linux-2.6.38. Tar. Bz2
$CD linux-2.6.38

create an include folder under the specified path to store related header files< br />$ mkdir -p $TARGET_ Prefix / include

ensures that the Linux source code is clean
$make mrproper

generates the required header file< br />$ make ARCH=mips headers_ check
$ make ARCH=mips INSTALL_ HDR_ PATH=dest headers_ Install

all the files in dest folder to the specified include folder< br />$ cp -rv dest/include/* $TARGET_ Prefix / include

delete dest folder at last
$RM - RF dest
$LS - L $target_ PREFIX/include
2. curl方法,file_get_contents,
3.

If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records

the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:

< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){
transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />});

Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query

recommend a practical introction, you can see: Ethereum tutorial

4.

Ethereum specifies the JSON RPC API application development interface that each node needs to implement. This interface is transport independent. Applications can use this interface protocol to operate Ethereum nodes through HTTP, websocket or IPC and other communication mechanisms:

5. For now, if there are development documents, you need to get them according to the development documents. If not, there is no way

I hope my answer can help you. If you don't understand anything, you can ask.
6. PHP integrates the access of XML-RPC and soap, both of which are focused on the extension of XMLRPC. In addition, in the pear of PHP, both PHP 4 and PHP 5 have integrated the XML-RPC extension by default, and this extension is independent of the XMLRPC extension, and can independently implement the protocol interaction of XML-RPC. If there is no XMLRPC extension, pear:: XML-RPC extension is recommended
Introction to web service
Web service is proced for the communication of heterogeneous systems. Its basic idea is to provide a standard mechanism by using HTTP remote call based on XML without the need to establish a new protocol. At present, there are two protocol standards for web service communication, one is XML-RPC, the other is soap. XML-RPC is relatively simple, appeared earlier, soap is relatively complex, mainly used when it needs stable, robust, safe and complex interaction
here, we mainly use XML-RPC to briefly describe the interaction process of web service. Part of the content is from the PHP manual. For more details, please refer to the manual
install the XMLRPC extension
if you don't have the PHP extension of XMLRPC installed on your system, please install it correctly
on the windows platform, first of all, expand PHP in the PHP installation directory_ Xmlrpc.dll to C: \ Windows or C: &? 92; In WinNT directory, (the extension of PHP4 is in C: & # 92; php\ In the extensions directory, the extension of PHP5 is in C: & # 92; php\ At the same time, in C: & # 92; Windows\ Php.ini or C: \ Winnt\ Extension = PHP in php.ini_ Semicolon before xmlrpc.dll & quot& quot; Remove it, and then restart the web server to see if phpinfo () has an XML-RPC project to determine whether the XML RPC extension has been properly installed
on UNIX / Linux platform, if the XMLRPC extension is not installed, please recompile PHP, add -- with XMLRPC option when configuring, and then check phpinfo() to see if the XMLRPC extension is installed normally
(Note: the following operations are based on the premise of normal installation of XMLRPC expansion, please be sure to install it correctly.)
working principle of XML-RPC
XML-RPC is basically the whole process of using XML to communicate. First of all, an RPC server is constructed to send the XML encapsulated request from the RPC client, and the processing result is returned to the RPC client in the form of XML. Then the client analyzes the XML to get the data it needs
the server side of XML-RPC must have ready-made functions to be called by the client side, and the functions and methods in the requests submitted by the client side must be consistent with those of the server side, otherwise the required results will not be obtained
I will describe the whole process with simple code
practice of XML-RPC
using XMLRPC in server_ server_ The create function generates a server, registers the RPC calling interface that needs to be exposed, accepts the XML data from the RPC client post, and processes it. The processing results are displayed to the client in the form of XML
the code is as follows: RPC_ server.php
<? PHP
/ *
* functions: functions provided to RPC clients to call
* parameters:
* $method functions to be called by clients
* $parameters array of functions to be called by clients
* Return: Returns the specified call result
* /
function RPC_ server_ func($method, $params) {
$parameter = $params[0];< br /> if ($parameter == " get"){< br /> $return = '&# 39; This data by get method'&# 39;;< br /> }else{
$return = '&# 39; Not specify method or params'&# 39;;< br /> }
return $return;
}
/ / generate an XML-RPC server-side
$XMLRPC_ server = xmlrpc_ server_ create();
/ / register a method RPC called by the server_ Server, which actually points to RPC_ server_ Func function
XMLRPC_ server_ register_ method($xmlrpc_ server, " rpc_ server", & quot; rpc_ server_ func");
/ / accept XML data from client post
$request = $http_ RAW_ POST_ DATA;
/ / after executing the XML request calling the client, get the execution result
$XMLRPC_ response = xmlrpc_ server_ call_ method($xmlrpc_ server, $request, null);
/ / output the result XML processed by the function
header (& # 39&# 39; Content-Type: text/xml'&# 39;);< br />echo $xmlrpc_ response;
/ / destroy XML-RPC server-side resources
XMLRPC_ server_ destroy($xmlrpc_ server);< br />?& gt;
after the server is constructed, we can construct our RPC client. The client accesses port 80 of the XML-RPC server through socket, encapsulates the RPC interface to be called into XML, submits the request to the RPC server through post, and finally obtains the result returned by the server
the code is as follows: RPC_ client.php
<? PHP
/ *
* functions: functions provided to clients to connect to XML-RPC servers
* parameters:
* $host host to connect to
* $port to connect to host port
* $RPC_ Server XML-RPC server-side file
* $request encapsulated XML request information
* Return: successful connection returns the XML information returned by the server, and failure returns false
* /
function RPC_ client_ call($host, $port, $rpc_ Server, $request) {
/ / open the specified server side
$FP = fsockopen ($host, $port)
/ / construct the query post request information of the XML-RPC server that needs to communicate
$query = & quot; POST $rpc_ server HTTP/1.0\ nUser_ Agent: XML-RPC Client\ nHost: ".$ host."&# 92; nContent-Type: text/xml\ nContent-Length: ". strlen($request)."&# 92; n\ n".$ request."&# 92; n";
/ / send the constructed HTTP protocol to the server. If it fails, return false
if (! fputs($fp, $query, strlen($query))) {
$errstr = " Write error";< br /> return false;<
}

/ / get all the information returned from the server, including HTTP header and XML information
$contents = & 39&# 39;&# 39;&# 39;;< br /> while (! feof($fp)){
$contents .= fgets($fp);
}
/ / after closing the connection resource, the obtained content is returned
Fclose ($FP)< br /> return $contents;
}
/ / construct the connection information of RPC server side
$host = & 39&# 39; localhost'&# 39;;< br />$port = 80;< br />$rpc_ server = '&# 39;/~ heiyeluren/rpc_ server.php'&# 39;;
/ / to encode the XML request to be sent into XML, the method to be called is RPC_ Server, the parameter is get
$request = XMLRPC_ encode_ request('&# 39; rpc_ server'&# 39;, &# 39;&# 39; get'&# 39;);
/ / call RPC_ client_ The call function sends all the requests to the XML-RPC server and gets the information
$response = RPC_ client_ call($host, $port, $rpc_ server, $request);
/ / analyze the XML returned from the server, remove the HTTP header information, and convert the XML to a string that PHP can recognize
$split = & 39&# 39;& lt;? xml version=" 1.0" encoding=" iso-8859-1"?& gt;&# 39;&# 39;;< br />$xml = explode($split, $response);< br />$xml = $split . array_ pop($xml);< br />$response = xmlrpc_ decode($xml);
/ / output the information obtained from RPC server
Print_ r($response);< br />?& gt;
in general, the above example is to submit an RPC_ In the past, the parameter of the server method was get, and then get the return of the server. The XML data returned by the server is:
& lt;? xml version=" 1.0" encoding=" iso-8859-1"?& gt;< br />< methodResponse>< br />< params>< br />< param>< br /> < value>< br /> < string> This data by get method</ string>< br /> </ value>< br /></ param>< br /></ params>< br /></ methodResponse>
then we can use XMLRPC_ The decode function encodes this XML into a PHP string, so we can handle it at will, and the whole web service interaction is completed.
7. After connecting to the Internet, click to open a song list, there will be no more after the meeting
8. In terms of stocks, if you have no experience in stock investment and have no time to mark to market and resume trading, it is suggested that you can choose some stocks with better fundamentals, better management level and consumer preference to make medium and long-term investment. At present, the price of gold is relatively low in the past half a year, so it can be used to invest in some funds. However, gold is not suitable for speculative profiteering. It is just a risk hedging tool and can be used to invest a small part of the money.
9. China's development and growth have threatened the hegemony of the United States. It is the most effective way to restrict China economically. Once China's monetary system changes, China will regress for 30 years.
10. Why should we appreciate? One of the reasons is that our foreign trade surplus is too much. The growth rate of our foreign trade and export is too fast. Our economy can't afford it, and the world can't afford it more and more. All kinds of imbalances are beginning to emerge. Therefore, we have adopted some policies, including monetary policy, whose purpose is to rece the growth rate of our foreign trade and export. That is to rece the trade surplus, especially the trade surplus with the United States, so that our foreign exchange reserves are not increasing by hundreds of billions every year. Now we have reached 1.6 trillion, and then 2 trillion. Our goal is to rece its speed. Therefore, we can't say that ye gonghao is a good dragon. In the past, we always talked about recing the balance of payments, recing the surplus. As a result, the surplus began to decrease, and we began to feel unbearable. Since there are adjustments and rections, some instries and enterprises may be impacted, which is also foreseen. I understand that the current policy is to prevent big shocks and let it go in small steps. The biggest consideration for small steps is that our enterprises should give us a buffer period. Instead of orders running away all at once, there is also a process of cost rection and structural adjustment, which gives us a buffer. But after all, this is an adjustment. In the past, our foreign trade surplus increased by more than 40% last year and by more than 60% the year before last. This is unsustainable. We need to rece it. So I said, first of all, we need to recognize this
Second, when will it have further consequences? I said that the market will graally appreciate and realize the process of equilibrium. And again, why do we accelerate appreciation against the dollar? One of the most important is the accelerated depreciation of the US dollar. When we accelerate the appreciation, we haven't caught up with the pace of its depreciation. We are still devaluing against the euro and yen. The world is not just a dollar currency. We are still trading partners with other countries. We have a smaller deficit against the euro and yen. Europeans will also discuss with us about this imbalance. So how fast does it appreciate. Where is the equilibrium point? We can't just ask the Chinese, we have to ask how much the US dollar has depreciated. Now the euro has depreciated to 1.56 against the US dollar, and when will it end? This is the biggest question. Changes in the United States have brought about all changes. So you say where the equilibrium point is, no one knows. Therefore, if we want to adjust, we should not only look at the adjustment of imports and exports to the United States, but also look at the adjustment of imports and exports to other countries
having said all this, we also need to realize that China needs to adjust. According to the past growth pattern and the growth pattern with such a large foreign trade surplus, it is indeed unsustainable. But on the other hand, China has to grow and develop the international market. Otherwise, when will our low-income level complete the process of instrialization and transformation of farmers. Therefore, we really need to pay close attention to the changes in the market, the whole employment situation and the whole international situation. In the context of the US subprime crisis and in the process of RMB dollar adjustment, we should pay close attention to the changes in various variables, so as to make our policy adjustment and the adjustment of various variables to a more appropriate degree.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750