Download the PHP package smallsung/ethereum-php without Composer
On this page you can find all versions of the php package smallsung/ethereum-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smallsung/ethereum-php
More information about smallsung/ethereum-php
Files in smallsung/ethereum-php
Package ethereum-php
Short Description Ethereum client for PHP.
License MIT
Homepage https://github.com/ericychu/ethereum-php
Informations about the package ethereum-php
Ethereum Client for PHP
PHP 版本以太坊 JSON RPC 客户端。
可通过简单的添加合约地址和 ABI 来方便的调用合约内的方法,对于需要对交易签名的请求,客户端会自动完成。
支持对事件(Log)的监听,但需要通过定时器执行 \Ethereum\Client::synchronizer->sync()
方法来轮询,
当有事件到达会执行自定义的回调并传递一个 \Ethereum\Types\Event
的实例,该实例包含了反序列化后的事件输入和相关的区块、交易数据。
JSON RPC API 实现度
已实现
- eth_*
- net_*
- web3_*
未实现
- shh_*
依赖
- ext-scrypt: https://github.com/DomBlack/php-scrypt
- ext-secp256k1: https://github.com/Bit-Wasp/secp256k1-php
- ext-keccak: https://github.com/EricYChu/php-keccak-hash
使用
安装
示例
实例化客户端
添加合约
调用合约中的方法
pure
和 view
的方法,可以直接以数组的形式返回反序列化后的数据;nonpayable
和 payable
的方法返回交易的哈希(\Ethereum\Types\Hash
实例)。
监听事件
这里的事件名称是你在合约中定义的事件名称。
注意,监听事件需要通过定时器执行 \Ethereum\Client::synchronizer->sync()
方法来轮询以太坊节点。当有事件到达会执行自定义的回调并传递一个 \Ethereum\Types\Event
的实例,该实例包含了反序列化后的事件输入和相关的区块、交易数据。
如果使用 Swoole,可以通过 Swoole 的定时器来来轮询。
调用 JSON RPC API
支持的方法请查阅 \Ethereum\Methods\Eth
、 \Ethereum\Methods\Web3
和 \Ethereum\Methods\Net
类。
All versions of ethereum-php with dependencies
ext-gmp Version *
ext-scrypt Version ~1.4
ext-secp256k1 Version >=0.1.0
ext-keccak Version ~0.2
graze/guzzle-jsonrpc Version ^3.2
bitwasp/buffertools Version ^0.5.0