分享最近开发的以太方套件 ethereum-tx

分享链接:https://github.com/web3p/ethereum-tx
先前练习写了 web3.php
这次练习写交易的函示库
各位可以使用 ethereum-tx 制作和签章一个以太坊交易
下面稍微介绍怎么签章交易
一般的交易:

use Web3p\EthereumTx\Transaction;

$transaction = new Transaction([
    'nonce' => '0x01',
    'from' => '0x0000000000000000000000000000000000000000',
    'to' => ''0x0000000000000000000000000000000000000000',
    'gas' => '0x76c0',
    'gasPrice' => '0x9184e72a000',
    'value' => '0x9184e72a',
    'chainId' => 1,
    'data' => ''
]);

合约交易:

use Web3p\EthereumTx\Transaction;

$transaction = new Transaction([
    'nonce' => '0x01',
    'from' => '0x0000000000000000000000000000000000000000',
    'to' => ''0x0000000000000000000000000000000000000000', // contract address
    'gas' => '0x76c0',
    'gasPrice' => '0x9184e72a000',
    'value' => '0x9184e72a',
    'chainId' => 1,
    'data' => 'contract function data you want to send'
]);

签章:

$signedTransaction = $transaction->sign('your private key');

程式码还有很多地方可以改进,也希望各位大神能提供意见
谢谢!

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!