loadContractCodeForContractId

Loads the contract code entry (including WASM bytecode) for a given contract ID.

This method:

  1. Fetches the contract instance to determine the WASM hash from its executable: a WASM executable carries the hash directly, and a CAP-85 external reference is resolved through the owner contract's tag entry via getExternalRefWasmHash. A Stellar Asset Contract has no WASM on-chain, so it yields null.

  2. Fetches the contract code using the WASM hash

Example

val contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"
val codeEntry = server.loadContractCodeForContractId(contractId)
codeEntry?.let {
println("Contract code size: ${it.code.dataValue.size} bytes")
}

Return

The contract code entry, or null when the instance or its code entry is not found, or when the contract is a Stellar Asset Contract

Parameters

contractId

The contract address (C... format)

See also

Throws

If the RPC request fails

If contractId is not a valid contract address, or if the instance carries an external reference whose owner is not a contract address

If an external reference cannot be resolved: the tag entry is missing, is not a contract data entry, or does not hold a 32-byte hash