SettleMint
ArchitectureComponentsInfrastructure

Contract Runtime

The Contract Runtime provides a secure abstraction for smart contract interactions, managing ABI encoding, call execution, and state queries with automatic retry and error classification.

Overview

The Contract Runtime translates high-level operations into smart contract calls. This component handles ABI encoding, call construction, and result decoding while abstracting blockchain interaction complexity.

Smart contracts present binary interfaces that require precise encoding. Method selectors, parameter encoding, and result parsing demand careful implementation. The Contract Runtime centralizes this complexity, providing typed interfaces for application code.

Interaction patterns

Rendering diagram...

ABI management

The Contract Runtime maintains an ABI registry for all deployed contracts. Contract deployment automatically registers ABIs. Version management tracks ABI changes across contract upgrades.

ABI sourceRegistration timingUpdate mechanism
Platform contractsBuild timeDeployment pipeline
User contractsDeployment timeAutomatic extraction
External contractsConfiguration timeManual registration

Operation types

Read operations

View and pure functions execute without transaction submission. Read calls route to Chain Gateway replica nodes for performance. Results decode through ABI definitions with type validation.

Write operations

State-modifying functions require transaction submission through the Transaction Signer. The runtime constructs complete transaction objects including:

  • Target contract address
  • Encoded function call data
  • Gas limit estimation
  • Value transfer (if applicable)

Multicall batching

Multiple read operations batch into single RPC calls when targeting compatible contracts. Batching reduces network round trips and improves response latency for complex queries.

Error classification

Contract calls can fail in multiple ways. The runtime classifies errors to enable appropriate handling:

Error typeCauseHandling
RevertContract logic rejectionSurface to workflow
Out of gasInsufficient gas limitRetry with higher limit
Nonce collisionConcurrent transaction conflictResubmit with correct nonce
Contract not foundInvalid addressConfiguration error
Invalid parametersABI encoding mismatchDeveloper error

Gas optimization

The Contract Runtime implements gas optimization strategies:

Efficient encoding: Parameter encoding uses gas-optimal patterns where alternatives exist.

Calldata compression: Large parameters compress when contract supports decompression.

Access list generation: EIP-2930 access lists pre-warm storage for gas reduction.

Simulation validation: Complex transactions simulate before submission to catch failures before gas expenditure.

Event decoding

Contract events decode through registered ABIs. The Chain Indexer uses Contract Runtime decoding for event processing. Event parameters extract with full type information for domain model construction.

Upgrade handling

Contract upgrades require ABI registry updates. The runtime supports:

Proxy patterns: Transparent and UUPS proxies route through consistent addresses while ABIs update.

Version tracking: Multiple ABI versions coexist for historical data decoding.

Migration support: Upgrade workflows coordinate ABI updates with contract deployment.

Security considerations

The Contract Runtime enforces security boundaries:

  • Only approved contract addresses accept calls
  • Parameter validation prevents injection attacks
  • Value transfers require explicit authorization
  • Administrative functions restrict to authorized roles

See also

On this page