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\RPC\Modules\AbstractModule Class Reference
Inheritance diagram for M8B\EtherBinder\RPC\Modules\AbstractModule:
M8B\EtherBinder\RPC\Modules\Debug M8B\EtherBinder\RPC\Modules\Eth M8B\EtherBinder\RPC\Modules\Net M8B\EtherBinder\RPC\Modules\Web3 M8B\EtherBinder\RPC\Compound M8B\EtherBinder\RPC\AbstractRPC M8B\EtherBinder\RPC\HttpRPC

Public Member Functions

 runRpc (string $method, ?array $params=null)
 

Protected Member Functions

 blockParam (int|BlockParam $blockNumber)
 
 blockHash (Hash|Block $block)
 

Detailed Description

AbstractModule serves as the base class for specific modules, enabling them to access the runRpc() method. Note that only the first module in the inheritance chain will inherit this, as PHP allows single inheritance only.

Author
DubbaThony

Member Function Documentation

◆ blockHash()

M8B\EtherBinder\RPC\Modules\AbstractModule::blockHash ( Hash|Block $block)
protected

Either extracts block hash from block and returns it as hex string, or returns hash hex string. Used for parameter normalization in RPC calls, for convenience of API.

Parameters
Hash | Block$blockthe block object or a Hash object
Returns
string hexadecimal representation of the block hash

◆ blockParam()

M8B\EtherBinder\RPC\Modules\AbstractModule::blockParam ( int|BlockParam $blockNumber)
protected

Normalizes a block number parameter for RPC calls.

Parameters
int | BlockParam$blockNumberthe block number or a BlockParam object
Returns
string hexadecimal representation of the block number or RPC alias string, such as "latest"

◆ runRpc()

M8B\EtherBinder\RPC\Modules\AbstractModule::runRpc ( string $method,
?array $params = null )
abstract

Executes an RPC call with the given method and parameters.

Parameters
string$methodthe RPC method name
array | null$paramsoptional array of parameters for the RPC call
Returns
array result of the RPC call
array 'result' field of the RPC response. If the result is not an array, it's wrapped in an array under key 0.
Exceptions
RPCGeneralExceptionif any unexpected error is present in RPC response
RPCInvalidResponseParamExceptionif the 'result' field is missing in the response
RPCNotFoundExceptionif the method is not found

Reimplemented in M8B\EtherBinder\RPC\AbstractRPC.


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