Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
Loading...
Searching...
No Matches
M8B\EtherBinder\Contract\ABIEncoder Class Reference

Static Public Member Functions

static encode (string $signature, array $data, bool $withTransactionSignature=true)
 
static explodeTuple (string $types)
 

Detailed Description

ABIEncoder handles the encoding and decoding of ABI data in Ethereum smart contracts.

Author
DubbaThony

Member Function Documentation

◆ encode()

static M8B\EtherBinder\Contract\ABIEncoder::encode ( string $signature,
array $data,
bool $withTransactionSignature = true )
static

Encodes ABI data for an Ethereum smart contract function. It returns binary blob which can be bin2hex()-ed for presentation purposes.

Parameters
string$signatureThe function signature including the function name and its parameters.
array$dataThe data to encode.
bool$withTransactionSignatureWhether to prepend the function selector hash to the encoded data.
Returns
string The ABI-encoded binary blob.
Exceptions
EthBinderLogicExceptionThrown if function name end is not found or indicates other bug.
EthBinderArgumentExceptionThrown if validation of signature fails.

◆ explodeTuple()

static M8B\EtherBinder\Contract\ABIEncoder::explodeTuple ( string $types)
static

Splits a tuple type into its constituent types, preserving child tuples as single type. Input must start with ( and end with ), without function name etc. Example input and output: "(uint256,(uint8,uint16)[],bytes)" => ["uint256", "(uint8,uint16)[]", "bytes"]

Parameters
string$typesThe tuple types string.
Returns
array An array of the constituent types.
Exceptions
EthBinderArgumentExceptionThrown if provided tuple is invalid.

The documentation for this class was generated from the following file: