All Projects → ericychu → ethereum-php

ericychu / ethereum-php

Licence: MIT license
Ethereum Client for PHP.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ethereum-php

ethereum-kit-ios
Comprehensive EVM SDK (ex: Ethereum, Binance Smart Chain) for iOS, implemented on Swift. Create wallets, watch wallets (read-only), sync transactions, filter transactions by type (erc20, bep20, swap transactions etc.), swap using native DEX protocols, easily extendable to work with custom smart contracts, and full support for EIP1159.
Stars: ✭ 148 (+196%)
Mutual labels:  ethereum-client, web3
0x-event-extractor
NodeJS worker built for 0x Tracker which extracts 0x fill events from the Ethereum blockchain and persists them to MongoDB
Stars: ✭ 32 (-36%)
Mutual labels:  web3
airswap-web
AirSwap Web App
Stars: ✭ 94 (+88%)
Mutual labels:  web3
oxo-chat-client
基于websocket、json、blockchain的公告、聊天(客户端到客户端加密)客户端。账号无需注册,本地生成!
Stars: ✭ 52 (+4%)
Mutual labels:  web3
nft-swap-sdk
Ethereum's missing p2p NFT and token swap library for web3 developers. Written in TypeScript. Powered by 0x.
Stars: ✭ 200 (+300%)
Mutual labels:  web3
web3-token
Web3 Token is a new way to authenticate users in a hybrid dApps using signed messages. Implementation of EIP-4361.
Stars: ✭ 356 (+612%)
Mutual labels:  web3
erebos
JavaScript client and CLI for Swarm
Stars: ✭ 47 (-6%)
Mutual labels:  web3
SkyGallery
Create galleries by uploading images and videos. Powered by Sia Skynet.
Stars: ✭ 23 (-54%)
Mutual labels:  web3
nextjs-dapp-starter-ts
A fullstack monorepo template to develop ethereum dapps
Stars: ✭ 228 (+356%)
Mutual labels:  web3
circles-myxogastria
Webapp and mobile client for Circles
Stars: ✭ 32 (-36%)
Mutual labels:  web3
mev-inspect-rs
Discover historic Miner Extractable Value (MEV) opportunities
Stars: ✭ 443 (+786%)
Mutual labels:  web3
crypto-high-score
Add your name to the global, immutable leaderboard by paying in ETH.
Stars: ✭ 18 (-64%)
Mutual labels:  web3
geth-connector
This repository served as an experiment playground for the alpha version of AKASHA desktop application. Now it is considered deprecated and seen as a stepping stone in the R&D of the AKASHA world framework. 🚀🌍🚀
Stars: ✭ 52 (+4%)
Mutual labels:  web3
useWeb3
useWeb3 provides a curated overview of the best and latest resources on Ethereum, blockchain and Web3 development.
Stars: ✭ 325 (+550%)
Mutual labels:  web3
matic-docs
The official documentation for all Polygon products.
Stars: ✭ 181 (+262%)
Mutual labels:  web3
Before-Bitcoin
Book about the ideological context of cryptocurrency. 'Before Bitcoin' written by Pet3rpan.
Stars: ✭ 22 (-56%)
Mutual labels:  web3
geesome-node
🦈 Your self-hosted decentralized Messenger, Social network, Media file storage on top of IPFS! Freely communicate in encrypted chat groups, share images, video, text or any data without a risk of censorship or blocking.
Stars: ✭ 90 (+80%)
Mutual labels:  web3
react-mix
Everything you need to use React with Brownie!
Stars: ✭ 58 (+16%)
Mutual labels:  web3
zksync-dapp-checkout
zkCheckout — trustable permissionless DeFi payment gateway. Brand new zkSync dApp w/t all L2 perks: fast&cheap transfers / simple&quick withdrawal
Stars: ✭ 37 (-26%)
Mutual labels:  web3
metaverse-development
Certified Web3 and Metaverse Developer Syllabus and Details by Panaverse
Stars: ✭ 195 (+290%)
Mutual labels:  web3

Ethereum Client for PHP

PHP 版本以太坊 JSON RPC 客户端。

可通过简单的添加合约地址和 ABI 来方便的调用合约内的方法,对于需要对交易签名的请求,客户端会自动完成。

支持对事件(Log)的监听,但需要通过定时器执行 \Ethereum\Client::synchronizer->sync() 方法来轮询, 当有事件到达会执行自定义的回调并传递一个 \Ethereum\Types\Event 的实例,该实例包含了反序列化后的事件输入和相关的区块、交易数据。

JSON RPC API 实现度

已实现

  • eth_*
  • net_*
  • web3_*

未实现

  • shh_*

依赖

php-64bit: ^7.2
ext-gmp: ^7.2
ext-scrypt: ^1.4
ext-secp256k1: ^0.1.0
ext-keccak: ^0.2
graze/guzzle-jsonrpc: ^3.2
bitwasp/buffertools: ^0.5.0

使用

安装

composer require ericychu/ethereum-php

示例

实例化客户端

$client = new Ethereum\Client(
    // JSON RPC 地址
    'https://api.infura.io/v1/jsonrpc/ropsten',
    // 以太坊网络 ID
    3,
    // 节点账户的 Keystore
    '',
    // Keystore 的密码
    '',
    // 存储实例,用来保存一些状态值,可以通过实现 \Ethereum\StorageInterface 接口使用你自己的存储
    new \Ethereum\Storage
);

添加合约

$client->contracts
    ->add(
        // 合约别名
        'test_contract',
        // 合约地址
        '',
        // 合约 ABI(JSON String)
        ''
    );

调用合约中的方法

pureview 的方法,可以直接以数组的形式返回反序列化后的数据;nonpayablepayable 的方法返回交易的哈希(\Ethereum\Types\Hash 实例)。

$result = $client->contracts->test_contract->call('test_function', ['test_arg_1', 'test_arg_2']);

监听事件

这里的事件名称是你在合约中定义的事件名称。

注意,监听事件需要通过定时器执行 \Ethereum\Client::synchronizer->sync() 方法来轮询以太坊节点。当有事件到达会执行自定义的回调并传递一个 \Ethereum\Types\Event 的实例,该实例包含了反序列化后的事件输入和相关的区块、交易数据。

$client->contracts->test_contract->watch('Event1', function (\Ethereum\Types\Event $data) {
    var_dump($data);
});

如果使用 Swoole,可以通过 Swoole 的定时器来来轮询。

swoole_timer_tick(1000, function() use ($client) {
    $client->synchronizer->sync();
});

调用 JSON RPC API

支持的方法请查阅 \Ethereum\Methods\Eth\Ethereum\Methods\Web3\Ethereum\Methods\Net 类。

echo $client->eth()->protocolVersion();
echo $client->web3()->clientVersion();
echo $client->net()->version();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].