JSON RPC API
Pchain JSON RPC API
JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs. JSON RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.
JavaScript API
To talk to a pchain node from inside a JavaScript application, use the pweb3 library, which gives a convenient interface for the RPC methods. See the JavaScript API for more.
Java API
To talk to a pchain node from inside a Java application use the pweb3j library.
JSON RPC URL
Default JSON RPC URL
Chain Name
Chain Id
Default Datadir Directory
How To Open RPC
You can start pchain with flag –rpc
After this, if you want to check the main chain’s current block number, the command will look like this:
Or if you want to check the subchain’s current block number, the command will look like this:
You can also send requests by Postman, you will need to start pchain with the flag “–rpc –rpcaddr=0.0.0.0”. Be aware, opening your RPC to remote hosts is very dangerous if you keep your account information on your node.
Reference
Pchain Utility RPC
Chain RPC
Epoch RPC
Delegation RPC
Library
web3_clientVersion
Returns the latest software version
Parameters
none
Returns
String
- The current client version.
Example
web3_sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
Parameters
DATA
- the data to convert into a SHA3 hash.
Returns
DATA
- The SHA3 result of the given string.
Example
net_version
Returns the current network id.
Parameters
none
Returns
String
- The current network id.
"1"
: Pchain Mainnet"2"
: Testnet
Example
net_listening
Returns true
if client is actively listening for network connections.
Parameters
none
Returns
Boolean
- true
when listening, otherwise false
.
Example
net_peerCount
Returns number of peers currently connected to the client.
Parameters
none
Returns
QUANTITY
- integer of the number of connected peers.
Example
eth_protocolVersion
Returns the current pchain protocol version.
Parameters
none
Returns
String
- The current pchain protocol version.
Example
eth_syncing
Returns an object with data about the sync status or false
.
Parameters
none
Returns
Object|Boolean
, An object with sync status data or FALSE
, when not syncing:
startingBlock
:QUANTITY
- The block at which the import started (will only be reset, after the sync reached his head)currentBlock
:QUANTITY
- The current block, same as eth_blockNumberhighestBlock
:QUANTITY
- The estimated highest block
Example
eth_coinbase
Returns the client coinbase address.
Parameters
none
Returns
DATA
, 20 bytes - the current coinbase address.
Example
eth_mining
Returns true
if client is actively mining new blocks.
Parameters
none
Returns
Boolean
- returns true
of the client is mining, otherwise false
.
Example
eth_hashrate
Returns the number of hashes per second that the node is mining with.
Parameters
none
Returns
QUANTITY
- number of hashes per second.
Example
eth_gasPrice
Returns the current price per gas in wei.
Parameters
none
Returns
QUANTITY
- integer of the current gas price in wei.
Example
eth_accounts
Returns a list of addresses owned by client.
Parameters
none
Returns
Array of DATA
, 20 Bytes - addresses owned by the client.
Example
eth_blockNumber
Returns the number of most recent block.
Parameters
none
Returns
QUANTITY
- integer of the current block number the client is on.
Example
eth_getBalance
Returns the balance of the account of given address.
Parameters
DATA
, 20 Bytes - address to check for balance.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Returns
QUANTITY
- integer of the current balance in wei.
Example
eth_getStorageAt
Returns the value from a storage position at a given address.
Parameters
DATA
, 20 Bytes - address of the storage.QUANTITY
- integer of the position in the storage.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Returns
DATA
- the value at this storage position.
Example
Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at 0x295a70b2de5e3953354a6a8344e616ed314d7251
by address 0x391694e7e0b0cce554cb130d723a9d27458f9298
.
Retrieving the value of pos0 is straight forward:
Retrieving an element of the map is harder. The position of an element in the map is calculated with:
This means to retrieve the storage on pos1["0x391694e7e0b0cce554cb130d723a9d27458f9298"] we need to calculate the position with:
The geth console which comes with the web3 library can be used to make the calculation:
Now to fetch the storage:
eth_getTransactionCount
Returns the number of transactions sent from an address.
Parameters
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Returns
QUANTITY
- integer of the number of transactions send from this address.
Example
eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
Parameters
DATA
, 32 Bytes - hash of a block.
Returns
QUANTITY
- integer of the number of transactions in this block.
Example
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block matching the given block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.
Returns
QUANTITY
- integer of the number of transactions in this block.
Example
eth_getUncleCountByBlockHash
Returns the number of uncles in a block from a block matching the given block hash.
Parameters
DATA
, 32 Bytes - hash of a block.
Returns
QUANTITY
- integer of the number of uncles in this block.
Example
eth_getUncleCountByBlockNumber
Returns the number of uncles in a block from a block matching the given block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string "latest", "earliest" or "pending", see the default block parameter.
Returns
QUANTITY
- integer of the number of uncles in this block.
Example
eth_getCode
Returns code at a given address.
Parameters
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
Returns
DATA
- the code from the given address.
Example
eth_sign
The sign method calculates an pchain specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)))
.
By adding a prefix to the message makes the calculated signature recognisable as an pchain specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.
Note the address to sign with must be unlocked.
Parameters
account, message
DATA
, 20 Bytes - address.DATA
, N Bytes - message to sign.
Returns
DATA
: Signature
Example
An example how to use solidity ecrecover to verify the signature calculated with eth_sign
can be found here. The contract is deployed on the testnet Ropsten and Rinkeby.
eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Parameters
Object
- The transaction object
from
:DATA
, 20 Bytes - The address the transaction is send from.to
:DATA
, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.gas
:QUANTITY
- (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.gasPrice
:QUANTITY
- (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gasvalue
:QUANTITY
- (optional) Integer of the value sent with this transactiondata
:DATA
- The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Pchain Contract ABInonce
:QUANTITY
- (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Returns
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
eth_sendRawTransaction
Creates new message call transaction or a contract creation for signed transactions.
Parameters
DATA
, The signed transaction data.
Returns
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
eth_call
Executes a new message call immediately without creating a transaction on the block chain.
Parameters
Object
- The transaction call object
from
:DATA
, 20 Bytes - (optional) The address the transaction is sent from.to
:DATA
, 20 Bytes - The address the transaction is directed to.gas
:QUANTITY
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:QUANTITY
- (optional) Integer of the gasPrice used for each paid gasvalue
:QUANTITY
- (optional) Integer of the value sent with this transactiondata
:DATA
- (optional) Hash of the method signature and encoded parameters. For details see Pchain Contract ABI
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Returns
DATA
- the return value of executed contract.
Example
eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
Parameters
See eth_call parameters, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.
Returns
QUANTITY
- the amount of gas used.
Example
eth_getBlockByHash
Returns information about a block by hash.
Parameters
DATA
, 32 Bytes - Hash of a block.Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Returns
Object
- A block object, or null
when no block was found:
number
:QUANTITY
- the block number.null
when its pending block.hash
:DATA
, 32 Bytes - hash of the block.null
when its pending block.parentHash
:DATA
, 32 Bytes - hash of the parent block.nonce
:DATA
, 8 Bytes - hash of the generated proof-of-work.null
when its pending block.sha3Uncles
:DATA
, 32 Bytes - SHA3 of the uncles data in the block.logsBloom
:DATA
, 256 Bytes - the bloom filter for the logs of the block.null
when its pending block.transactionsRoot
:DATA
, 32 Bytes - the root of the transaction trie of the block.stateRoot
:DATA
, 32 Bytes - the root of the final state trie of the block.receiptsRoot
:DATA
, 32 Bytes - the root of the receipts trie of the block.miner
:DATA
, 20 Bytes - the address of the beneficiary to whom the mining rewards were given.difficulty
:QUANTITY
- integer of the difficulty for this block.totalDifficulty
:QUANTITY
- integer of the total difficulty of the chain until this block.extraData
:DATA
- the "extra data" field of this block.size
:QUANTITY
- integer the size of this block in bytes.gasLimit
:QUANTITY
- the maximum gas allowed in this block.gasUsed
:QUANTITY
- the total used gas by all transactions in this block.timestamp
:QUANTITY
- the unix timestamp for when the block was collated.transactions
:Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.uncles
:Array
- Array of uncle hashes.
Example
eth_getBlockByNumber
Returns information about a block by block number.
Parameters
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Returns
Example
Result see eth_getBlockByHash
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Parameters
DATA
, 32 Bytes - hash of a transaction
Returns
Object
- A transaction object, or null
when no transaction was found:
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in.null
when its pending.blockNumber
:QUANTITY
- block number where this transaction was in.null
when its pending.from
:DATA
, 20 Bytes - address of the sender.gas
:QUANTITY
- gas provided by the sender.gasPrice
:QUANTITY
- gas price provided by the sender in Wei.hash
:DATA
, 32 Bytes - hash of the transaction.input
:DATA
- the data send along with the transaction.nonce
:QUANTITY
- the number of transactions made by the sender prior to this one.to
:DATA
, 20 Bytes - address of the receiver.null
when its a contract creation transaction.transactionIndex
:QUANTITY
- integer of the transaction's index position in the block.null
when its pending.value
:QUANTITY
- value transferred in Wei.v
:QUANTITY
- ECDSA recovery idr
:DATA
, 32 Bytes - ECDSA signature rs
:DATA
, 32 Bytes - ECDSA signature s
Example
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
Parameters
DATA
, 32 Bytes - hash of a block.QUANTITY
- integer of the transaction index position.
Returns
Example
Result see eth_getTransactionByHash
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction index position.
Parameters
QUANTITY|TAG
- a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.QUANTITY
- the transaction index position.
Returns
Example
Result see eth_getTransactionByHash
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Note That the receipt is not available for pending transactions.
Parameters
DATA
, 32 Bytes - hash of a transaction
Returns
Object
- A transaction receipt object, or null
when no receipt was found:
transactionHash
:DATA
, 32 Bytes - hash of the transaction.transactionIndex
:QUANTITY
- integer of the transaction's index position in the block.blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in.blockNumber
:QUANTITY
- block number where this transaction was in.from
:DATA
, 20 Bytes - address of the sender.to
:DATA
, 20 Bytes - address of the receiver. null when it's a contract creation transaction.cumulativeGasUsed
:QUANTITY
- The total amount of gas used when this transaction was executed in the block.gasUsed
:QUANTITY
- The amount of gas used by this specific transaction alone.contractAddress
:DATA
, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwisenull
.logs
:Array
- Array of log objects, which this transaction generated.logsBloom
:DATA
, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs.
It also returns either :
root
:DATA
32 bytes of post-transaction stateroot (pre Byzantium)status
:QUANTITY
either1
(success) or0
(failure)
Example
eth_getUncleByBlockHashAndIndex
Returns information about a uncle of a block by hash and uncle index position.
Parameters
DATA
, 32 Bytes - hash a block.QUANTITY
- the uncle's index position.
Returns
Example
Result see eth_getBlockByHash
Note: An uncle doesn't contain individual transactions.
eth_getUncleByBlockNumberAndIndex
Returns information about a uncle of a block by number and uncle index position.
Parameters
QUANTITY|TAG
- a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.QUANTITY
- the uncle's index position.
Returns
Note: An uncle doesn't contain individual transactions.
Example
Result see eth_getBlockByHash
eth_getCompilers (DEPRECATED)
Returns a list of available compilers in the client.
Parameters
none
Returns
Array
- Array of available compilers.
Example
eth_compileSolidity (DEPRECATED)
Returns compiled solidity code.
Parameters
String
- The source code.
Returns
DATA
- The compiled source code.
Example
eth_compileLLL (DEPRECATED)
Returns compiled LLL code.
Parameters
String
- The source code.
Returns
DATA
- The compiled source code.
Example
eth_compileSerpent (DEPRECATED)
Returns compiled serpent code.
Parameters
String
- The source code.
Returns
DATA
- The compiled source code.
Example
eth_newFilter
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.
A note on specifying topic filters:
Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:
[]
"anything"[A]
"A in first position (and anything after)"[null, B]
"anything in first position AND B in second position (and anything after)"[A, B]
"A in first position AND B in second position (and anything after)"[[A, B], [A, B]]
"(A OR B) in first position AND (A OR B) in second position (and anything after)"
Parameters
Object
- The filter options:
fromBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
, - (optional) Array of 32 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
Returns
QUANTITY
- A filter id.
Example
eth_newBlockFilter
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.
Parameters
None
Returns
QUANTITY
- A filter id.
Example
eth_newPendingTransactionFilter
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
Parameters
None
Returns
QUANTITY
- A filter id.
Example
eth_uninstallFilter
Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren't requested with eth_getFilterChanges for a period of time.
Parameters
QUANTITY
- The filter id.
Returns
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
Example
eth_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since last poll.
Parameters
QUANTITY
- the filter id.
Returns
Array
- Array of log objects, or an empty array if nothing has changed since last poll.
For filters created with
eth_newBlockFilter
the return are block hashes (DATA
, 32 Bytes), e.g.["0x3454645634534..."]
.For filters created with
eth_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes), e.g.["0x6345343454645..."]
.For filters created with
eth_newFilter
logs are objects with following params:removed
:TAG
-true
when the log was removed, due to a chain reorganization.false
if its a valid log.logIndex
:QUANTITY
- integer of the log index position in the block.null
when its pending log.transactionIndex
:QUANTITY
- integer of the transactions index position log was created from.null
when its pending log.transactionHash
:DATA
, 32 Bytes - hash of the transactions this log was created from.null
when its pending log.blockHash
:DATA
, 32 Bytes - hash of the block where this log was in.null
when its pending.null
when its pending log.blockNumber
:QUANTITY
- the block number where this log was in.null
when its pending.null
when its pending log.address
:DATA
, 20 Bytes - address from which this log originated.data
:DATA
- contains the non-indexed arguments of the log.topics
:Array of DATA
- Array of 0 to 4 32 BytesDATA
of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g.Deposit(address,bytes32,uint256)
), except you declared the event with theanonymous
specifier.)
Example
eth_getFilterLogs
Returns an array of all logs matching filter with given id.
Parameters
QUANTITY
- The filter id.
Returns
Example
Result see eth_getFilterChanges
eth_getLogs
Returns an array of all logs matching a given filter object.
Parameters
Object
- The filter options:
fromBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
, - (optional) Array of 32 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.blockhash
:DATA
, 32 Bytes - (optional) With the addition of EIP-234 (Geth >= v1.8.13 or Parity >= v2.1.0),blockHash
is a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash
. UsingblockHash
is equivalent tofromBlock
=toBlock
= the block number with hashblockHash
. IfblockHash
is present in the filter criteria, then neitherfromBlock
nortoBlock
are allowed.
Returns
Example
Result see eth_getFilterChanges
eth_getWork
Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").
Parameters
none
Returns
Array
- Array with the following properties:
DATA
, 32 Bytes - current block header pow-hashDATA
, 32 Bytes - the seed hash used for the DAG.DATA
, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.
Example
eth_submitWork
Used for submitting a proof-of-work solution.
Parameters
DATA
, 8 Bytes - The nonce found (64 bits)DATA
, 32 Bytes - The header's pow-hash (256 bits)DATA
, 32 Bytes - The mix digest (256 bits)
Returns
Boolean
- returns true
if the provided solution is valid, otherwise false
.
Example
eth_submitHashrate
Used for submitting mining hashrate.
Parameters
Hashrate
, a hexadecimal string representation (32 bytes) of the hash rateID
, String - A random hexadecimal(32 bytes) ID identifying the client
Returns
Boolean
- returns true
if submitting went through succesfully and false
otherwise.
Example
eth_getProof
Returns the account- and storage-values of the specified account including the Merkle-proof.
getProof-Parameters
DATA
, 20 bytes - address of the account or contractARRAY
, 32 Bytes - array of storage-keys which should be proofed and included. See eth_getStorageAtQUANTITY|TAG
- integer block number, or the string "latest" or "earliest", see the default block parameter
getProof-Returns
Returns Object
- A account object:
balance
: QUANTITY
- the balance of the account. See eth_getBalance
codeHash
: DATA
, 32 Bytes - hash of the code of the account. For a simple Account without code it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
nonce
: QUANTITY
, - nonce of the account. See eth_getTransactionCount
storageHash
: DATA
, 32 Bytes - SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash.
accountProof
: ARRAY
- Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3 (address) as key.
storageProof
: ARRAY
- Array of storage-entries as requested. Each entry is a object with these properties:
key
: QUANTITY
- the requested storage key value
: QUANTITY
- the storage value proof
: ARRAY
- Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3 (key) as path.
getProof-Example
db_putString
Stores a string in the local database.
Note this function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.String
- String to store.
Returns
Boolean
- returns true
if the value was stored, otherwise false
.
Example
db_getString
Returns string from the local database.
Note this function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.
Returns
String
- The previously stored string.
Example
db_putHex
Stores binary data in the local database.
Note this function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.DATA
- The data to store.
Returns
Boolean
- returns true
if the value was stored, otherwise false
.
Example
db_getHex
Returns binary data from the local database.
Note this function is deprecated and will be removed in the future.
Parameters
String
- Database name.String
- Key name.
Returns
DATA
- The previously stored data.
Example
chain_createChildChain
Send an application of Subchain Creation, save the application into the ChainInfo DB
Parameters
from
, address - the address who triggers the action (Dont create different Subchain with same address)chainId
, string - subchain idminValidators
, hex string - Minimum Validators of the new subchainminDepositAmount
, hex string - Minimum Deposit PAI of the new subchainstartBlock
, hex string - Start Block height for launch subchainendBlock
, hex string - End Block height for launch subchaingasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, string - the transaction hash
Example
chain_joinChildChain
Send a request to Join the subchain, save the Join Application into the ChainInfo DB, after the blockchain match the criteria of the subchain, chainMgr will load the subchain Data from ChainInfo DB then start it
Parameters
from
: address, 20 Bytes - the address who triggers the actionpubkey
: hex string, 128 Bytes - the BLS Public Key who triggers the actionchainId
: string - subchain iddepositAmount
: hex string - Amount of the Deposit PAI to join the subchainsignature
: hex string, 64 Bytes - the signature of From Address, signed by BLS Private Key. (How to sign, see chain_signAddress)gasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
chain_depositInMainChain
Deposit from the main chain to subchain (step 1). Should be used with chain_depositInChildChain.
Parameters
from
, address - the address who triggers the actionchainId
, string - subchain idamount
, hex string - amount of PAI to depositgasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, string - the transaction hash
Example
chain_depositInChildChain
Deposit from the main chain to subchain (step 2). Should be used with chain_depositInMainChain
Parameters
from
, address - the address who triggers the actiontxHash
, string - Tx Hash of the chain_depositInMainChain rpc
Returns
hash
, string - the transaction hash
Example
chain_withdrawFromChildChain
Withdraw from subchain to the main chain (step 1). Should be used with chain_withdrawFromMainChain
Parameters
from
, address - the address who triggers the actionamount
, hex string - amount of PAI to withdrawgasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, string - the transaction hash
Example
chain_withdrawFromMainChain
Withdraw from subchain to the main chain (step 2). Should be used with chain_withdrawFromChildChain
Parameters
from
, address - the address who triggers the actionamount
, hex string - amount of PAI to withdrawchainId
, string - subchain idtxHash
, string - Tx Hash of the chain_withdrawFromChildChain rpc
Returns
hash
, string - the transaction hash
Example
chain_signAddress
Sign the Address with BLS Private Key, return the BLS Signature to proof you are the owner of the BLS Public Key
Parameters
from
: address, 20 Bytes - Address which will be signedprivateKey
: hex string, 32 Bytes - BLS Private Key
Returns
DATA
, 64 Bytes - the BLS Signature for the Address
Example
chain_setBlockReward
Set the Reward of each block for the subchain, only subchain Owner is allowed to send this tx. The Block Reward change will effect on the next block after this tx be mined.
The Block Reward will be charged from subchain Address 0x0000000000000000000000000000000000000064 balance, which accept anyone to transfer their contribution
Parameters
from
: address, 20 Bytes - Owner Address of subchainreward
: hex string - The reward of each block
Returns
hash
, string - the transaction hash
Example
chain_getBlockReward
Get the Reward of each block for the subchain
Parameters
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
Returns
QUANTITY
- integer of the block reward in wei
Example
chain_getAllChains
Get all the Chain Info from the node (A synced Full node should have all the chains' info)
Parameters
none
Returns
Object
- The chain info object
chain_id
:String
- The chain id of the chain.owner
:Address
, 20 Bytes - The owner address of the chain.current_epoch
:Number
- The current epoch number of the chain.epoch_start_time
:Time
- The start time of the current epochvalidators
:Array
- Array of validator objectaddress
:Address
- Address of the Validatorvoting_power
:QUANTITY
- Voting Power (Stack) of the Validator
Example
tdm_voteNextEpoch
Send hash of Vote for the next epoch (The valid window for this vote is between 75% - 85% of current epoch time, to know the detail block height, use tdm_getEpoch)
Parameters
from
: address, 20 Bytes - the address who triggers the actionvoteHash
: hex string, 32 Bytes - hash of the vote. (How to get the vote hash, use Keccak-256 (not the standardized SHA3-256) example: keccak256(from + pubkey + amount + salt) ),you can get pubkey from 'priv_validator.json' in the datadir directory(Default ~/.pchain on linux).You can get vote hash By Javascript API web3getvotehashgasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, string - the transaction hash
Example
tdm_revealVote
Reveal the vote, the content of vote should matched with the hash which provided in tdm_voteNextEpoch (The valid window for this vote is between 85% - 95% of current epoch time, to know the detail block height, use tdm_getEpoch)
Parameters
from
: address, 20 Bytes - the address who triggers the actionpubkey
: hex string, 128 Bytes - the BLS Public Key who triggers the actionamount
: hex string - the amount of votesalt
: string - salt stringsignature
: hex string, 64 Bytes - the signature of From Address, signed by BLS Private Key. (How to sign, see chain_signAddress)gasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
tdm_getCurrentEpochNumber
Returns the current epoch number
Parameters
none
Returns
epochNumber
, hex string - current epoch number
Example
tdm_getEpoch
Returns the epoch details
Parameters
number
, hex string - epoch number
Returns
result
, string - detail of the specific epoch, such as validators, start block, end block, reward per block
Example
tdm_getNextEpochVote
Returns the votes details of the next epoch
Parameters
none
Returns
result
, string - votes detail of the next epoch, such as epoch number, start block, end block, votes
Example
tdm_getNextEpochValidators
Returns the validators of the next epoch based on the votes
Parameters
none
Returns
result
, DATA - validators of the next epoch, such as address, public key, voting power
Example
tdm_generatePrivateValidator
Returns the generated BLS Public/Private Key associate with provided address
Parameters
from
: address, 20 Bytes - the address
Returns
address
: address, 20 Bytes - address from the requestconsensus_pub_key
: hex string, 128 Bytes - the generated BLS Public Keyconsensus_priv_key
: hex string, 32 Bytes - the generated BLS Private Key
Example
del_delegate
Create a new transaction to Delegate your balance to Candidate
Parameters
from
: address, 20 Bytes - the address who triggers the actioncandidate
: address, 20 Bytes - the address of candidateamount
: hex string - Amount of the Delegate PAI (minimum 1,000 PAI)gasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
del_cancelDelegate
Create a new transaction to Cancel your Delegation from Candidate
Parameters
from
: address, 20 Bytes - the address who triggers the actioncandidate
: address, 20 Bytes - the address of candidateamount
: hex string - Amount of the Delegate PAIgasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
del_applyCandidate
Create a new transaction to become a Candidate (with specific security deposit and commission fee rate)
Parameters
from
: address, 20 Bytes - the address who triggers the actionsecurityDeposit
: hex string - Amount of the security deposit PAI (minimum 10,000 PAI)commission
: integer - the commission fee percentage of each Block Reward be charged from delegator, when Candidate become a Validator (between 0 - 100)gasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
del_cancelCandidate
Create a new transaction to cancel the Candidate qualification, if the address has deposited proxied balance, it will be refund at the end of epoch, otherwise will be refund immediately
Parameters
from
: address, 20 Bytes - the address who triggers the actiongasPrice
: hex string - (optional, default: 1 gwei) gas price from the request
Returns
hash
, hex string - the transaction hash
Example
del_checkCandidate
Returns the candidate status of the account of given address.
Parameters
from
: address, 20 Bytes - address to check for balance.blockNumber
: QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending"
Returns
candidate
: Boolean - Candidate Flag of the given addresscommission
: QUANTITY - commission percentage of Candidate Address
Example
eth_getFullBalance
Returns the overall balance of the account of given address.
Parameters
from
: address, 20 Bytes - address to check for balance.blockNumber
: QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending"fullDetail
: Boolean - If true it returns the full detail of proxied/reward object under this address
Returns
balance
: QUANTITY - integer of the current balance in p-wei.total_delegateBalance
: QUANTITY - total delegate balance in p-wei to other addresstotal_depositBalance
: QUANTITY - deposit balance in p-wei for Validator Staketotal_depositProxiedBalance
: QUANTITY - total deposit proxied balance in p-wei for Validator Staketotal_pendingRefundBalance
: QUANTITY - total pending refund balance in p-wei which will be return to delegate at the end of Current Epochtotal_proxiedBalance
: QUANTITY - total proxied balance in p-wei delegate from other addresstotal_rewardBalance
: QUANTITY - total pending reward balance in p-wei of this addressproxied_detail
: Object - detail record of each address's proxied data, including proxied balance, deposit proxied balance and pending refund balancereward_detail
: Object - detail record of this address's reward data, including how much balance in p-wei will be given at the end of each epoch
Example
del_extractReward
Extract all avaliable reward.
Parameters
address
: address, 20 Bytes - address to check for balance.gasPrice
:QUANTITY|TAG
-(optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas
Returns
hash
hex string - the transaction hash
Example
Last updated