APIs

The OLA JSON RPC API provides interfaces for interacting with the OLA Virtual Machine, enabling functionalities such as sending transactions, querying transaction details, and invoking contract functions. Below is the list of currently supported APIs along with their usage instructions.

API Overview

1. ola_sendRawTransaction

  • Description: Sends a signed and serialized transaction to the OLA network.

  • Parameters:

    • tx_bytes: The signed and serialized transaction data in hexadecimal string format.

  • curl example :

    curl -X POST -H "Content-Type: application/json" \
    --data '{"jsonrpc": "2.0", "id": 1, "method": "ola_sendRawTransaction", "params": {"tx_bytes": "0x10f9012080a0fa2103eabd0c306b170167987382f676"}}' \
    "https://pre-alpha-api.olavm.com"
  • Output:

    {
        "jsonrpc": "2.0",
        "result": "0xc2da317c4455f31718437cd9839057a516f7cc4d2628331a683d6c487d1e0049",
        "id": 1
    }

2. ola_getTransactionDetails

  • Description: Queries the execution details of a specified transaction.

  • Parameters:

    • hash: The hash of the transaction in hexadecimal string format.

  • curl example:

    curl -X POST -H "Content-Type: application/json" \
    --data '{"jsonrpc": "2.0", "id": 1, "method": "ola_getTransactionDetails", "params": {"hash": "0x7d3d924f4f86655fc223072b56f524b0e0229fc24095596638a72dd93306109f"}}' \
    "https://pre-alpha-api.olavm.com"
  • Output:

    {
        "jsonrpc": "2.0",
        "result": {
            "isL1Originated": false,
            "status": "included",
            "fee": "0x0",
            "gasPerPubdata": null,
            "initiatorAddress": "0x129cfee7b5e7592f3818bd7c29f1417ecbe690a11e37e8719d9d19cf30ec8522",
            "receivedAt": "2024-02-06T09:31:09.225Z",
            "ethCommitTxHash": null,
            "ethProveTxHash": null,
            "ethExecuteTxHash": null
        },
        "id": 1
    }

3. ola_callTransaction

  • Description: Queries data, typically used for invoking read-only functions of a smart contract.

  • Parameters:

    • call_request: An object containing the call information, with fields as follows:

      • from: The address of the caller in hexadecimal string format.

      • to: The contract address in hexadecimal string format.

      • data: The call data in hexadecimal string format.

  • curl example:

    curl -X POST -H "Content-Type: application/json" \
    --data '{"jsonrpc": "2.0", "id": 1, "method": "ola_callTransaction", "params": { "call_request": {"from": "0x9a60aad93b2eb07764466df455544a2bd01ca91fe4abf5d5eabd28ad97cd9a7c", "to": "0xd547d6f18c104bc99f5efc9bfd3fff8c7b4a7dbe7c0858322a2430a0e6dd89f1", "data": "0x000000000000000000000000609ff1bd"}}}' \
    "https://pre-alpha-api.olavm.com"
  • Output:

    {
        "jsonrpc": "2.0",
        "result": "0x00000000000000010000000000000001",
        "id": 1
    }

General Information

  • Request Method: POST

  • Content-Type: application/json

  • Protocol Version: JSON RPC 2.0

  • RPC Endpoint: https://pre-alpha-api.olavm.com is the RPC address to which API calls should be sent.

When utilizing these APIs, ensure that you have the necessary permissions and that the parameters are formatted correctly. For all requests, it is crucial to check the returned data to verify the results of the operation.

Last updated