2017 © Pedro PelĂĄez
 

library php-eth-raw-tx

PHP tool for creating Ethereum raw transactions

image

domraider/php-eth-raw-tx

PHP tool for creating Ethereum raw transactions

  • Friday, June 1, 2018
  • by etienneroudeix
  • Repository
  • 3 Watchers
  • 16 Stars
  • 215 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 4 Open issues
  • 4 Versions
  • 139 % Grown

The README.md

php-eth-raw-tx

PHP tool to create Ethereum raw transaction, (*1)

Pre-requisite

secp256k1-php

You need secp256k1-php. Which itself needs secp256k1 to be installed on your system., (*2)

Last tests were run using the following versions : * secp256k1-lastest * secp256k1-php-0.1.2, (*3)

You will need gcc, libtool, make, automake , which is standard package you can grab from apt, yum, brew..., (*4)

First install secp256k1, (*5)

$> 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., (*6)

Updating this section with fix for issue #35. I have added SED to make extension compatible with latest secp256k1 library, (*7)

$> 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, (*8)

extension=secp256k1.so

Examples

You may run examples in examples folder., (*9)

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 :, (*10)

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., (*11)

  • 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 a eth_getTransactionByHash call.
  • decode_smart_contract_reponse : Tool to read an eth_call response.
  • decode_tx_params : Tool to decode a data 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, (*12)

vendor/bin/peridot tests/

The Versions

01/06 2018

dev-master

9999999-dev

PHP tool for creating Ethereum raw transactions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Etienne Roudeix
by Mike Nopère

01/03 2018

0.0.2

0.0.2.0

PHP tool for creating Ethereum raw transactions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Etienne Roudeix
by Mike Nopère

28/02 2018

dev-feature/encode_decode_dynamic_data_oop

dev-feature/encode_decode_dynamic_data_oop

PHP tool for creating Ethereum raw transactions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Etienne Roudeix

23/01 2018

0.0.1

0.0.1.0

PHP tool for creating Ethereum raw transactions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Etienne Roudeix