-
Notifications
You must be signed in to change notification settings - Fork 36
JSON RPC
- Valid on dev branch of this repo
- RPC HTTP endpoint: http://localhost:8545
-
RPC interface list:
- account_accountIsExist
- account_getAccountByName
- account_getAccountByID
- account_getCode
- account_getNonce
- account_getAssetInfoByName
- account_getAssetInfoByID
- account_getAccountBalanceByID
- account_getAccountBalanceByTime
- account_getAssetAmountByTime
- account_getSnapshotTime
- ft_sendRawTransaction
- ft_getBlockByHash
- ft_getBlockByNumber
- ft_getCurrentBlock
- ft_getTransactionByHash
- ft_getTransactionReceipt
- ft_getBlockAndResultByNumber
- ft_getTxsByAccount
- ft_getTxsByBloom
- ft_getInternalTxByAccount
- ft_getInternalTxByBloom
- ft_getInternalTxByHash
- ft_gasPrice
- ft_call
- ft_estimateGas
- ft_getChainConfig
- ft_newPendingTransactionFilter
- ft_newBlockFilter
- ft_newFilter
- ft_getFilterChanges
- ft_uninstallFilter
- dpos_info
- dpos_irreversible
- dpos_epoch
- dpos_prevEpoch
- dpos_nextEpoch
- dpos_votersByCandidate
- dpos_votersByVoter
- dpos_candidates
- dpos_candidatesSize
- dpos_candidate
- dpos_availableStake
- dpos_validCandidates
- dpos_nextValidCandidates
- dpos_getActivedCandidateSize
- dpos_getActivedCandidate
- dpos_snapShotTime
- dpos_snapShotStake
- fee_getObjectFeeByName
- fee_getObjectFeeResult
Function:whether an account is exist
Argments:
- accountName - Name of the account
Response: true/false
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_accountIsExist","params":["fractal.admin"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
Function:get information of the account by name
Argments:
- accountName - Name of the account
Response: Object - object represents account,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAccountByName","params":["fractal.admin"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"accountName": "fractal.admin",
"founder": "fractal.admin",
"accountID": 4098,
"number": 0,
"nonce": 0,
"code": "",
"codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"codeSize": 0,
"threshold": 1,
"updateAuthorThreshold": 1,
"authorVersion": "0xcef3cd8eb9a2c3253a5a21abd3991f19b9deb8eda8ac38ed0951a74d5318c652",
"balances": [
{
"assetID": 0,
"balance": 1e+29
}
],
"authors": [
{
"owner": "0x047db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf795962b8cccb87a2eb56b29fbe37d614e2f4c3c45b789ae4f1f51f4cb21972ffd",
"weight": 1
}
],
"suicide": false,
"destroy": false,
"description": ""
}
}
Function:get information of the account by ID
Argments:
- accountID - ID of the account
Response: Object - object represents account,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAccountByID","params":[45000],"id":1}' http://localhost:8545
// Result
Function:get contract code by account name
Argments:
- accountName - Name of the account
Response: Contract code
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getCode","params":["fractal.admin"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x900463ffff......"
}
Function:get nonce of the account
Argments:
- accountName - Name of the account
Response: the value of nonce
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getNonce","params":["fractal.admin"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 2
}
Function: get information of the asset by its name
Argments:
- assetName - Name of the asset
Response: Object - object represents asset,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAssetInfoByName","params":["ftoken"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"assetName": "ftoken",
"symbol": "ft",
"amount": 1e+29,
"decimals": 18,
"founder": "fractal.admin",
"owner": "fractal.admin",
"addIssue": 1e+29,
"upperLimit": 1e+29,
"contract": "",
"description": ""
}
}
Function: get information of the asset by its id
Argments:
- assetID - id of the asset
Response: Object - object represents asset,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAssetInfoByID","params":[1],"id":1}' http://localhost:8545
// Result
Function: get account balance by accountName and assetID
Argments:
- accountName - Name of the account
- assetID - id of the asset
- typeID - 0:only count main asset; 1: subasset included
Response: QUANTITY - current balance(unit:gaft).
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAccountBalanceByID","params":["fractal.admin", 0, 0],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 200000010000
}
Function: get account balance by accountName and snapshot time
Argments:
- accountName - Name of the account
- assetID - id of the asset
- typeID - 0:only count main asset; 1: subasset included
- time - snapshot time
Response: QUANTITY - current balance(unit:wei).
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAccountBalanceByTime","params":["ftsystemio", 0, 0, 1546054908000000000],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 200000010000
}
Function: query the total amount of a specific asset
Argments:
- assetID - id of the asset
- time - snapshot time
Response: Object - #td
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAssetAmountByTime","params":[1,1552977600000000000],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 2000010000
}
Function: get adjacent snapshot time
Argments:
- typeID - 0: current time,and 2nd arg must be set to 0; 1: preview time; 2: next time
- time - snapshot time
params: [ 1, 1546054910000000000 ]
Response: data - snapshot time
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getSnapshotTime","params":[1,1546054910000000000],"id":1}' http://localhost:8545
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": 1546054908000000000
}
Function:send raw transaction data to node
Argments:
- data - signed transaction data
params: [ "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675" ]
Response: data - hash value of the transaction, 0 if the transaction is invalid
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_sendRawTransaction","params":["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"],"id":1}' http://localhost:8545
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
Function:get information of the block by its hash value
Argments:
- data - the hash value of the block
- Boolean - true when returned the entire block information,otherwise only hash of the transactions will be returned
Response: Object - object represents block,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": 1059999,
"extraData": "0x73797374656d2ccf0144c13b919f33ace5085e4369a434126d210c223c8c8ec129c3bf56f39e10d9d94237a2420b97bb6dba571a747833df83008ffba779b715b94554aa961200",
"forkID": {
"cur": 0,
"next": 0
},
"gasLimit": 30000000,
"gasUsed": 0,
"hash": "0x2f5d0a3e930a9843870fd6a3e0ad88d9f0604c171ef223234dea036a5c1b0ce8",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "candidate5",
"number": 104625,
"parentHash": "0xd8bafb27b5947870049e7f079206e7774d51c2d2faa9417c3a22a2aaf09670d9",
"proposedIrreversible": 104544,
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size": 512,
"stateRoot": "0xa1ed169aeb561d89536dd6919fb16ecf776d0a52cd01407345afab77e33547da",
"timestamp": 1558955994000000000,
"totalDifficulty": 104864178994,
"transactions": [{...}],
"transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
Function:get information of the block by its height
Argments:
- QUANTITY|TAG - number of the block
- Boolean - true when returned the entire block information,otherwise only hash of the transactions will be returned
Response: Ref ft_getBlockByHash
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getBlockByNumber","params":[10, true],"id":1}' http://localhost:8545
// Result
Function:get information of current block
Argments:
- Boolean - true when returned the entire block information,otherwise only hash of the transactions will be returned
Response: Ref ft_getBlockByHash
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getCurrentBlock","params":[true],"id":1}' http://localhost:8545
// Result
Function:get information of transaction by its hash value
Argments:
- data - the hash value of the transaction
Response: Object - object represents transaction,null if not found
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTransactionByHash","params":["0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x99a7eeda1b44e716344a2f7fb57193443cfb8553956b2cb98343510a11785893",
"blockNumber": 29,
"txHash": "0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece",
"transactionIndex": 0,
"actions": [{
"type": 6,
"nonce": 1,
"from": "testname",
"to": "",
"assetID": 0,
"gas": 200000,
"value": 0,
"payload": "0xe5808a41737365746e616d65318753796d626f6c31865af3107a40000288746573746e616d65",
"actionHash": "0x1a3bd6ee054ca68df24d62f37c98f29bcec7df147b6638b988cb529cee36e980",
"actionIndex": 0
}],
"gasAssetID": 1,
"gasPrice": 2,
"gasCost": 400000
}
}
Function:get receipt of transaction by hash value
Argments:
- data - the hash value of the transaction
Response: Object - object represents receipt,null if not found
Example: // Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTransactionReceipt","params":["0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x3b627e25a55603253a8d81b34af98fb0c89d64d70ba4d2018c7a2e2767065322",
"blockNumber": 122756,
"txHash": "0x016fda697e94608da014887b8e383168e561bd72815473204aaba0adc828aab0",
"transactionIndex": 0,
"postState": "0xd90b315f457e734aeb02c66052bf96d51add34b52396dae79c9b299bc500aa66",
"actionResults": [
{
"actionType": 772,
"status": 1,
"index": 0,
"gasUsed": 101368,
"gasAllot": [
{
"name": "candidate3",
"gas": 101368,
"typeId": 2
}
],
"error": ""
}
],
"cumulativeGasUsed": 101368,
"totalGasUsed": 101368,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"logs": null
}
}
Function: get block info and receipts with interal transcation logs at a specific number of block
Argments:
- number - number of the block
Response: Object - #td
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getBlockAndResultByNumber","params":["109222"],"id":1}' http://localhost:8545
// Result
Function: get all transcations sent from or to an account by a range of blocks
Argments:
- accountName - Name of the account
- blockNr - number of the block to start search
- lookbackNum - indicates how many blocks to search backwards
Response: list of transcations hash
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTxsByAccount","params":["ftsystemio",10,5],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": ["0xcf2ebeccce958496c39b59adf106a7568143f41f72c845dd258c8719d3c15abd",...]
}
Function: get all transcations filtered by a bloombyte by a range of blocks
Argments:
- bloomByte - the bloombyte constructed by a list of account names
- blockNr - number of the block to start search
- lookbackNum - indicates how many blocks to search backwards
Response: list of transcations hash
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTxsByBloom","params":["0x013...",10,5],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": ["0xcf2ebeccce958496c39b59adf106a7568143f41f72c845dd258c8719d3c15abd",...]
}
Function: get all internal transcation logs sent from or to an account by a range of blocks
Argments:
- accountName - Name of the account
- blockNr - number of the block to start search
- lookbackNum - indicates how many blocks to search backwards
Response: list of internal transcations logs
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getInternalTxByAccount","params":["ftsystemio",10,5],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [{
"txhash":"0xcf2ebeccce958496c39b59adf106a7568143f41f72c845dd258c8719d3c15abd",
"actions"[{
"internalActions":[{
"action":{
"type": 6,
"nonce": 1,
"from": "testname",
"to": "",
"assetID": 0,
"gas": 200000,
"value": 0,
"payload": "0xe5808a41737365746e616d65318753796d626f6c31865af3107a40000288746573746e616d65",
"actionHash": "0x1a3bd6ee054ca68df24d62f37c98f29bcec7df147b6638b988cb529cee36e980",
"actionIndex": 0
}
"actionType":""
"gasUsed":1000,
"gasLimit": 50000,
"depth": 1
"error":"",
},...]
},...]
},...]
}
Function: get all internal transcation logs filtered by a bloombyte by a range of blocks
Argments:
- bloomByte - the bloombyte constructed by a list of account names
- blockNr - number of the block to start search
- lookbackNum - indicates how many blocks to search backwards
Response: list of internal transcations logs
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getInternalTxByBloom","params":["0x013...",10,5],"id":1}' http://localhost:8545
// Result
Function: get internal transcation logs of a specific transcation
Argments:
- data - the hash value of the transaction
Response: Object - object represent interal transcation
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getInternalTxByHash","params":["0x94c7941205ce8c3ea053fe84d18892d20ea25b69852252b1e6db25a0cc49cc9c"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result":{
"txhash":"0xcf2ebeccce958496c39b59adf106a7568143f41f72c845dd258c8719d3c15abd",
"actions"[{
"internalActions":[{
"action":{
"type": 6,
"nonce": 1,
"from": "testname",
"to": "",
"assetID": 0,
"gas": 200000,
"value": 0,
"payload": "0xe5808a41737365746e616d65318753796d626f6c31865af3107a40000288746573746e616d65",
"actionHash": "0x1a3bd6ee054ca68df24d62f37c98f29bcec7df147b6638b988cb529cee36e980",
"actionIndex": 0
}
"actionType":""
"gasUsed":1000,
"gasLimit": 50000,
"depth": 1
"error":"",
},...]
},...]
}
}
Function:get adviced gas price
Argments: None
Response: adviced gas price
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_gasPrice","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 1800
}
Function:execute a message call,this will not create a transaction on chain
Argments:
- from - 20 bytes long user's address
- to - 20 bytes long user's address
- data - payload of the transaction
- assetId - id of the asset
- actionType - type of transaction(0:issue asset, 1:further issue asset, 2:set the owner of the asset,3:transfer asset)
- gas - gas limit for this transaction
- gasPrice - gas price for this transaction
- value - transfered value for this transaction
- QUANTITY|TAG - height of the block, or string value "latest", "earliest" or "pending"
params: [{"from":"testtest7","to":"testcontract5","data":"0xef9ba08c00000000000000000000000000000000000000000000007465737474657374370000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a","assetId":1,"actionType":2,"gas":200000,"gasPrice":3,"value":1},"latest"]
Response: null
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_call","params":[{"from":"testtest7","to":"testcontract5","data":"0xef9ba08c00000000000000000000000000000000000000000000007465737474657374370000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a","assetId":1,"actionType":2,"gas":200000,"gasPrice":3,"value":1},"latest"],"id":1}' http://localhost:8545
// Result null
Function:estimate the gas needed for a transaction
Argments: same as ft_call
Response: gas needed for a transaction
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_estimateGas","params":[{"from":"testtest7","to":"testcontract5","data":"0xef9ba08c00000000000000000000000000000000000000000000007465737474657374370000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a","assetId":1,"actionType":2,"gas":200000,"gasPrice":3,"value":1},"latest"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 21000
}
Function: get the chain configs
Argments: None
Response: Object - the object represents chain configs
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getChainConfig","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"bootnodes": [
"fnode://938597139178830dac79a3c1bcc7be70d41a79a1a1f479cde73862a3d2b808e83f60c6b7d9bd4ff999403828d2b4b5a27ff7323b3467ba3f45db6150db943c32@120.131.7.228:2018",
"fnode://e30016f87e9f32895039c5b4fbbb40fbbf04fc2ef93299124a115df8344d81fff070591b2e455f043d2ccc9ffab3b881ce89c426ae111a5400034bb0fe64e1fa@120.131.7.101:2018"
],
"chainId": 45,
"chainName": "fractal",
"chainUrl": "https://fractalproject.com",
"accountParams": {
"level": 1,
"length": 16,
"subLength": 8
},
"assetParams": {
"level": 1,
"length": 16,
"subLength": 8
},
"chargeParams": {
"assetRatio": 80,
"contractRatio": 80
},
"upgradeParams": {
"blockCnt": 10000,
"upgradeRatio": 80
},
"dposParams": {
"maxURLLen": 512,
"unitStake": 1000,
"candidateMinQuantity": 10,
"voterMinQuantity": 1,
"activatedMinQuantity": 100,
"blockInterval": 3000,
"blockFrequency": 6,
"candidateScheduleSize": 15,
"epchoInterval": 21600000,
"freezeEpchoSize": 3,
"extraBlockReward": 1,
"blockReward": 5
},
"systemName": "fractal.admin",
"accountName": "fractal.account",
"assetName": "fractal.asset",
"dposName": "fractal.dpos",
"snapshotInterval": 3600000,
"feeName": "fractal.fee",
"systemToken": "ftoken",
"sysTokenDecimal": 18,
"referenceTime": 1555776000000000000
}
}
Function: Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call ft_getFilterChanges
Argments: None
Response: QUANTITY - A filter id
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_newPendingTransactionFilter","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x50dbd6380389d414e254ce64f736b97c"
}
Function: Creates a filter in the node, to notify when new block arrive. To check if the state has changed, call ft_getFilterChanges
Argments: None
Response: QUANTITY - A filter id
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_newBlockFilter","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x5aeb8e569931053fb6a9b9422c701a93"
}
Function: Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call ft_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)"
Argments:
-
accounts
:DATA|Array
, account name - (optional) Contract name or a list of accounts 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.
Response: QUANTITY - A filter id
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_newFilter","params":[{"accounts":["fractal.founder"],"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xfce5a886e3550604059a5f3e404f8767"
}
Function: Polling method for a filter, which returns an array of logs or hashes which occurred since last poll
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)"
Argments:
QUANTITY - A filter id
Response:
- For filters created with
ft_newBlockFilter
the return are block hashes (DATA
, 32 Bytes), e.g.["0x3454645634534..."]
. - For filters created with
ft_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes), e.g.["0x6345343454645..."]
. - For filters created with
ft_newFilter
logs are objects with following params:-
index
:QUANTITY
- integer of the log index position in the block. -
txIndex
:QUANTITY
- integer of the transactions index position log was created from. -
actionIndex:
QUANTITY
- integer of the action index position log was created from. -
txHash
:DATA
, 32 Bytes - hash of the transactions this log was created from. -
blockHash
:DATA
, 32 Bytes - hash of the block where this log was in.null
when its pending. -
blockNumber
:QUANTITY
- the block number where this log was in.null
when its pending. -
name
:DATA
, account - account 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:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getFilterChanges","params":["0xfce5a886e3550604059a5f3e404f8767"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [{
"index": "0x1", // 1
"actionIndex": "0x1", // 1
"blockNumber":"0x1b4", // 436
"blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"transactionHash": "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
"transactionIndex": "0x0", // 0
"name": "fractal.founder",
"data":"0x0000000000000000000000000000000000000000000000000000000000000000",
"topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"]
},{
...
}]
}
Function: 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 ft_getFilterChanges (https://github.com/fractalplatform/fractal/wiki/JSON-RPC#ft_getfilterchanges) for a period of time.
Argments: QUANTITY
- The filter id
Response:
Bool - true
if the filter was successfully uninstalled, otherwise false
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_uninstallFilter","params":["0xfce5a886e3550604059a5f3e404f8767"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
Function:query dpos configuration
Argments: None
Response: data - configuration of dpos
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_info","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"maxURLLen": 512,
"unitStake": 1,
"candidateMinQuantity": 500000,
"candidateAvailableMinQuantity": 3000000,
"voterMinQuantity": 1,
"activatedMinCandidate": 28,
"activatedMinQuantity": 1350000000,
"blockInterval": 3000,
"blockFrequency": 6,
"candidateScheduleSize": 21,
"backupScheduleSize": 7,
"epochInterval": 604800000,
"freezeEpochSize": 2,
"accountName": "fractal.dpos",
"systemName": "fractal.admin",
"systemURL": "https://fractalproject.com",
"extraBlockReward": 0,
"blockReward": 0,
"decimals": 18,
"assetID": 0,
"referenceTime": 1555776000000000000
}
}
Function:query irreversible height
Argments: None
Response: data - the irreversible height
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_irreversible","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"bftIrreversible": 21433,
"proposedIrreversible": 21434,
"reversible": 21434
}
}
Function:query epoch number by block number
Argments:
- number - block number
Response: a number represents epoch
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_epoch","params":[19000],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 100
}
Function:query previous epoch from given epoch
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: a number represents epoch
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_prevEpoch","params":[10],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 9
}
Function:query next epoch from given epoch
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: a number represents epoch
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_nextEpoch","params":[10],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 11
}
Function: get voters info of candidate
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- candidate - the name of the candidate
- detail - if false only the name of the voter is returned
Response: list of voter info
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_votersByCandidate","params":[10,"testtest13",true],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [{
"epcho": 1001
"name":"testtest1",
"candidate":"testtest2",
"quantity":10,
"number":1557725729
},...]
}
Function: get voters info of voter
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- voter - the name of the voter
- detail - if false only the name of the candidate is returned
Response: list of vote info
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_votersByVoter","params":[10,"testtest2",true],"id":1}' http://localhost:8545
// Result
Function: get all candidates info of a specific epoch
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- detail - if false only the name of the candidate is returned
Response: list of candidate info
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_candidates","params":[10,true],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [{
"epoch": 7,
"name":"testtest1",
"url":"www.testurl.com",
"quantity": 0,
"totalQuantity": 0,
"number": 0,
"shouldCounter": 214,
"actualCounter": 212,
"type": "normal"
},...]
}
Function: get candidates size
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: a number represents size of candidates
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_candidatesSize","params":[10],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 28
}
Function: get candidate info by name
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- name - the name of the candidate
Response: Object - object represent the candidate
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_candidate","params":[10,"testtest1"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result":{
"epoch": 7,
"name":"testtest1",
"url":"www.testurl.com",
"quantity": 0,
"totalQuantity": 0,
"number": 0,
"shouldCounter": 24,
"actualCounter": 21,
"type": "normal"
}
}
Function: get current available stake of a voter
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- voter - the name of the voter
Response: the number of the available stake
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_availableStake","params":[10,"testtest1"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 10
}
Function: query valid candidates by epoch
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: Object - object represent the validate candidates
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_validCandidates","params":[100],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"epcho":50,
"preEpcho":49,
"activatedCandidateSchedule":[
"testtest1",
"testtest2",
"testtest3"
]
"activatedTotalQuantity":100000,
"offCandidateSchedule":[],
"offCandidateNumber":[],
"totalQuantity":100010,
"takeOver":false,
"dpos":true,
"number":1557726302,
}
}
Function: valid candidates of next epoch
Argments: None
Response: Object - object represent the validate candidates
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_nextValidCandidates","params":[],"id":1}' http://localhost:8545
// Result
Function: get actived candidates size
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: a number represents size of candidates
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_getActivedCandidateSize","params":[10],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 21
}
Function: get actived candidate at a specific index
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- index - index of the actived candidate
Response: Object - object represent actived candidate info
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_getActivedCandidate","params":[0,0],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"actualCount": 52,
"candidate": "fractal.admin",
"delegatedStake": 0,
"epoch": 358,
"replaceIndex": 0,
"shouldCount": 52,
"votedStake": 0
}
}
Function: get snapshort time and timestamp
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
Response: Object - object cotains time and timestamp
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_snapShotTime","params":[100],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"time": "2019-04-21T00:00:00+08:00",
"timestamp": 1555776000000000000
}
}
Function: get snapshort stake of account name
Argments:
- epoch - epoch of the mining cycles,current data will be returned if 0 is passed
- name - the name of the account Response: Object - object stake of account name
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_snapShotStake","params":[0,"fractal.admin"],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": 1e+28
}
Function: get fee detail by object's name
Argments:
- name - name of the object(asset name, contract name or miner's name)
- objectType - type of the object(Asset Type(0),Contract Type(1),Coinbase Type(2))
Response: Object - object represents the details of fee
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"fee_getObjectFeeByName","params":["testtest11",2],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"objectFeeID": 874,
"objectType": 2,
"objectName": "testtest11",
"assetFees":[{
"assetID": 0,
"totalFee": 100,
"remainFee": 100,
}]
}
}
Function: get fee result from a specific id within count number at a given timestamp
Argments: None
- startFeeID - the start id(start from 1)
- count - the count of results(max 1000)
- time - timestamp, pass 0 means current
Response: Object - the object represents the fee result
Example:
// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"fee_getObjectFeeResult","params":[],"id":1}' http://localhost:8545
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"continue": false
"objectFees":[{
"objectFeeID": 874,
"objectType": 2,
"objectName": "testtest11",
"assetFees":[{
"assetID": 0,
"totalFee": 100,
"remainFee": 100,
}...]
}...]
}
}