Ontology Developer Center
DISCOVERCOMMUNITYSUPPORT
  • Introduction
  • Discover Ontology
  • Getting Started
  • Glossary
  • Decentralized Identity and Data
    • ONT ID
      • Decentralized Identifiers
        • Method Specification for Ontology
        • Method Specification for Ethereum
        • Method Specification for BSC
      • Verifiable Credentials
        • Anonymous Credentials
      • ONT Login
        • Scenarios
        • Protocol Specification
        • Front-end JavaScript SDK
          • Integration and Usage
          • API Reference
        • Front-end UI SDK
          • Integration and Usage
          • API Reference
        • Back-end Go SDK
          • Integration and Usage
          • API Reference
        • Back-end Java SDK
          • Integration and Usage
          • API Reference
      • ONT TAG
        • Workflow
        • API Reference
      • Mercury
      • OScore
    • DDXF
      • Components and Interfaces
      • GREP
      • Overall Scheme
      • Solutions
        • Marketplace
          • Deployment
          • Scenarios
          • SaaS Tenant
          • Java SDK
        • Data Storage
          • Deployment
          • Java SDK
        • Resource Auditor
        • Offline Judge
      • Use Cases
        • E-Shops
  • ONTOLOGY ELEMENTS
    • Smart Contracts
      • Types of smart contracts
    • Token Protocols
    • Consensus Mechanism
    • Ontology Oracle
      • Oracle Process Flow
  • GUIDES & TUTORIALS
    • Development Guides
      • dApp Development
        • Using the dAPI
        • Data Synchronization
      • Smart Contract Development
        • EVM Contract
          • Development Environment and Tools
          • Wallet Setup
          • Contract Development
          • How to Deploy a Smart Contract with GetBlock
        • NeoVM Contract
          • Development tools and environment
          • Launching the IDE
          • Writing and editing program logic
          • Deploying and testing on private net
        • WASM Contract
          • Development Environment
          • Project Initiation - Hello World
          • Creating your own project
          • Development using SmartX
          • Runtime API
          • Contract Fundamentals
          • Inter-contract Interaction
          • Developing Contracts in C++
        • Publish Contract Source Code
    • Integration Guides
      • dApp Integration
        • dAPI Integration
          • Chrome Plugin
          • Mobile wallet dApp
          • QR code mechanism
          • Wake call mechanism
        • Cocos 2D-x
        • Unity 3D applications
      • Mobile Wallet Integration
        • SDK integration
        • dAPI Integration
          • In-wallet applications
          • QR code mechanism
          • Wake call mechanism
        • Stake
      • Using ONT ID
      • Exchange Integration
        • Exchange Docking Guide
        • Exchange API
      • Ontology for dApp Stores
    • EVM & Token Decimals Upgrade
  • ONTOLOGY NODE
    • Abstract
    • Node Deployment
      • Standard Node
      • Rosetta Node
    • Interacting with a Public Node
  • DEVELOPER TOOLS
    • dApp Development Framework
      • Punica CLI
      • Punica boxes
      • Solo Chain
    • IDE
    • APIs
      • HTTP API
        • Restful
        • WebSocket
        • Remote Procedure Call (RPC)
      • Explorer v2 API
        • Block
        • Address
        • Contract
        • Token
        • Transactions
        • ONT ID
        • Summary
        • Node
      • Native Token API
        • ONT Contract API
        • ONG Contract API
      • ONT ID Contract API
      • Web3 API
      • OScore Open API
      • Rosetta Node API
        • Data API
        • Construction API
      • DToken Contract API
      • DDXF
        • Marketplace Contract API
        • Storage API
      • Governance API
    • Digital Wallet
      • Chrome Plugin provider
      • Chrome Plugin dAPI
      • Mobile version provider
      • Mobile version dAPI
    • SDKs
    • Signing Server
      • Installation
      • API reference
  • COMMUNITY
    • Ecosystem Programs
    • Community Libraries
    • Community Events
    • Community Channels
    • Core Contributors
  • SUPPORT
    • FAQ
      • Basic blockchain concepts
      • Ontology Nodes
      • Ontology token protocols
      • Smart contracts
      • SDKs and APIs
    • Contact Us
Powered by GitBook
On this page
  • Network
  • Fetch the list of available networks
  • Fetch network options
  • Fetch the network status
  • Account
  • Fetch account balance
  • Block
  • Fetch block details
  • Fetch transaction information from a block
  • Mempool
  • Fetch all mempool transactions
  • Fetch details for a mempool transaction

Was this helpful?

  1. DEVELOPER TOOLS
  2. APIs
  3. Rosetta Node API

Data API

Fetch block and transaction related data

The data API methods can be used to fetch block, transaction, and other related data from the chain. The available methods have been classified based on the endpoints and listed below.

Network

Fetch the list of available networks

Method: POST

URL: /network/list

Sample Request:

{
  "metadata": {}
}

Sample Response:

{
  "network_identifiers": [
    {
      "blockchain": "ont",
      "network": "mainnet"
    }
  ]
}

Fetch network options

Method: POST

URL: /network/options

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  }
}

Sample Response:

{
  "version": {
        "rosetta_version": "1.4.0",
        "node_version": "1.11.0"
  },
  "allow": {
    "operation_statuses": [
      {
        "status": "SUCCESS",
        "successful": true
      },
      {
        "status": "FAILED",
        "successful": false
      }
    ],
    "operation_types": ["transfer"],
    "errors": [
      {
        "code": 400,
        "message": "network identifier is not supported",
        "retriable": false
      },
      {
        "code": 401,
        "message": "block identifier is empty",
        "retriable": false
      },
      {
        "code": 402,
        "message": "block index is invalid",
        "retriable": false
      },
      {
        "code": 403,
        "message": "get block failed",
        "retriable": true
      },
      {
        "code": 404,
        "message": "block hash is invalid",
        "retriable": false
      },
      {
        "code": 405,
        "message": "get transaction failed",
        "retriable": true
      },
      {
        "code": 406,
        "message": "transaction hash is invalid",
        "retriable": false
      },
      {
        "code": 407,
        "message": "commit transaction failed",
        "retriable": false
      },
      {
        "code": 408,
        "message": "tx hash is invalid",
        "retriable": false
      },
      {
        "code": 409,
        "message": "block is not exist",
        "retriable": false
      },
      {
        "code": 500,
        "message": "service not realize",
        "retriable": false
      },
      {
        "code": 501,
        "message": "addr is invalid",
        "retriable": true
      },
      {
        "code": 502,
        "message": "get balance error",
        "retriable": true
      },
      {
        "code": 503,
        "message": "parse int error",
        "retriable": true
      },
      {
        "code": 504,
        "message": "json marshal failed",
        "retriable": false
      },
      {
        "code": 505,
        "message": "parse tx payload failed",
        "retriable": false
      },
      {
        "code": 506,
        "message": "currency not config",
        "retriable": false
      },
      {
        "code": 507,
        "message": "params error",
        "retriable": true
      },
      {
        "code": 508,
        "message": "contract addr invalid",
        "retriable": true
      },
      {
        "code": 509,
        "message": "preExecute contract failed",
        "retriable": false
      },
      {
        "code": 510,
        "message": "query balance failed",
        "retriable": true
      }
    ]
  }
}

Fetch the network status

Method: POST

URL: /network/status

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  }
}

Sample Response:

{
  "current_block_identifier": {
    "index": 4789126,
    "hash": "76fcf0fbd5e979721fe52e472ac79eb26f4bc502c371508574c0e03386be20e6"
  },
  "current_block_timestamp": 1560312815000,
  "genesis_block_identifier": {
    "index": 0,
    "hash": "1b8fa7f242d0eeb4395f89cbb59e4c29634047e33245c4914306e78a88e14ce5"
  },
  "peers": [
    {
      "peer_id": "000000000000000000000000b41fe9ceaaaa4d7b",
      "metadata": {
        "address": "40.113.237.243:20338",
        "height": 8454242
      }
    },
    {
      "peer_id": "000000000000000000000000a4f0c524d8efd6a8",
      "metadata": {
        "address": "139.219.141.104:20338",
        "height": 8454242
      }
    },
    {
      "peer_id": "0000000000000000000000008e6528f4659f3112",
      "metadata": {
        "address": "50.18.219.74:20338",
        "height": 8454242
      }
    }
  ]
}

Account

Fetch account balance

Method: POST

URL: /account/balance

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "account_identifier": {
    "address": "AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
    "metadata": {}
  },
  "block_identifier": {
    "index": 310
  }
}

Sample Response:

{
  "block_identifier": {
    "index": 310,
    "hash": "11405500403779cff364803bbd7fe4dc74ba9119015fd79473c188b727769c52"
  },
  "balances": [
    {
      "value": "14700000000000000",
      "currency": {
        "symbol": "ONT",
        "decimals": 9,
        "metadata": {
          "ContractAddress": "0100000000000000000000000000000000000000",
          "TokenType": "Governance Token"
        }
      }
    },
    {
      "value": "1750000140000000000000",
      "currency": {
        "symbol": "ONG",
        "decimals": 18,
        "metadata": {
          "ContractAddress": "0200000000000000000000000000000000000000",
          "TokenType": "Utility Token"
        }
      }
    }
  ]
}

Block

Fetch block details

Method: POST

URL: /block

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "block_identifier": {
    "index": 54
  }
}
{
  "block": {
    "block_identifier": {
      "index": 54,
      "hash": "790ea8942e5722c75ba638312caa8c1380c41da4c145d6493ae510eb6017c5f3"
    },
    "parent_block_identifier": {
      "index": 53,
      "hash": "2b52c7fcdbdcd362211e1646fa6351c8f6fd4cbfa520fe7857133e59061ff348"
    },
    "timestamp": 1530389834000,
    "transactions": [
      {
        "transaction_identifier": {
          "hash": "20247d9df50d830b8978a5c49313a6f8a118fd5bb9c2950e3c7f95f5ac6410f6"
        },
        "operations": [
          {
            "operation_identifier": {
              "index": 0
            },
            "type": "transfer",
            "status": "SUCCESS",
            "account": {
              "address": "AJMFNZL5jGjZJEhBrJfVLHJeJ3KwiczJ6B"
            },
            "amount": {
              "value": "-1000000000000000000",
              "currency": {
                "symbol": "ONT",
                "decimals": 9,
                "metadata": {
                  "ContractAddress": "0100000000000000000000000000000000000000",
                  "TokenType": "Governance Token"
                }
              }
            }
          },
          {
            "operation_identifier": {
              "index": 1
            },
            "related_operations": [
              {
                "index": 0
              }
            ],
            "type": "transfer",
            "status": "SUCCESS",
            "account": {
              "address": "AWyEMxiLUVr5MeVJe3Fw5Xsij7iZUmfYyk"
            },
            "amount": {
              "value": "1000000000000000000",
              "currency": {
                "symbol": "ONT",
                "decimals": 9,
                "metadata": {
                  "ContractAddress": "0100000000000000000000000000000000000000",
                  "TokenType": "Governance Token"
                }
              }
            }
          }
        ]
      }
    ]
  }
}

Please note that the transaction record consists of two operations, i.e. the from operation, and the to operation. The transaction amount for the from operation is negative, while the amount for the to operation is equal and positive.

The currency field contains token details. The two tokens are denoted in the following manner:

ONT Parameters

{
    "symbol": "ONT",
    "decimals": 9,
    "metadata": {
        "ContractAddress": "0100000000000000000000000000000000000000",
        "TokenType": "Governance Token"
        }
}

ONG Parameters

{
    "symbol": "ONG",
    "decimals": 18,
    "metadata": {
        "ContractAddress": "0200000000000000000000000000000000000000",
        "TokenType": "Utility Token"
        }
}

Fetch transaction information from a block

Method: POST

URL: /block/transaction

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "block_identifier": {
    "index": 54,
    "hash": "790ea8942e5722c75ba638312caa8c1380c41da4c145d6493ae510eb6017c5f3"
  },
  "transaction_identifier": {
    "hash": "20247d9df50d830b8978a5c49313a6f8a118fd5bb9c2950e3c7f95f5ac6410f6"
  }
}

Sample Response:

{
  "transaction": {
    "transaction_identifier": {
      "hash": "20247d9df50d830b8978a5c49313a6f8a118fd5bb9c2950e3c7f95f5ac6410f6"
    },
    "operations": [
      {
        "operation_identifier": {
          "index": 0
        },
        "type": "transfer",
        "status": "SUCCESS",
        "account": {
          "address": "AJMFNZL5jGjZJEhBrJfVLHJeJ3KwiczJ6B"
        },
        "amount": {
          "value": "-1000000000000000000",
          "currency": {
            "symbol": "ONT",
            "decimals": 9,
            "metadata": {
              "ContractAddress": "0100000000000000000000000000000000000000",
              "TokenType": "Governance Token"
            }
          }
        }
      },
      {
        "operation_identifier": {
          "index": 1
        },
        "related_operations": [
          {
            "index": 0
          }
        ],
        "type": "transfer",
        "status": "SUCCESS",
        "account": {
          "address": "AWyEMxiLUVr5MeVJe3Fw5Xsij7iZUmfYyk"
        },
        "amount": {
          "value": "1000000000000000000",
          "currency": {
            "symbol": "ONT",
            "decimals": 9,
            "metadata": {
              "ContractAddress": "0100000000000000000000000000000000000000",
              "TokenType": "Governance Token"
            }
          }
        }
      }
    ]
  }
}

Mempool

Fetch all mempool transactions

Method: POST

URL: /mempool

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  }
}

Sample Response:

{
  "transaction_identifiers": [
    {
      "hash": "<tx hash>"
    }
  ]
}

Fetch details for a mempool transaction

Method: POST

URL: /mempool/transaction

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "transaction_identifier": {
    "hash": "20247d9df50d830b8978a5c49313a6f8a118fd5bb9c2950e3c7f95f5ac6410f6"
  }
}

Sample Response:

{
  "transaction": {
    "transaction_identifier": {
      "hash": "20247d9df50d830b8978a5c49313a6f8a118fd5bb9c2950e3c7f95f5ac6410f6"
    },
    "operations": [
      {
        "operation_identifier": {
          "index": 0
        },
        "type": "transfer",
        "status": "SUCCESS",
        "account": {
          "address": "AJMFNZL5jGjZJEhBrJfVLHJeJ3KwiczJ6B"
        },
        "amount": {
          "value": "-1000000000000000000",
          "currency": {
            "symbol": "ONT",
            "decimals": 9,
            "metadata": {
              "ContractAddress": "0100000000000000000000000000000000000000",
              "TokenType": "Governance Token"
            }
          }
        }
      },
      {
        "operation_identifier": {
          "index": 1
        },
        "related_operations": [
          {
            "index": 0
          }
        ],
        "type": "transfer",
        "status": "SUCCESS",
        "account": {
          "address": "AWyEMxiLUVr5MeVJe3Fw5Xsij7iZUmfYyk"
        },
        "amount": {
          "value": "1000000000000000000",
          "currency": {
            "symbol": "ONT",
            "decimals": 9,
            "metadata": {
              "ContractAddress": "0100000000000000000000000000000000000000",
              "TokenType": "Governance Token"
            }
          }
        }
      }
    ]
  }
}
PreviousRosetta Node APINextConstruction API

Last updated 3 years ago

Was this helpful?