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

Public Member Functions

 __construct (string $url, array $extraHeaders=[])
 
 __destruct ()
 
 raw (string $method, ?array $params=null)
 
 runRpc (string $method, ?array $params=null)
 
 calcAvgTip (int $blockNumbers=3)
 
 isLookingLikeLondon ()
 
 web3ClientVersion ()
 
 web3Sha3Keccak (string $inputHex)
 
 web3Sha3KeccakBin (string $inputBin)
 
 netVersion ()
 
 netListening ()
 
 netPeerCount ()
 
 ethProtocolVersion ()
 
 ethSyncing ()
 
 ethCoinbase ()
 
 ethChainID ()
 
 ethMining ()
 
 ethHashrate ()
 
 ethGasPrice ()
 
 ethAccounts ()
 
 ethBlockNumber ()
 
 ethGetBalance (Address $address, int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethGetStorageAt (Address $address, OOGmp $position, int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethGetTransactionCount (Address $address, int|BlockParam $blockParam=BlockParam::PENDING)
 
 ethGetBlockTransactionCountByHash (Hash|Block $block)
 
 ethGetBlockTransactionCountByNumber (int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethGetUncleCountByBlockHash (Hash|Block $block)
 
 ethGetUncleCountByBlockNumber (int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethGetCode (Address $address, int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethSign (Address $address, string $dataHex)
 
 ethSignTransaction (Transaction $txn, Address $from)
 
 ethSendTransaction (Transaction $txn, Address $from)
 
 ethSendRawTransaction (Transaction $signedTransaction)
 
 ethSendRawTransactionHex (string $rawTransactionHex)
 
 ethCall (Transaction $message, ?Address $from=null, int|BlockParam $blockParam=BlockParam::LATEST)
 
 ethEstimateGas (Transaction $txn, ?Address $from)
 
 ethGetBlockByHash (Hash $hash, bool $fullBlock=false)
 
 ethGetBlockByNumber (int|BlockParam $blockParam=BlockParam::LATEST, bool $fullBlock=false)
 
 ethGetTransactionByHash (Hash $hash)
 
 ethGetTransactionByBlockHashAndIndex (Hash $hash, int $index)
 
 ethGetTransactionByBlockNumberAndIndex (int|BlockParam $blockParam, int $index)
 
 ethGetTransactionReceipt (Hash $hash)
 
 ethGetUncleByBlockHashAndIndex (Hash $hash, int $unclePos)
 
 ethGetUncleByBlockNumberAndIndex (int|BlockParam $blockParam, int $unclePos)
 
 ethMaxPriorityFeePerGas ()
 
 ethNewFilter (Address|array $address, null|int|BlockParam $fromBlock, null|int|BlockParam $toBlock, string|bool|HashSerializable|array $topic0, null|string|bool|HashSerializable|array $topic1=null, null|string|bool|HashSerializable|array $topic2=null, null|string|bool|HashSerializable|array $topic3=null)
 
 ethGetLogs (Address|array $address, null|int|BlockParam $fromBlock, null|int|BlockParam $toBlock, null|Hash $blockHash, string|bool|HashSerializable|array $topic0, null|string|bool|HashSerializable|array $topic1=null, null|string|bool|HashSerializable|array $topic2=null, null|string|bool|HashSerializable|array $topic3=null)
 
 ethGetFilterChanges (OOGmp $filterId)
 
 ethGetFilterLogs (OOGmp $filterId)
 
 debugGetRawBlock (int|BlockParam $blockParam=BlockParam::LATEST)
 
 debugGetRawHeader (int|BlockParam $blockParam=BlockParam::LATEST)
 
 debugGetRawReceipts (int|BlockParam $blockParam=BlockParam::LATEST)
 
 debugGetRawTransaction (Hash $h)
 

Protected Member Functions

 parseFilterInput (Address|array $address, null|int|BlockParam $fromBlock, null|int|BlockParam $toBlock, null|Hash $blockHash, string|bool|HashSerializable|array $topic0, null|string|bool|HashSerializable|array $topic1=null, null|string|bool|HashSerializable|array $topic2=null, null|string|bool|HashSerializable|array $topic3=null)
 
 blockParam (int|BlockParam $blockNumber)
 
 blockHash (Hash|Block $block)
 

Detailed Description

HttpRPC provides functionality to make JSON-RPC calls over HTTP / HTTPS via curl. Curl handle persist across calls.

Author
DubbaThony

Constructor & Destructor Documentation

◆ __construct()

M8B\EtherBinder\RPC\HttpRPC::__construct ( string $url,
array $extraHeaders = [] )

Constructs a new HttpRPC object.

Parameters
string$urlEndpoint URL for JSON-RPC calls.
array$extraHeadersAdditional HTTP headers.
Exceptions
InvalidURLExceptionif the provided URL is not valid or uses unsupported protocols.

◆ __destruct()

M8B\EtherBinder\RPC\HttpRPC::__destruct ( )

Closes the cURL handle on object destruction.

Member Function Documentation

◆ blockHash()

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

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

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"

◆ calcAvgTip()

M8B\EtherBinder\RPC\Compound::calcAvgTip ( int $blockNumbers = 3)
inherited

Calculates the average EIP1559 tip over a range of blocks. If the underlying chain doesn't look like EIP1559 chain, it returns fallback of 1 GWEI.

Parameters
int$blockNumbersnumber of recent blocks to consider
Returns
OOGmp average tip across considered blocks
Exceptions
EthBinderLogicException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ debugGetRawBlock()

M8B\EtherBinder\RPC\Modules\Debug::debugGetRawBlock ( int|BlockParam $blockParam = BlockParam::LATEST)
inherited
Exceptions
EthBinderLogicException
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ debugGetRawHeader()

M8B\EtherBinder\RPC\Modules\Debug::debugGetRawHeader ( int|BlockParam $blockParam = BlockParam::LATEST)
inherited
Exceptions
EthBinderLogicException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ debugGetRawReceipts()

M8B\EtherBinder\RPC\Modules\Debug::debugGetRawReceipts ( int|BlockParam $blockParam = BlockParam::LATEST)
inherited
Exceptions
EthBinderLogicException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ debugGetRawTransaction()

M8B\EtherBinder\RPC\Modules\Debug::debugGetRawTransaction ( Hash $h)
inherited
Parameters
Hash$h
Returns
Transaction
Exceptions
BadAddressChecksumException
EthBinderLogicException
InvalidHexException
InvalidHexLengthException
NotSupportedException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException
EthBinderRuntimeException

◆ ethAccounts()

M8B\EtherBinder\RPC\Modules\Eth::ethAccounts ( )
inherited
Returns
Address[]
Exceptions
EthBinderLogicException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ ethBlockNumber()

M8B\EtherBinder\RPC\Modules\Eth::ethBlockNumber ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ ethCall()

M8B\EtherBinder\RPC\Modules\Eth::ethCall ( Transaction $message,
?Address $from = null,
int|BlockParam $blockParam = BlockParam::LATEST )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethChainID()

M8B\EtherBinder\RPC\Modules\Eth::ethChainID ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethCoinbase()

M8B\EtherBinder\RPC\Modules\Eth::ethCoinbase ( )
inherited
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException
EthBinderLogicException

◆ ethEstimateGas()

M8B\EtherBinder\RPC\Modules\Eth::ethEstimateGas ( Transaction $txn,
?Address $from )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGasPrice()

M8B\EtherBinder\RPC\Modules\Eth::ethGasPrice ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetBalance()

M8B\EtherBinder\RPC\Modules\Eth::ethGetBalance ( Address $address,
int|BlockParam $blockParam = BlockParam::LATEST )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetBlockByHash()

M8B\EtherBinder\RPC\Modules\Eth::ethGetBlockByHash ( Hash $hash,
bool $fullBlock = false )
inherited
Parameters
Hash$hash
bool$fullBlock
Returns
Block
Exceptions
EthBinderLogicException
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ ethGetBlockByNumber()

M8B\EtherBinder\RPC\Modules\Eth::ethGetBlockByNumber ( int|BlockParam $blockParam = BlockParam::LATEST,
bool $fullBlock = false )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderLogicException

◆ ethGetBlockTransactionCountByHash()

M8B\EtherBinder\RPC\Modules\Eth::ethGetBlockTransactionCountByHash ( Hash|Block $block)
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ ethGetBlockTransactionCountByNumber()

M8B\EtherBinder\RPC\Modules\Eth::ethGetBlockTransactionCountByNumber ( int|BlockParam $blockParam = BlockParam::LATEST)
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ ethGetCode()

M8B\EtherBinder\RPC\Modules\Eth::ethGetCode ( Address $address,
int|BlockParam $blockParam = BlockParam::LATEST )
inherited
Exceptions
RPCNotFoundException
RPCInvalidResponseParamException
RPCGeneralException

◆ ethGetFilterChanges()

M8B\EtherBinder\RPC\Modules\Eth::ethGetFilterChanges ( OOGmp $filterId)
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetFilterLogs()

M8B\EtherBinder\RPC\Modules\Eth::ethGetFilterLogs ( OOGmp $filterId)
inherited
Parameters
OOGmp$filterId
Returns
Log[]
Exceptions
BadAddressChecksumException
EthBinderLogicException
InvalidHexException
InvalidHexLengthException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ ethGetLogs()

M8B\EtherBinder\RPC\Modules\Eth::ethGetLogs ( Address|array $address,
null|int|BlockParam $fromBlock,
null|int|BlockParam $toBlock,
null|Hash $blockHash,
string|bool|HashSerializable|array $topic0,
null|string|bool|HashSerializable|array $topic1 = null,
null|string|bool|HashSerializable|array $topic2 = null,
null|string|bool|HashSerializable|array $topic3 = null )
inherited
Parameters
Address | array$address
int | BlockParam | null$fromBlockif $blockHash not null, it MUST be null
int | BlockParam | null$toBlockif $blockHash not null, it MUST be null
Hash | null$blockHashif $fromBlock and/or $toBlock is not null, it MUST be null
string | bool | HashSerializable | array$topic0
string | bool | HashSerializable | array | null$topic1
string | bool | HashSerializable | array | null$topic2
string | bool | HashSerializable | array | null$topic3
Returns
Log[]
Exceptions
BadAddressChecksumException
EthBinderArgumentException
EthBinderLogicException
InvalidHexException
InvalidHexLengthException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ ethGetStorageAt()

M8B\EtherBinder\RPC\Modules\Eth::ethGetStorageAt ( Address $address,
OOGmp $position,
int|BlockParam $blockParam = BlockParam::LATEST )
inherited
Exceptions
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ ethGetTransactionByBlockHashAndIndex()

M8B\EtherBinder\RPC\Modules\Eth::ethGetTransactionByBlockHashAndIndex ( Hash $hash,
int $index )
inherited
Exceptions
NotSupportedException
EthBinderLogicException
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetTransactionByBlockNumberAndIndex()

M8B\EtherBinder\RPC\Modules\Eth::ethGetTransactionByBlockNumberAndIndex ( int|BlockParam $blockParam,
int $index )
inherited
Exceptions
NotSupportedException
EthBinderLogicException
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetTransactionByHash()

M8B\EtherBinder\RPC\Modules\Eth::ethGetTransactionByHash ( Hash $hash)
inherited
Exceptions
EthBinderLogicException
NotSupportedException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ ethGetTransactionCount()

M8B\EtherBinder\RPC\Modules\Eth::ethGetTransactionCount ( Address $address,
int|BlockParam $blockParam = BlockParam::PENDING )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethGetTransactionReceipt()

M8B\EtherBinder\RPC\Modules\Eth::ethGetTransactionReceipt ( Hash $hash)
inherited
Exceptions
NotSupportedException
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderLogicException

◆ ethGetUncleByBlockHashAndIndex()

M8B\EtherBinder\RPC\Modules\Eth::ethGetUncleByBlockHashAndIndex ( Hash $hash,
int $unclePos )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderLogicException

◆ ethGetUncleByBlockNumberAndIndex()

M8B\EtherBinder\RPC\Modules\Eth::ethGetUncleByBlockNumberAndIndex ( int|BlockParam $blockParam,
int $unclePos )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderLogicException

◆ ethGetUncleCountByBlockHash()

M8B\EtherBinder\RPC\Modules\Eth::ethGetUncleCountByBlockHash ( Hash|Block $block)
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ ethGetUncleCountByBlockNumber()

M8B\EtherBinder\RPC\Modules\Eth::ethGetUncleCountByBlockNumber ( int|BlockParam $blockParam = BlockParam::LATEST)
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderRuntimeException

◆ ethHashrate()

M8B\EtherBinder\RPC\Modules\Eth::ethHashrate ( )
inherited
Exceptions
RPCNotFoundException
RPCInvalidResponseParamException
RPCGeneralException

◆ ethMaxPriorityFeePerGas()

M8B\EtherBinder\RPC\Modules\Eth::ethMaxPriorityFeePerGas ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethMining()

M8B\EtherBinder\RPC\Modules\Eth::ethMining ( )
inherited
Exceptions
RPCNotFoundException
RPCInvalidResponseParamException
RPCGeneralException

◆ ethNewFilter()

M8B\EtherBinder\RPC\Modules\Eth::ethNewFilter ( Address|array $address,
null|int|BlockParam $fromBlock,
null|int|BlockParam $toBlock,
string|bool|HashSerializable|array $topic0,
null|string|bool|HashSerializable|array $topic1 = null,
null|string|bool|HashSerializable|array $topic2 = null,
null|string|bool|HashSerializable|array $topic3 = null )
inherited

Installs event filterer on rpc node and returns ID of the filter. Accepts few types, but bear in mind that string type is always considered to be binary blob.

Parameters
int | BlockParam | null$fromBlock
int | BlockParam | null$toBlock
Address | Address[]$address
string | bool | HashSerializable | string[] | bool[] | HashSerializable[]$topic0
null | string | bool | HashSerializable | string[] | bool[] | HashSerializable[]$topic1
null | string | bool | HashSerializable | string[] | bool[] | HashSerializable[]$topic2
null | string | bool | HashSerializable | string[] | bool[] | HashSerializable[]$topic3
Returns
OOGmp
Exceptions
EthBinderArgumentException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException
EthBinderLogicException

◆ ethProtocolVersion()

M8B\EtherBinder\RPC\Modules\Eth::ethProtocolVersion ( )
inherited
Exceptions
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ ethSendRawTransaction()

M8B\EtherBinder\RPC\Modules\Eth::ethSendRawTransaction ( Transaction $signedTransaction)
inherited
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException
UnexpectedUnsignedException
EthBinderArgumentException

◆ ethSendRawTransactionHex()

M8B\EtherBinder\RPC\Modules\Eth::ethSendRawTransactionHex ( string $rawTransactionHex)
inherited
Parameters
string$rawTransactionHex
Returns
Hash
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ ethSendTransaction()

M8B\EtherBinder\RPC\Modules\Eth::ethSendTransaction ( Transaction $txn,
Address $from )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
RPCInvalidResponseParamException

◆ ethSign()

M8B\EtherBinder\RPC\Modules\Eth::ethSign ( Address $address,
string $dataHex )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ ethSignTransaction()

M8B\EtherBinder\RPC\Modules\Eth::ethSignTransaction ( Transaction $txn,
Address $from )
inherited
Exceptions
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ ethSyncing()

M8B\EtherBinder\RPC\Modules\Eth::ethSyncing ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ isLookingLikeLondon()

M8B\EtherBinder\RPC\Compound::isLookingLikeLondon ( )
inherited

Checks whether the network seems to be like London (EIP-1559) by checking block data fields that are EIP1559 specific

Returns
bool true if network seems to be post-London fork, false otherwise
Exceptions
EthBinderLogicException
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ netListening()

M8B\EtherBinder\RPC\Modules\Net::netListening ( )
inherited
Exceptions
RPCNotFoundException
RPCInvalidResponseParamException
RPCGeneralException

◆ netPeerCount()

M8B\EtherBinder\RPC\Modules\Net::netPeerCount ( )
inherited
Exceptions
RPCNotFoundException
RPCInvalidResponseParamException
RPCGeneralException
EthBinderRuntimeException

◆ netVersion()

M8B\EtherBinder\RPC\Modules\Net::netVersion ( )
inherited
Exceptions
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException

◆ parseFilterInput()

M8B\EtherBinder\RPC\Modules\Eth::parseFilterInput ( Address|array $address,
null|int|BlockParam $fromBlock,
null|int|BlockParam $toBlock,
null|Hash $blockHash,
string|bool|HashSerializable|array $topic0,
null|string|bool|HashSerializable|array $topic1 = null,
null|string|bool|HashSerializable|array $topic2 = null,
null|string|bool|HashSerializable|array $topic3 = null )
protectedinherited
Exceptions
EthBinderLogicException
EthBinderArgumentException
Exceptions
EthBinderArgumentException

◆ raw()

M8B\EtherBinder\RPC\HttpRPC::raw ( string $method,
?array $params = null )

@inheritDoc

Exceptions
RPCGeneralExceptionif the request fails or response is invalid.

Reimplemented from M8B\EtherBinder\RPC\AbstractRPC.

◆ runRpc()

M8B\EtherBinder\RPC\AbstractRPC::runRpc ( string $method,
?array $params = null )
inherited

Sends an RPC request and returns only the 'result' data.

Parameters
string$methodthe RPC method to call
array | null$paramsoptional parameters for the method
Returns
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 from M8B\EtherBinder\RPC\Modules\AbstractModule.

◆ web3ClientVersion()

M8B\EtherBinder\RPC\Modules\Web3::web3ClientVersion ( )
inherited
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException

◆ web3Sha3Keccak()

M8B\EtherBinder\RPC\Modules\Web3::web3Sha3Keccak ( string $inputHex)
inherited
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ web3Sha3KeccakBin()

M8B\EtherBinder\RPC\Modules\Web3::web3Sha3KeccakBin ( string $inputBin)
inherited
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

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