Documentation

AbstractContract
in package

AbstractYes

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.

Tags
author

DubbaThony

Table of Contents

Properties

$noSend  : bool
$transactionFeesPercentageBump  : int
$contractAddress  : Address
$fallbackFrom  : Address|null
$key  : Key|null
$rpc  : AbstractRPC

Methods

__construct()  : mixed
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.
abi()  : string
Returns raw ABI JSON string, as is during abigen run.
bytecode()  : string|null
Returns raw bytecode hex string, as is during abigen run. Used for deployment.
getContractAddress()  : Address
Gets the contract address this object is bound to.
getEventsFromReceipt()  : array<string|int, AbstractEvent>
Parses all logs from the receipt and returns them in array, in order of events in receipt. All possible transaction types are listed as class-strings in static::getEventsRegistry()
loadPrivK()  : static
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.
setFallbackFrom()  : static
Sets a fallback address. See constructor documentation for details.
unloadPrivK()  : static
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.
unsetFallbackFrom()  : static
Sets the fallback address to null. See constructor documentation for details.
expectBinarySizeNormalizeString()  : string
expectIntArrOfSize()  : array<string|int, mixed>
expectIntOfSize()  : OOGmp
getEventsRegistry()  : array<string|int, mixed>
mkCall()  : string
mkPayableTxn()  : Transaction
mkTxn()  : Transaction
parseOutput()  : mixed
runNonPayableDeploy()  : Transaction
Executes a non-payable smart contract deploy.
runPayableDeploy()  : Transaction
_mkTxn()  : Transaction
getDeployTransaction()  : Transaction
getFromAddress()  : Address

Properties

$noSend

public bool $noSend = false

is to be directly set from outside. If set to true, transactions will be created but not sent. Useful for gas estimations to be presented to user, or inspecting transaction before sending it.

$transactionFeesPercentageBump

public static int $transactionFeesPercentageBump = 0

is to be directly set from outside. It increases gas price by this amount of percent. If set to 0, the bare minimum fees will be applied. If set to negative, probably insufficient fees will be set, but still there is possibility of transaction to go through. If set to for example 20, the fees will be 120% of what is estimated to be bare minimum

Methods

__construct()

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.

public __construct(AbstractRPC $rpc, Address $contractAddress[, Key|null $key = null ][, Address|null $fallbackFrom = null ]) : mixed
Parameters
$rpc : AbstractRPC

The RPC interface used for interacting with Ethereum.

$contractAddress : Address

The address of the deployed smart contract.

$key : Key|null = null

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.

$fallbackFrom : Address|null = null

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.

abi()

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

public abstract static abi() : string
Return values
string

bytecode()

Returns raw bytecode hex string, as is during abigen run. Used for deployment.

public abstract static bytecode() : string|null

Since bytecode is optional, the return is nullable, and when it is null, the deploy methods aren't generated.

Return values
string|null

getContractAddress()

Gets the contract address this object is bound to.

public getContractAddress() : Address
Return values
Address

Address of the contract.

getEventsFromReceipt()

Parses all logs from the receipt and returns them in array, in order of events in receipt. All possible transaction types are listed as class-strings in static::getEventsRegistry()

public static getEventsFromReceipt(Receipt $rcpt) : array<string|int, AbstractEvent>
Parameters
$rcpt : Receipt

The transaction receipt.

Tags
throws
EthBinderLogicException
throws
InvalidLengthException
throws
EthBinderArgumentException
Return values
array<string|int, AbstractEvent>

Array of parsed events.

loadPrivK()

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.

public loadPrivK(Key $key) : static
Parameters
$key : Key

The private key.

Return values
static

The same object instance.

setFallbackFrom()

Sets a fallback address. See constructor documentation for details.

public setFallbackFrom(Address $addr) : static
Parameters
$addr : Address

The address to set.

Return values
static

The same object instance.

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.

public unloadPrivK() : static
Return values
static

The same object instance.

unsetFallbackFrom()

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

public unsetFallbackFrom() : static
Return values
static

The same object instance.

expectBinarySizeNormalizeString()

protected static expectBinarySizeNormalizeString(string $binOrHex, int $length) : string
Parameters
$binOrHex : string
$length : int
Tags
throws
EthBinderArgumentException
Return values
string

expectIntArrOfSize()

protected static expectIntArrOfSize(bool $unsigned, array<string|int, mixed> $value, int $bits) : array<string|int, mixed>
Parameters
$unsigned : bool
$value : array<string|int, mixed>
$bits : int
Tags
throws
EthBinderArgumentException
Return values
array<string|int, mixed>

getEventsRegistry()

protected abstract static getEventsRegistry() : array<string|int, mixed>
Return values
array<string|int, mixed>

runNonPayableDeploy()

Executes a non-payable smart contract deploy.

protected static runNonPayableDeploy(string $constructorParamsSig, Key $pk, AbstractRPC $rpc[, array<string|int, mixed> $params = [] ]) : Transaction
Parameters
$constructorParamsSig : string

ABI constructor signature.

$pk : Key

Private key for signing.

$rpc : AbstractRPC

RPC interface for Ethereum.

$params : array<string|int, mixed> = []

ABI encoded constructor params.

Tags
throws
EthBinderArgumentException
throws
EthBinderLogicException
throws
EthBinderRuntimeException
throws
InvalidLengthException
throws
RPCInvalidResponseParamException
throws
UnexpectedUnsignedException
throws
RPCGeneralException
throws
RPCNotFoundException
Return values
Transaction

The resulting transaction.

runPayableDeploy()

protected static runPayableDeploy(string $constructorParamsSig, Key $pk, AbstractRPC $rpc, OOGmp $value[, array<string|int, mixed> $params = [] ]) : Transaction
Parameters
$constructorParamsSig : string
$pk : Key
$rpc : AbstractRPC
$value : OOGmp
$params : array<string|int, mixed> = []
Tags
throws
EthBinderLogicException
throws
InvalidLengthException
throws
UnexpectedUnsignedException
throws
EthBinderArgumentException
throws
RPCInvalidResponseParamException
throws
EthBinderRuntimeException
Return values
Transaction

_mkTxn()

private _mkTxn(string $signature, array<string|int, mixed> $params, bool $careAboutEstims[, bool $trimmedSignature = false ][, OOGmp|null $value = null ]) : Transaction
Parameters
$signature : string
$params : array<string|int, mixed>
$careAboutEstims : bool
$trimmedSignature : bool = false
$value : OOGmp|null = null
Tags
throws
EthBinderLogicException
throws
EthBinderArgumentException
throws
RPCInvalidResponseParamException
throws
EthBinderRuntimeException
Return values
Transaction

getDeployTransaction()

private static getDeployTransaction(string $constructorParamsSig, Key $pk, AbstractRPC $rpc, array<string|int, mixed> $params, OOGmp|null $value) : Transaction
Parameters
$constructorParamsSig : string
$pk : Key
$rpc : AbstractRPC
$params : array<string|int, mixed>
$value : OOGmp|null
Tags
throws
EthBinderLogicException
throws
InvalidLengthException
throws
EthBinderArgumentException
throws
RPCInvalidResponseParamException
throws
EthBinderRuntimeException
Return values
Transaction

        
On this page

Search results