Skip to content

API Reference ​

Facades Overview ​

FacadeUnderlying ContractPurpose
EvmContractClientRead & write contract functions
EvmRpcRpcClientRaw JSON-RPC calls & health snapshot
EvmSignerSignerSigning address and transaction signing
EvmNonceNonceManagerTrack last used nonce locally
EvmFeesFeePolicySuggest & bump EIP-1559 fees
EvmLogsLogFilterBuilderQuery & filter event logs

ContractClient (via Evm) ​

MethodArgsReturnsNotes
at(address, abi)string, array| stringselfSet target contract & ABI JSON/array
call(fn, args=[])string, arrayCallResult| mixedeth_call; hex wrapped for decoding
sendAsync(fn, args=[], opts=[], payload=null)string, array, array, mixedstringDispatch async job; returns request UUID; payload flows through events
at() returns a new handle--It does not mutate the client it was called on
wait(txHash, timeoutSec=120, pollMs=800)string, int, intarray| nullPoll receipt until mined/timeout
estimateGas(data, from?)string, ?stringintUses eth_estimateGas + padding

CallResult ​

MethodReturnsDescription
raw()stringOriginal 0x hex
as(type)mixedDecode basic ABI types (string, bytes, uintN, intN, bool, address). Integers are returned as decimal strings
__toString()stringRaw hex when cast to string

RpcClient (via EvmRpc) ​

MethodArgsReturnsNotes
call(method, params=[])string, arraymixedGeneric JSON-RPC request
health()-['chainId'=>int,'block'=>int]Convenience status snapshot

Signer (via EvmSigner) ​

MethodReturnsNotes
getAddress()stringPublic address derived from the key
sign(fields)stringRaw 0x payload for eth_sendRawTransaction

The key never leaves the signer; there is no accessor for it.


NonceManager (via EvmNonce) ​

MethodArgsReturnsNotes
getPendingNonce(address, fetcher)string, callableintCached; fetcher is called only on a cache miss
markUsed(address, nonce)string, intvoidAdvances the cache after a successful broadcast
invalidate(address)stringvoidDrops the cache so the next read hits the chain

FeePolicy (via EvmFees) ​

MethodArgsReturnsNotes
suggest(FeeSnapshot $snapshot)FeeSnapshot[priorityWei, maxFeeWei]Initial fee suggestion
replace(int $oldPriority, int $oldMax)int $oldPriority, int $oldMax[priorityWei, maxFeeWei]Replacement bump

LogFilterBuilder (via EvmLogs) ​

Start with EvmLogs::query() then chain:

MethodArgsReturnsPurpose
fromBlock(block)int| stringselfSet starting block or 'latest'
toBlock(block)int| stringselfSet end block or 'latest'
address(addrOrArray)string| arrayselfFilter by one or many contract addresses
event(signature)stringselfSet topic0 = keccak256(signature)
eventByAbi(abiJson, name)array| string, stringselfResolve signature from ABI by event name
topic(index, value)int, stringselfExact match indexed topic
topicAny(index, values)int, arrayselfOR match on multiple values
topicWildcard(index)intselfUnset filter for that indexed slot
blockHash(hash)stringselfFilter a single block instead of a range
get()-arrayFetch raw logs array
chunked(maxChunk=null)?intarraySplit a wide range into several requests

Helpers: ​

HelperArgsReturnsDescription
padAddress(address)stringstringLeft-pad address to 32-byte topic value
decodeEvent(abiJson, log)array|string, arrayarrayDecode indexed + non-indexed params

Encoding Helpers ​

ClassMethodReturnsUse Case
EncodingstringToBytes32(str)stringConvert UTF-8 string to bytes32 padded hex
Encodingbytes32ToString(hex)stringThe inverse
EncodingtoChecksumAddress(addr)stringApply the EIP-55 checksum
ReceiptisSuccessful(receipt)boolMined and did not revert
ReceiptisReverted(receipt)boolMined but reverted

Events ​

EventWhenKey Data (excerpt)
TxQueuedJob pushedto, data, payload
TxBroadcastedFirst broadcast oktxHash, fields, payload
TxReplacedFee bump broadcastoldTxHash, newFields, attempt, payload
TxMinedReceipt found, status 0x1txHash, receipt, payload
TxRevertedReceipt found, status 0x0txHash, receipt, payload
TxFailedTerminal failureto, data, reason, payload
CallPerformedRead executedfrom, address, function, rawResult

Configuration Highlights (config/evm.php) ​

SectionKeyPurpose
rpc.timeoutintSeconds per RPC request
rpc.connect_timeoutintSeconds to establish a connection
rpc.triesintTransport retries per endpoint
logs.max_chunkintBlocks per eth_getLogs chunk
tracking.enabledboolPersist the transaction lifecycle
rpc_urlslistFailover endpoints
chain_idintNetwork id (EIP-155)
signer.private_keyhexSigning key
tx.estimate_paddingfloatGas safety multiplier
tx.confirm_timeoutintSeconds before considering replacement
tx.max_replacementsintFee bump attempts limit
tx.poll_interval_msintReceipt poll interval
tx.queuestringQueue name for sendAsync jobs

Worker Recommendation ​

Run one worker per signing key:

bash
php artisan queue:work --queue=evm-send --sleep=0

Maintains nonce ordering; for scaling use a distributed nonce manager.


Error Classes ​

ClassTriggerTypical Cause
RpcExceptionbase class for the two below-
RpcTransportExceptionno endpoint could be reachedNetwork / provider outage
RpcErrorExceptionthe node returned a JSON-RPC errorRevert, insufficient funds, bad nonce
SignerExceptionSigning issueBad key format
RequirementExceptionMissing runtime prerequisiteext-gmp not enabled

RpcErrorException carries the original rpcCode and rpcData and offers isRevert(), so a contract revert can be told apart from an outage.


Security Notes ​

  • Never log private keys. The signer holds the key and does not expose it.
  • RPC endpoint credentials are redacted in logs and in health().
  • Transactions per signing address are serialised by a cache lock.
  • Use multiple RPC endpoints for resilience.
  • Attach domain payloads to events for traceability.

Released under the MIT License.