Skip to content

JSON RPC

Jae Liu edited this page Aug 19, 2019 · 33 revisions

RPC interface


account_accountIsExist

Function:whether an account is exist

Argments:

  1. 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  
}

account_getAccountByName

Function:get information of the account by name

Argments:

  1. 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": ""
    }
}

account_getAccountByID

Function:get information of the account by ID

Argments:

  1. 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

Ref account_getAccountByName


account_getCode

Function:get contract code by account name

Argments:

  1. 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......"  
}  

account_getNonce

Function:get nonce of the account

Argments:

  1. 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  
}  

account_getAssetInfoByName

Function: get information of the asset by its name

Argments:

  1. 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": ""
    }
}

account_getAssetInfoByID

Function: get information of the asset by its id

Argments:

  1. 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

Ref account_getAssetInfoByName


account_getAccountBalanceByID

Function: get account balance by accountName and assetID

Argments:

  1. accountName - Name of the account
  2. assetID - id of the asset
  3. 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  
}

account_getAccountBalanceByTime

Function: get account balance by accountName and snapshot time

Argments:

  1. accountName - Name of the account
  2. assetID - id of the asset
  3. typeID - 0:only count main asset; 1: subasset included
  4. 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  
}

account_getAssetAmountByTime

Function: query the total amount of a specific asset

Argments:

  1. assetID - id of the asset
  2. 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  
}

account_getSnapshotTime

Function: get adjacent snapshot time

Argments:

  1. typeID - 0: current time,and 2nd arg must be set to 0; 1: preview time; 2: next time
  2. 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
}  

ft_sendRawTransaction

Function:send raw transaction data to node

Argments:

  1. 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"  
}  

ft_getBlockByHash

Function:get information of the block by its hash value

Argments:

  1. data - the hash value of the block
  2. 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"
    }
}

ft_getBlockByNumber

Function:get information of the block by its height

Argments:

  1. QUANTITY|TAG - number of the block
  2. 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

Ref ft_getBlockByHash


ft_getCurrentBlock

Function:get information of current block

Argments:

  1. 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

Ref ft_getBlockByHash


ft_getTransactionByHash

Function:get information of transaction by its hash value

Argments:

  1. 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
	}
}

ft_getTransBatch

Function:get information of transactions

Argments:

  1. data - a list of transcation hash

Response: List - object represents transaction

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTransBatch","params":[["0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece","0x5a324a181b9aef67528ee61a2fc56cb489d0f32e72cc36bd2a2c11cdc106657c"]],"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
	}]
}

ft_getTransactionReceipt

Function:get receipt of transaction by hash value

Argments:

  1. 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
    }
}

ft_getBlockAndResultByNumber

Function: get block info and receipts with interal transcation logs at a specific number of block

Argments:

  1. 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

td


ft_getTxsByAccount

Function: get all transcations sent from or to an account by a range of blocks

Argments:

  1. accountName - Name of the account
  2. blockNr - number of the block to start search
  3. lookforwardNum - indicates how many blocks to search forwards

Response: list of transcations hash

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTxsByAccount","params":["ftsystemio",0,5],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result":{
        "txs": [
            {
                "hash": "0x5a324a181b9aef67528ee61a2fc56cb489d0f32e72cc36bd2a2c11cdc106657c",
                "height": 0
            },
            ...
        ],
        "irreversibleBlockHeight": 0,
        "endHeight": 0
    }
}

ft_getTxsByBloom

Function: get all transcations filtered by a bloombyte by a range of blocks

Argments:

  1. bloomByte - the bloombyte constructed by a list of account names
  2. blockNr - number of the block to start search
  3. lookforwardNum - indicates how many blocks to search forwards

Response: list of transcations hash

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ft_getTxsByBloom","params":["0x013...",0,5],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result":{
        "txs": [
            {
                "hash": "0x5a324a181b9aef67528ee61a2fc56cb489d0f32e72cc36bd2a2c11cdc106657c",
                "height": 0
            },
            ...
        ],
        "reversibleBlockHeight": 0,
        "endheight": 0
    }
}

ft_getInternalTxByAccount

Function: get all internal transcation logs sent from or to an account by a range of blocks

Argments:

  1. accountName - Name of the account
  2. blockNr - number of the block to start search
  3. 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":"",
            },...]
        },...]
    },...]  
}

ft_getInternalTxByBloom

Function: get all internal transcation logs filtered by a bloombyte by a range of blocks

Argments:

  1. bloomByte - the bloombyte constructed by a list of account names
  2. blockNr - number of the block to start search
  3. 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

Ref ft_getInternalTxByAccount


ft_getInternalTxByHash

Function: get internal transcation logs of a specific transcation

Argments:

  1. 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":"",
            },...]
        },...]
    }
}

ft_gasPrice

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  
}

ft_call

Function:execute a message call,this will not create a transaction on chain

Argments:

  1. from - 20 bytes long user's address
  2. to - 20 bytes long user's address
  3. data - payload of the transaction
  4. assetId - id of the asset
  5. actionType - type of transaction(0:issue asset, 1:further issue asset, 2:set the owner of the asset,3:transfer asset)
  6. gas - gas limit for this transaction
  7. gasPrice - gas price for this transaction
  8. value - transfered value for this transaction
  9. 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


ft_estimateGas

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
}

ft_getChainConfig

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
    }
}

ft_newPendingTransactionFilter

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"
}

ft_newBlockFilter

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"
}

ft_newFilter

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 Bytes DATA 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"
}

ft_getFilterChanges

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 Bytes DATA 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 the anonymous 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"]
    },{
      ...
    }]
}

ft_uninstallFilter

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 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
}

dpos_info

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
	}
}

dpos_irreversible

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
	}
}

dpos_epoch

Function:query epoch number by block number

Argments:

  1. 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
}

dpos_prevEpoch

Function:query previous epoch from given epoch

Argments:

  1. 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
}

dpos_nextEpoch

Function:query next epoch from given epoch

Argments:

  1. 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
}

dpos_votersByCandidate

Function: get voters info of candidate

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. candidate - the name of the candidate
  3. 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
    },...]
}

dpos_votersByVoter

Function: get voters info of voter

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. voter - the name of the voter
  3. 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

Ref dpos_votersByCandidate


dpos_candidates

Function: get all candidates info of a specific epoch

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. 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"
	},...]
}

dpos_candidatesSize

Function: get candidates size

Argments:

  1. 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
}

dpos_candidate

Function: get candidate info by name

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. 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"
	}
}

dpos_availableStake

Function: get current available stake of a voter

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. 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  
}

dpos_validCandidates

Function: query valid candidates by epoch

Argments:

  1. 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,
    }
}

dpos_nextValidCandidates

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

Ref dpos_validCandidates


dpos_getActivedCandidateSize

Function: get actived candidates size

Argments:

  1. 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
}

dpos_getActivedCandidate

Function: get actived candidate at a specific index

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. 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
    }
}

dpos_snapShotTime

Function: get snapshort time and timestamp

Argments:

  1. 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
    }
}

dpos_snapShotStake

Function: get snapshort stake of account name

Argments:

  1. epoch - epoch of the mining cycles,current data will be returned if 0 is passed
  2. 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
}

dpos_browserAllEpoch

Function: query all epoch

Argments: None

Response: Object - object represents epoch

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_browserAllEpoch","params":[],"id":1}' http://localhost:8545

// Result

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "data": [
            {
                "start": 1565668800,
                "epoch": 11
            },
            ...
        ]
    }
}

dpos_browserEpochRecord

Function: query the record of state of given epoch

Argments:

  1. epoch - epoch of the mining cycles

Response: Object - object represents the epoch record data section contains all candidate info bad section indicates the kicked out candidate index using section shows the indexes of mining candidate takeover flag marks whether this epoch is takeover by admin dpos flag marks whether dpos is lauched

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_browserEpochRecord","params":[11],"id":1}' http://localhost:8545

// Result

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "data": [
            {
                "candidate": "olivelawrence",
                "holder": "4499999999796592000000000",
                "quantity": "500000000000000000000000",
                "totalQuantity": "5000001",
                "shouldCounter": 38358,
                "actualCounter": 38352,
                "nowShouldCounter": 46806,
                "nowActualCounter": 46791
            },
            ...
        ],
        "bad": [
            3,
            6,
            15,
            16,
            9
        ],
        "using": [
            0,
            1,
            2,
            21,
            4,
            5,
            22,
            7,
            8,
            25,
            10,
            11,
            12,
            13,
            14,
            23,
            24,
            17,
            18,
            19,
            20
        ],
        "takeOver": false,
        "dpos": true
    }
}

dpos_browserVote

Function: query valid candidate of this epoch

Argments:

  1. epoch - epoch of the mining cycles

Response: Object - object represents the epoch record data section contains all valid candidate

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"dpos_browserVote","params":[11],"id":1}' http://localhost:8545

// Result

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "data": [
            {
                "candidate": "olivelawrence",
                "holder": "4499999999796592000000000",
                "quantity": "500000000000000000000000",
                "totalQuantity": "5000001",
                "shouldCounter": 38358,
                "actualCounter": 38352,
                "nowShouldCounter": 46806,
                "nowActualCounter": 46791
            },
            ...
        ],
        "bad": null,
        "using": null,
        "takeOver": false,
        "dpos": false
    }
}

fee_getObjectFeeByName

Function: get fee detail by object's name

Argments:

  1. name - name of the object(asset name, contract name or miner's name)
  2. 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,
		}]
	}
}

fee_getObjectFeeResult

Function: get fee result from a specific id within count number at a given timestamp

Argments: None

  1. startFeeID - the start id(start from 1)
  2. count - the count of results(max 1000)
  3. 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,
			}...]
		}...]
	}
}