The JSON-RPC service provides APIs for clients to query the Diem Blockchain. This tutorial will guide you through the different methods you can use. You can test these on testnet.
All commands in this document assume that:
- You are running on a Linux (Red Hat or Debian-based) or macOS system.
- You have a stable connection to the internet.
- Complete the My First Transaction tutorial to understand how to create accounts and interact with testnet.
If you have already completed the My First Transaction tutorial, you can use the following account information for Alice and Bob to get started:
To get information about Alice’s account, use get_account. To run this method, you will need the hex-coded account address (see step 4 of My First Transaction).
In the example below, we have a request sent using get_account to learn information about Alice’s account and the response received.
To see all the transactions sent by Alice’s account, you can use get_account_transactions. You will need:
- Alice’s hex-code account address
- the starting sequence number
- the maximum number of transactions you want returned for this method
In the example below, we have a request sent using get_account_transactions to learn transaction information about Alice’s account and the response received.
You can check the current state of the testnet using get_metadata.
The example below has the request and response received.
Use get_currencies to query the types of currencies supported by the Diem Blockchain.
You can use different methods to query the blockchain and get the information you’re looking for. We’ve included the complete list and their descriptions below.
|get_transactions||Get transactions on the Diem Blockchain.|
|get_account||Get the latest account information for a given account address.|
|get_account_transactions||Get transactions sent by a particular account.|
|get_metadata||Get the blockchain metadata (for example, state as known to the current full node).|
|get_events||Get the events for a given event stream key.|
|get_currencies||Get information about all currencies supported by the Diem Blockchain.|