Resources

data class Resources(val cpuInstructions: Long, val diskReadBytes: Long, val writeBytes: Long)

Resource consumption metrics for Soroban transactions.

These metrics define the maximum resources a transaction can consume during execution. They are used to:

  • Calculate resource fees

  • Ensure network capacity limits aren't exceeded

  • Provide execution guarantees

Obtaining Resource Values

Always use simulation results when possible:

val simulation = server.simulateTransaction(tx)
// Extract from simulation's transactionData

Manual construction (testing only):

val resources = SorobanDataBuilder.Resources(
cpuInstructions = 1000000,
diskReadBytes = 5000,
writeBytes = 2000
)

Resource Limits

Each resource has network-level limits:

  • CPU Instructions: ~100M per transaction (varies by network)

  • Disk Read: ~200KB per transaction

  • Write: ~100KB per transaction

Exceeding these limits causes transaction failure.

See also

Constructors

Link copied to clipboard
constructor(cpuInstructions: Long, diskReadBytes: Long, writeBytes: Long)

Properties

Link copied to clipboard

Number of CPU instructions the contract execution can consume.

Link copied to clipboard

Number of bytes read from ledger entries.

Link copied to clipboard

Number of bytes written to ledger and memory.