Transactions
Transactions in GenLayer are the fundamental operations that change network state, including deploying a new contract, sending value between accounts, or invoking a function within an existing contract. A transaction records the call data, sender and recipient addresses, gas limit, nonce, status, consensus data, and execution receipts used by the protocol to process and finalize the operation.
Here is the general structure of a transaction:
{
"consensus_data": {
"leader_receipt": {
"args": [
[
2,
"0x793Ae2CfF17462cc9f9D68e194b7b949d2080Ea2"
]
],
"class_name": "LlmErc20",
"contract_state": "gASVnAAAAAAAAACMF2JhY2tlbmQubm9kZS5nZW52bS5iYXNllIwITGxtRXJjMjCUk5QpgZR9lIwIYmFsYW5jZXOUfZQojCoweEQyNzFjNzRBNzgwODNGMzU3YTlmOGQzMWQ1YWRDNTlCMzk1Y2YxNmKUS2KMKjB4NzkzQWUyQ2ZGMTc0NjJjYzlmOUQ2OGUxOTRiN2I5NDlkMjA4MEVhMpRLAnVzYi4=",
"eq_outputs": {
"leader": {
"0": "{\"transaction_success\": true, \"transaction_error\": \"\", \"updated_balances\": {\"0xD271c74A78083F357a9f8d31d5adC59B395cf16b\": 98, \"0x793Ae2CfF17462cc9f9D68e194b7b949d2080Ea2\": 2}}"
}
},
"error": null,
"execution_result": "SUCCESS",
"gas_used": 0,
"method": "transfer",
"mode": "leader",
"node_config": {
"address": "0x185D2108D9dE15ccf6beEb31774CA96a4f19E62B",
"config": {},
"model": "gpt-4o",
"plugin": "openai",
"plugin_config": {
"api_key_env_var": "OPENAIKEY",
"api_url": null
},
"provider": "openai",
"stake": 1
},
"vote": "agree"
},
"validators": [
{
"args": [
[
2,
"0x793Ae2CfF17462cc9f9D68e194b7b949d2080Ea2"
]
],
"class_name": "LlmErc20",
"contract_state": "gASVnAAAAAAAAACMF2JhY2tlbmQubm9kZS5nZW52bS5iYXNllIwITGxtRXJjMjCUk5QpgZR9lIwIYmFsYW5jZXOUfZQojCoweEQyNzFjNzRBNzgwODNGMzU3YTlmOGQzMWQ1YWRDNTlCMzk1Y2YxNmKUS2KMKjB4NzkzQWUyQ2ZGMTc0NjJjYzlmOUQ2OGUxOTRiN2I5NDlkMjA4MEVhMpRLAnVzYi4=",
"eq_outputs": {
"leader": {
"0": "{\"transaction_success\": true, \"transaction_error\": \"\", \"updated_balances\": {\"0xD271c74A78083F357a9f8d31d5adC59B395cf16b\": 98, \"0x793Ae2CfF17462cc9f9D68e194b7b949d2080Ea2\": 2}}"
}
},
"error": null,
"execution_result": "SUCCESS",
"gas_used": 0,
"method": "transfer",
"mode": "validator",
"node_config": {
"address": "0x31bc9380eCbF487EF5919eBa7457F457B5196FCD",
"config": {},
"model": "gpt-4o",
"plugin": "openai",
"plugin_config": {
"api_key_env_var": "OPENAIKEY",
"api_url": null
},
"provider": "openai",
"stake": 1
},
"pending_transactions": [],
"vote": "agree"
},
...
],
"votes": {
"0x185D2108D9dE15ccf6beEb31774CA96a4f19E62B": "agree",
"0x2F04Fb1e5daf7DCbf170E4CB0e427d9b11aB96cA": "agree",
"0x31bc9380eCbF487EF5919eBa7457F457B5196FCD": "agree"
}
},
"created_at": "2024-10-02T20:32:50.469443+00:00",
"data": {
"function_args": "[2,\"0x793Ae2CfF17462cc9f9D68e194b7b949d2080Ea2\"]",
"function_name": "transfer"
},
"from_address": "0xD271c74A78083F357a9f8d31d5adC59B395cf16b",
"gaslimit": 66,
"hash": "0xb7486f70a3fec00af5f929fc1cf1078af9ff3a063afe8b6f370a44a96635505d",
"leader_only": false,
"nonce": 66,
"r": null,
"s": null,
"status": "FINALIZED",
"to_address": "0x5929bB548a2Fd7E9Ea2577DaC9c67A08BbC2F356",
"type": 2,
"v": null,
"value": 0
}Explanation of fields:
- consensus_data: Object containing information about the consensus process
- leader_receipt: Object containing details about the leader's execution of the transaction
- args: Arguments passed to the contract function
- class_name: Name of the contract class
- contract_state: Encoded state of the contract
- eq_outputs: Outputs from every equivalence principle in the execution of the contract method
- error: Any error that occurred during execution (null if no error)
- execution_result: Result of the execution (e.g., "SUCCESS" or "ERROR")
- gas_used: Amount of gas used in the transaction
- method: Name of the method called on the contract
- mode: Execution mode (e.g., "leader" or "validator")
- node_config: Configuration of the node executing the transaction
- address: Address of the node
- config: Configuration of the node
- model: Model of the node
- plugin: Plugin used for the LLM provider connection
- plugin_config: Configuration of the plugin
- api_key_env_var: Environment variable containing the API key for the given provider
- api_url: API URL for the given provider
- provider: Provider of the node
- stake: Stake of the validator
- vote: The leader's vote on the transaction (e.g., "agree")
- validators: Array of objects containing similar information for each validator
- votes: Object mapping validator addresses to their votes
- leader_receipt: Object containing details about the leader's execution of the transaction
- created_at: Timestamp of when the transaction was created
- data: Object containing details about the function call in the transaction
- from_address: Address of the account initiating the transaction
- gaslimit: Maximum amount of gas the transaction is allowed to consume
- hash: Unique identifier (hash) of the transaction
- leader_only: Boolean indicating whether the transaction is to be executed by the leader node only
- nonce: Number of transactions sent from the from_address (used to prevent double-spending)
- r: Part of the transaction signature (null if not yet signed)
- s: Part of the transaction signature (null if not yet signed)
- status: Current status of the transaction (e.g., "FINALIZED")
- to_address: Address of the contract or account receiving the transaction
- type: Internal type of the transaction (2 indicates a contract write call)
- v: Part of the transaction signature (null if not yet signed)
- value: Amount of native currency (GEN) being transferred in the transaction