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\AbstractContract Class Reference

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 ()
 

Detailed Description

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.

Author
DubbaThony

Constructor & Destructor Documentation

◆ __construct()

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.

Parameters
AbstractRPC$rpcThe RPC interface used for interacting with Ethereum.
Address$contractAddressThe address of the deployed smart contract.
?Key$keyOptional, 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$fallbackFromOptional, 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.

Member Function Documentation

◆ abi()

static M8B\EtherBinder\Contract\AbstractContract::abi ( )
staticabstract

Returns raw ABI JSON string, as is during abigen run.

Returns
string

◆ bytecode()

static M8B\EtherBinder\Contract\AbstractContract::bytecode ( )
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.

Returns
?string

◆ expectBinarySizeNormalizeString()

static M8B\EtherBinder\Contract\AbstractContract::expectBinarySizeNormalizeString ( string $binOrHex,
int $length )
staticprotected
Exceptions
EthBinderArgumentException

◆ expectIntArrOfSize()

static M8B\EtherBinder\Contract\AbstractContract::expectIntArrOfSize ( bool $unsigned,
array $value,
int $bits )
staticprotected
Exceptions
EthBinderArgumentException

◆ expectIntOfSize()

static M8B\EtherBinder\Contract\AbstractContract::expectIntOfSize ( bool $unsigned,
int|OOGmp $value,
int $bits )
staticprotected
Exceptions
EthBinderArgumentException

◆ getContractAddress()

M8B\EtherBinder\Contract\AbstractContract::getContractAddress ( )

Gets the contract address this object is bound to.

Returns
Address Address of the contract.

◆ loadPrivK()

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.

Parameters
Key$keyThe private key.
Returns
static The same object instance.

◆ mkCall()

M8B\EtherBinder\Contract\AbstractContract::mkCall ( string $signature,
array $params = [] )
protected
Exceptions
EthBinderArgumentException
EthBinderLogicException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ mkPayableTxn()

M8B\EtherBinder\Contract\AbstractContract::mkPayableTxn ( string $signature,
OOGmp $value,
array $params )
protected
Exceptions
InvalidLengthException
EthBinderArgumentException
EthBinderLogicException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ mkTxn()

M8B\EtherBinder\Contract\AbstractContract::mkTxn ( string $signature,
array $params = [] )
protected
Exceptions
EthBinderLogicException
InvalidLengthException
UnexpectedUnsignedException
EthBinderArgumentException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ parseOutput()

M8B\EtherBinder\Contract\AbstractContract::parseOutput ( string $output,
string $type,
?array $tupleReplacements = null )
protected
Exceptions
EthBinderLogicException
EthBinderArgumentException
EthBinderRuntimeException

◆ runNonPayableDeploy()

static M8B\EtherBinder\Contract\AbstractContract::runNonPayableDeploy ( string $constructorParamsSig,
# Key $pk[SensitiveParameter],
AbstractRPC $rpc,
array $params = [] )
staticprotected

Executes a non-payable smart contract deploy.

Parameters
string$constructorParamsSigABI constructor signature.
Key$pkPrivate key for signing.
AbstractRPC$rpcRPC interface for Ethereum.
array$paramsABI encoded constructor params.
Returns
Transaction The resulting transaction.
Exceptions
EthBinderArgumentException
EthBinderLogicException
EthBinderRuntimeException
InvalidLengthException
RPCInvalidResponseParamException
UnexpectedUnsignedException
RPCGeneralException
RPCNotFoundException

◆ runPayableDeploy()

static M8B\EtherBinder\Contract\AbstractContract::runPayableDeploy ( string $constructorParamsSig,
# Key $pk[SensitiveParameter],
AbstractRPC $rpc,
OOGmp $value,
array $params = [] )
staticprotected
Exceptions
EthBinderLogicException
InvalidLengthException
UnexpectedUnsignedException
EthBinderArgumentException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ setFallbackFrom()

M8B\EtherBinder\Contract\AbstractContract::setFallbackFrom ( Address $addr)

Sets a fallback address. See constructor documentation for details.

Parameters
Address$addrThe address to set.
Returns
static The same object instance.

◆ unloadPrivK()

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.

Returns
static The same object instance.

◆ unsetFallbackFrom()

M8B\EtherBinder\Contract\AbstractContract::unsetFallbackFrom ( )

Sets the fallback address to null. See constructor documentation for details.

Returns
static The same object instance.

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