amendozadev/eth_rpc
Composer 安装命令:
composer require amendozadev/eth_rpc
包简介
Create Ethereum wallet and/or connect to JSON-RPC Endpoint from Ethereum or compatibles like BSC
关键字:
README 文档
README
Create Ethereum wallet and/or connect to JSON-RPC Endpoint from Ethereum or compatibles like BSC
This library requires the bcmath PHP extension.
Installation:
composer require amendozadev/eth_rpc
Usage:
$wallet = new \aMendoza\Eth_rpc\Wallet(); //Create new wallet $account = $wallet->createWallet(); //['address' => '0xf1b4d0755ef13025c8b1b398237652b7c3ea8dc0', 'private_key' => '81011e578366208ab232d726cb910d1dffd132c84659cede2bfc6b5d0404d234'] //Connect to RPC URL (URL : Chain ID) $wallet->rpc_url('https://ropsten.infura.io/v3/', 3); // get gas price in wei $wei = $wallet->gasPrice(); echo $wei; // "5000000000" // convert to eth: $eth = $wallet->wei2eth($wei); echo $eth; // "0.000000005000000000" // block number $block = $wallet->blockNumber(); echo $block; //18143442 // account balance $balance = $wallet->getBalance($account['address']); //Send Transaction try { $to = '0xa48e2ff1e6e4ef5952c64dc505d6983a92d320f7'; $nonce = 0; $gasPrice = 10; $gasLimit = 21000; $raw = $wallet->createTransaction($account['address'], $to, '0.0002', $account['private_key'], $nonce, $gasPrice, $gasLimit); echo $wallet->sendTransaction($raw); //0xa91377938abd362e2486398d467a6c7c96b1100424ef1d20318e82bffbd8f0e8 }catch (Exception $exception){ echo $exception->getMessage(); }
Crypto
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-27