|
static | encode (string $signature, array $data, bool $withTransactionSignature=true) |
|
static | explodeTuple (string $types) |
|
ABIEncoder handles the encoding and decoding of ABI data in Ethereum smart contracts.
- Author
- DubbaThony
◆ 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 | $signature | The function signature including the function name and its parameters. |
array | $data | The data to encode. |
bool | $withTransactionSignature | Whether to prepend the function selector hash to the encoded data. |
- Returns
- string The ABI-encoded binary blob.
- Exceptions
-
EthBinderLogicException | Thrown if function name end is not found or indicates other bug. |
EthBinderArgumentException | Thrown 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 | $types | The tuple types string. |
- Returns
- array An array of the constituent types.
- Exceptions
-
EthBinderArgumentException | Thrown if provided tuple is invalid. |
The documentation for this class was generated from the following file:
- src/Contract/ABIEncoder.php