Pando offers two sets of RPC APIs. The rationale of this division is to separate the public interface accessible to all users and personal interface that manages a specific user's private wallet.
The Pando APIs is provided by the Pando Node. It is the RPC interface via which a user can interact with the Pando Node directly. As described in the setup guide, the Pando Node can be launched with the following command. By default the Pando node runs its RPC server at port 16888.
Pando start --config=<path/to/config/folder>
The PandoCli APIs is provided by the PandoCli Daemon. It allows a user to interact with his/her personal Pando Wallet through RPC calls. The wallet can manange multiple accounts simultaneously. The encrypted private keys of the accounts are stored under ~/.Pandocli/keys/encrypted/ by default. The RPC APIs supports account creation, lock/unlock, and sending Pando/PTX. The PandoCli Daemon can be run by the following command. If the port parameter is not specified, by default it runs at port 16889. Note that part of the PandoCli Daemon's functionality depends on the Pando Node. Hence we need to have the Pando Node running when we launch the PandoCli Daemon.
Pandocli daemon start --port=
In the examples below, we assume the reader has followed the setup guide to launch both the Pando Node and the PandoCli Daemon on the local machine at port 16888 and 16889 respectively.
We have also implemented a JavaScript SDK Pando.js for ease of DApp development. Please refer to here for more details.
This API returns the version of the blockchain software.
RPC Method: Pando.GetVersion
Returns
version: the version number
git_hash: the git commit hash of the code base
timestamp: the build timestamp
Example
Shell
//Requestcurl-XPOST-H'Content-Type: application/json'--data'{"jsonrpc":"2.0","method":"Pando.GetVersion","params":[],"id":1}'http://localhost:16888/rpc//Result{"jsonrpc":"2.0","id":1,"result":{"version":"1.0","git_hash":"9d7669a735063a283ae8b6f0826183e3830c00a5","timestamp":"Tue Feb 19 23:31:32 UTC 2019" }}
GetAccount
This API returns the details of the account being queried in json format.
RPC Method: Pando.GetAccount
Query Parameters
address: the address of the account
Returns
code: the hash of the smart contract bytecode (for smart contract accounts)
coins: the native token balance
reserved_funds: fund reserved for micropayment through the off-chain resource-oriented payment pool
root: the root hash of the data Merkle-Patricia trie (for smart contract accounts)
sequence: the current sequence number of the account
This API returns the block being queried in json format.
RPC Method: Pando.GetBlock
Query Parameters
hash: the block hash
include_eth_tx_hashes: whether to include the ETH tx hash of the smart contract transactions in the response.
Returns
chain_id: ID of the chain
epoch: epoch of the block
height: height of the block
parent: hash of the parent block
transactions_hash: root hash of the transaction Merkle-Patricia trie
state_hash: root hash of the state Merkle-Patricia trie
timestamp: timestamp when the block was proposed
proposer: address of the proposer validator
children: children blocks
hash: the block hash
transactions: json representation of the transactions contained in the block
raw: transaction details
type: type of the transaction (see the Transaction Types note below)
hash: hash of the transaction
status: status of the block (see the Block Status note below)
Transaction Types
Text
0: coinbase transaction, for validator/guardian reward
1: slash transaction, for slashing malicious actors
2: send transaction, for sending tokens among accounts
3: reserve fund transaction, for off-chain micropayment
4: release fund transaction, for off-chain micropayment
5: service payment transaction, for off-chain micropayment
6: split rule transaction, for the "split rule" special smart contract
7: smart contract transaction, for general purpose smart contract
8: deposit stake transaction, for depositing stake to validators/guardians
9: withdraw stake transaction, for withdrawing stake from validators/guardians
Block Status
Text
0: pending
1: valid
2: invalid
3: committed
4: directly finalized
5: indirectly finalized
6: trusted (the first block in a verified snapshot is marked as trusted)
A block and all the transactions included in the block are considered Finalized by the validators if the block status is either 4, 5, or 6
In this example, we queried the block with hash 0x9f1e77b08c9fa8984096a735d0aae6b0e43aee297e42c54ce36334103ddd67a7. This block contains two transactions. The first one is a "coinbase" transaction (type 0), and the second is a "send" transaction (type 2). In particular, in the "send" transaction, address 0x2e833968e5bb786ae419c4d13189fb081cc43bab 20 PTX tokens to address 0x9f1233798e905e173560071255140b4a8abd3ec6, which cost 1000000000000 PTXWei transaction fee.
This API returns the finalized block given the height. If none of the blocks at the given height are finalized (either directly or indirectly), the API simply returns an empty result.
RPC Method: pando.GetBlockByHeight
Query Parameters
height: the block height (need to pass in as a string instead of an integer)
include_eth_tx_hashes: whether to include the ETH tx hash of the smart contract transactions in the response.
Returns
Similar to the returns of the GetBlock API. Please see above.
Example
In this example, we query the block at height 3. The result is similar to the result of the GetBlock API.
This API returns the transaction being queried in json format.
RPC Method: pando.GetTransaction
Query Parameters
hash: the transaction hash*
Returns
block_hash: hash of the block that contains the transaction
block_height: height of the block that contains the transaction
status: status of the transaction
hash: the hash of the transaction itself
transaction: the details of the transaction
GetTransaction Example 1
In this example, the transaction being queried is a "send transaction" (i.e., type 2, see the Transaction types. In this transaction, address 0x2e833968e5bb786ae419c4d13189fb081cc43bab 20 PTX tokens to address 0x9f1233798e905e173560071255140b4a8abd3ec6, which cost 1000000000000 PTXWei transaction fee.
Smart contract transactions can be used to send PTX. For example, if you use Metamask to send PTX following the steps here, the PTX is sent through a smart contract transaction. In the transaction details, transaction.from.coins.ptxwei specifies the amount of PTX (in Wei) sent to the receiver address (see below for more details). Similar to ETH, some of the smart contract transactions just interact with a smart contract. They may not send any PTX to the contract. This is a smart contract transaction that did not send any PTX. On the other hand, this is a smart contract transaction with a non-zero PTX value. In this example, the transaction sends 702.8783 PTX to the receiver address 0x8366537d56cf2b86ca90e9dbc89450207a29f6e3.
The following example show how to query the details of a "smart contract transaction" (i.e., type 7, see the Transaction types). This type of transaction is similar to the Ethereum transaction:
transaction.from.address is the sender address of the transaction
transaction.to.address is the receiver address of the transaction. It can be a regular wallet, or a smart contract address
transaction.from.coins.ptxwei is the amount of PTX (in unit wei, i.e. 10e-18 PTX) send to the receiver address. This corresponds to the value field of an Ethereum transaction. In the example below, the sender is sending 250000000000000000000 PTXWei (i.e. 250 PTX) to the receiver address.
transaction.gas_limit and transaction.gas_price are the the gas limit and gas price of the transaction, similar to the corresponding fields of an Ethereum transaction.
transaction.data is an optional field to include arbitrary data, similar to the data field of an Ethereum transaction.
receipt is the receipt generated by the transaction, including the event logs, similar to the Ethereum transaction receipt.
Note : You can also use pando.GetBlock to retrieve all the transactions in a block. The transaction details in the pando.GetBlock response should also contain the above fields.
This API submits the given raw transaction to the blockchain, and returns only after the transaction to be included in the blockchain, or timed out (i.e. synchronous call).
RPC Method: pando.BroadcastRawTransaction
Query Parameters
tx_bytes: the signed transaction bytes
Returns
hash: the hash of the transaction
block: the details of the block that contains the transaction
This API simulates the smart contract execution locally without submitting the smart contract transaction to the blockchain. It is useful to evaluate the execution result, calculate the gas cost, etc.
RPC Method: pando.CallSmartContract
Query Parameters
sctx_bytes: the signed transaction bytes
Returns
vm_return: the return of the virtual machine
contract_address: the address of the corresponding smart contract
gas_used: amount of gas used for the smart contract execution
vm_error: error returned by the virtual machine if any
Example
PandoCli APIs
Account APIs
NewKey
This API creates a new account (i.e. a private key/address pair), and encrypts the private key under ~/.pandocli/keys/encrypted/ by default.
This API sends the PTX tokens. Note the API call can send PTX tokens, or both in one shot.
RPC Method: pandocli.Send
Query Parameters
chain_id: ID of the chain
from: The address of the account to send tokens from
to: The address of the receipient account
ptxwei: The amount of PTX tokens to be sent (in PTXWei, 1 PTX = 10^18 PTXWei)
fee: The transaction fee in PTXWei
sequence: The expected sequence number of the from account
async: A boolean flag. If async is set to false, the RPC call will wait until the transaction has been included in a block, or a timeout reached. Otherwise, the RPC call will return immediately with the transaction hash.
Returns
hash: the hash of the transaction
block: the details of the block that has included the transaction