Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
|
Public Member Functions | |
__construct (protected AbstractRPC $rpc, protected Address $contractAddress, #[SensitiveParameter] protected ?Key $key=null, protected ?Address $fallbackFrom=null) | |
getContractAddress () | |
unloadPrivK () | |
loadPrivK (#[SensitiveParameter] Key $key) | |
setFallbackFrom (Address $addr) | |
unsetFallbackFrom () | |
Static Public Member Functions | |
static | abi () |
static | bytecode () |
Public Attributes | |
bool | $noSend = false |
Static Public Attributes | |
static int | $transactionFeesPercentageBump = 0 |
Protected Member Functions | |
parseOutput (string $output, string $type, ?array $tupleReplacements=null) | |
mkCall (string $signature, array $params=[]) | |
mkTxn (string $signature, array $params=[]) | |
mkPayableTxn (string $signature, OOGmp $value, array $params) | |
Static Protected Member Functions | |
static | runNonPayableDeploy (string $constructorParamsSig, #[SensitiveParameter] Key $pk, AbstractRPC $rpc, array $params=[]) |
static | runPayableDeploy (string $constructorParamsSig, #[SensitiveParameter] Key $pk, AbstractRPC $rpc, OOGmp $value, array $params=[]) |
static | expectBinarySizeNormalizeString (string $binOrHex, int $length) |
static | expectIntOfSize (bool $unsigned, int|OOGmp $value, int $bits) |
static | expectIntArrOfSize (bool $unsigned, array $value, int $bits) |
static | getEventsRegistry () |
AbstractContract serves as the base class for all Ethereum smart contract bindings. It handles various tasks such as transaction management and encoding/decoding of ABI parameters of underlying contract binding.
M8B\EtherBinder\Contract\AbstractContract::__construct | ( | protected AbstractRPC | $rpc, |
protected Address | $contractAddress, | ||
# protected ?Key | $key[SensitiveParameter] = null, | ||
protected ?Address | $fallbackFrom = null ) |
Constructs a new instance of the underlying binding. This assumes the contract is deployed. If it's not the case, deploy it using static functions.
AbstractRPC | $rpc | The RPC interface used for interacting with Ethereum. |
Address | $contractAddress | The address of the deployed smart contract. |
?Key | $key | Optional, nullable private key for signing transactions. Without it transactions will be returned unsigned and unsent, and calls/estimations will be with from field $fallbackFrom. |
?Address | $fallbackFrom | Optional, nullable address to be used if the private key is not available for calls from field and gas estimations. If this field is null, Address::NULL() will be used. If you intend to sign the transaction, it's good idea to set this field to address of private key, since contracts may use msg.sender which may change if transaction reverts, or change which branches get executing resulting in bogus gas estimations. Note, that reverts throw exceptions. |
|
staticabstract |
Returns raw ABI JSON string, as is during abigen run.
|
staticabstract |
Returns raw bytecode hex string, as is during abigen run. Used for deployment. Since bytecode is optional, the return is nullable, and when it is null, the deploy methods aren't generated.
|
staticprotected |
EthBinderArgumentException |
|
staticprotected |
EthBinderArgumentException |
|
staticprotected |
EthBinderArgumentException |
M8B\EtherBinder\Contract\AbstractContract::getContractAddress | ( | ) |
Gets the contract address this object is bound to.
M8B\EtherBinder\Contract\AbstractContract::loadPrivK | ( | # Key | $key[SensitiveParameter] | ) |
Loads a private key into the object for signing transactions. Calls will be done using address that comes from this key, and fallback address will be not used.
Key | $key | The private key. |
|
protected |
EthBinderArgumentException | |
EthBinderLogicException | |
RPCInvalidResponseParamException | |
EthBinderRuntimeException |
|
protected |
InvalidLengthException | |
EthBinderArgumentException | |
EthBinderLogicException | |
RPCInvalidResponseParamException | |
EthBinderRuntimeException |
|
protected |
EthBinderLogicException | |
InvalidLengthException | |
UnexpectedUnsignedException | |
EthBinderArgumentException | |
RPCInvalidResponseParamException | |
EthBinderRuntimeException |
|
protected |
EthBinderLogicException | |
EthBinderArgumentException | |
EthBinderRuntimeException |
|
staticprotected |
Executes a non-payable smart contract deploy.
string | $constructorParamsSig | ABI constructor signature. |
Key | $pk | Private key for signing. |
AbstractRPC | $rpc | RPC interface for Ethereum. |
array | $params | ABI encoded constructor params. |
EthBinderArgumentException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidLengthException | |
RPCInvalidResponseParamException | |
UnexpectedUnsignedException | |
RPCGeneralException | |
RPCNotFoundException |
|
staticprotected |
EthBinderLogicException | |
InvalidLengthException | |
UnexpectedUnsignedException | |
EthBinderArgumentException | |
RPCInvalidResponseParamException | |
EthBinderRuntimeException |
M8B\EtherBinder\Contract\AbstractContract::setFallbackFrom | ( | Address | $addr | ) |
Sets a fallback address. See constructor documentation for details.
Address | $addr | The address to set. |
M8B\EtherBinder\Contract\AbstractContract::unloadPrivK | ( | ) |
Removes the private key from the object, making it no longer sign transactions, and fallback address will be used for estimations, if set, otherwise NULL address will be used.
M8B\EtherBinder\Contract\AbstractContract::unsetFallbackFrom | ( | ) |
Sets the fallback address to null. See constructor documentation for details.