domraider/php-eth-raw-tx
Composer 安装命令:
composer require domraider/php-eth-raw-tx
包简介
PHP tool for creating Ethereum raw transactions
README 文档
README
PHP tool to create Ethereum raw transaction
Pre-requisite
secp256k1-php
You need secp256k1-php. Which itself needs secp256k1 to be installed on your system.
Last tests were run using the following versions :
- secp256k1-lastest
- secp256k1-php-0.1.2
You will need gcc, libtool, make, automake , which is standard package you can grab from apt, yum, brew...
First install secp256k1
$> curl -L0k https://github.com/bitcoin-core/secp256k1/archive/master.zip > secp256k1-latest.zip $> unzip secp256k1-latest.zip $> cd secp256k1-master $> ./autogen.sh $> ./configure --enable-experimental --enable-module-{ecdh,recovery} $> make $> sudo make install $>
Then secp256k1-php v0.1.2.
Updating this section with fix for issue #35. I have added SED to make extension compatible with latest secp256k1 library
$> curl -L0k https://github.com/Bit-Wasp/secp256k1-php/archive/v0.1.2.zip > secp256k1-php-0.1.2.zip $> unzip secp256k1-php-0.1.2.zip $> cd secp256k1-php-0.1.2/secp256k1 $> sed -i 's/secp256k1_ecdh(ctx, resultChars, pubkey, privKey->val);/secp256k1_ecdh(ctx, resultChars, pubkey, privKey->val, NULL, NULL);/' secp256k1.c $> phpize $> ./configure --with-secp256k1 $> make $> sudo make install $>
Finally add extension to you php.ini file
extension=secp256k1.so
Examples
You may run examples in examples folder.
Creating a raw transaction
$tx = new \EthereumRawTx\Transaction( \BitWasp\Buffertools\Buffer::hex('d44d259015b61a5fe5027221239d840d92583adb'), \BitWasp\Buffertools\Buffer::int(5 * 10**18), ); $raw = $tx->getRaw(\BitWasp\Buffertools\Buffer::hex(MY_PRIVATE_KEY));
Demo :
Explore examples folder for demos.
Some are meant to generate a whole signed tx to write the blockchain. They can be broadcasted using eth_sendRawTransaction using JSON-RPC.
Some others aim to read the blockchain and generated data should simply be send using eth_call using JSON-RPC.
Some are simply utility reading tools.
Unfortunately some features may not be demonstrated yet. Do not hesitate to contribute.
call_smart_contract: Generate a raw data to read a Smart Contract.check_signature: Tool to recover the signer address of a transaction.decode_smart_contract_event_reponse: Tool to decode events from aeth_getTransactionByHashcall.decode_smart_contract_reponse: Tool to read aneth_callresponse.decode_tx_params: Tool to decode adatafield from a transaction.deploy_smart_contract: Generate a signed raw transaction for deploying a new Smart Contract.event_smart_contract: Tool to get an event hash.send_ether: Generate a signed raw transaction for sending ETH .send_smart_contract: Generate a signed raw transaction for writing on a Smart Contract function.
Tests
You can run specs with
vendor/bin/peridot tests/
domraider/php-eth-raw-tx 适用场景与选型建议
domraider/php-eth-raw-tx 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2018 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 domraider/php-eth-raw-tx 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 domraider/php-eth-raw-tx 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-05