PHP code example of wula / web3

1. Go to this page and download the library: Download wula/web3 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wula / web3 example snippets


    return [
        'etherscanKey'=>'your apiKey issued by https://etherscan.io/',
        'nodes'=>[
            'default' => [
                'url'=>'http://localhost:8545',
                'timeout'=>5,
                'startBlockId'=>10000,
                'fullTxData'=>true
            ],
            'otherServer'=>[
                'url'=>'http://www.nidefuwuqi.com:8545',
                'timeout'=>5
            ]
        ]
    ]

    //连接默认(default)服务器
    $web3 = Web3Factory::newWeb3();
    //或者连接指定服务器
    $web3 = Web3Factory::newWeb3('otherServer');
    
    
    //1. 获取最新区块
    $block = $web3->getBlock();
    //2. 获取1000区块并包括详细信息
    $block = $web3->getBlock(QuantityFormatter::format(1000),true);