domraider / php-eth-raw-tx
PHP tool for creating Ethereum raw transactions
Installs: 2 453
Dependents: 0
Suggesters: 0
Security: 0
Stars: 37
Watchers: 3
Forks: 15
Open Issues: 5
Requires
- php-64bit: >=7.1
- bitwasp/buffertools: ^0.5.0
- bitwasp/secp256k1-php: ^0.1.2
- kornrunner/keccak: ^1.0
Requires (Dev)
- peridot-php/leo: ^1.6
- peridot-php/peridot: ^1.19
This package is not auto-updated.
Last update: 2024-11-19 16:16:43 UTC
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_getTransactionByHash
call.decode_smart_contract_reponse
: Tool to read aneth_call
response.decode_tx_params
: Tool to decode adata
field 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/