Contract Methods
Methods for deploying, reading, writing, and simulating GenLayer intelligent contracts.
getContractCode
Retrieves the source code of a deployed contract. Studio only.
| Parameter | Type | Required | Description |
|---|---|---|---|
| address | Address | yes |
Returns: string
getContractSchema
Gets the schema (methods and constructor) of a deployed contract. Studio only.
| Parameter | Type | Required | Description |
|---|---|---|---|
| address | Address | yes |
Returns: ContractSchema
getContractSchemaForCode
Generates a schema for contract code without deploying it. Studio only.
| Parameter | Type | Required | Description |
|---|---|---|---|
| contractCode | string | Uint8Array | yes |
Returns: ContractSchema
readContract
Executes a read-only contract call without modifying state.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| address | Address | yes | |
| functionName | string | yes | |
| args | CalldataEncodable[] | no | |
| kwargs | Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable} | no | |
| rawReturn | RawReturn | no | |
| jsonSafeReturn | boolean | no | |
| leaderOnly | boolean | no | |
| transactionHashVariant | TransactionHashVariant | no |
Returns: RawReturn extends true ? 0x${string} : CalldataEncodable
simulateWriteContract
Simulates a state-modifying contract call without executing on-chain.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| address | Address | yes | |
| functionName | string | yes | |
| args | CalldataEncodable[] | no | |
| kwargs | Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable} | no | |
| rawReturn | RawReturn | no | |
| leaderOnly | boolean | no | |
| transactionHashVariant | TransactionHashVariant | no |
Returns: RawReturn extends true ? 0x${string} : CalldataEncodable
writeContract
Executes a state-modifying function on a contract through consensus. Returns the transaction hash.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| address | Address | yes | |
| functionName | string | yes | |
| args | CalldataEncodable[] | no | |
| kwargs | Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable} | no | |
| value | bigint | yes | |
| leaderOnly | boolean | no | |
| consensusMaxRotations | number | no |
Returns: 0x${string}
deployContract
Deploys a new intelligent contract to GenLayer. Returns the transaction hash.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| code | string | Uint8Array | yes | |
| args | CalldataEncodable[] | no | |
| kwargs | Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable} | no | |
| leaderOnly | boolean | no | |
| consensusMaxRotations | number | no |
getMinAppealBond
Calculates the minimum bond required to appeal a transaction.
| Parameter | Type | Required | Description |
|---|---|---|---|
| txId | 0x${string} | yes |
Returns: bigint
getRoundNumber
Returns the current consensus round number for a transaction.
| Parameter | Type | Required | Description |
|---|---|---|---|
| txId | 0x${string} | yes |
Returns: bigint
getRoundData
Returns detailed data for a specific consensus round.
| Parameter | Type | Required | Description |
|---|---|---|---|
| txId | 0x${string} | yes | |
| round | bigint | yes |
getLastRoundData
Returns the current round number and its data for a transaction.
| Parameter | Type | Required | Description |
|---|---|---|---|
| txId | 0x${string} | yes |
canAppeal
Checks if a transaction can be appealed.
| Parameter | Type | Required | Description |
|---|---|---|---|
| txId | 0x${string} | yes |
Returns: boolean
appealTransaction
Appeals a consensus transaction to trigger a new round of validation.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| txId | 0x${string} | yes | |
| value | bigint | no |
finalizeTransaction
Finalizes a single GenLayer transaction that is ready to be finalized. Returns the EVM transaction hash.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| txId | 0x${string} | yes |
Returns: 0x${string}
finalizeIdlenessTxs
Batch-finalizes idle GenLayer transactions (those stuck without progressing). Returns the EVM transaction hash.
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Account | no | |
| txIds | readonly 0x${string}[] | yes |
Returns: 0x${string}