Skip to content

JSON RPC

liuji85 edited this page Feb 25, 2019 · 33 revisions

RPC interface


account_accountIsExist

Function:whether an account is exist

Argments:

  1. accountName - Name of the account

params: ['ftsystemio']

Response: true/false

Example:

// Request

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

params: ['ftsystemio']

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":["ftsystemio"],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": {  
		"AcctName": "ftsystemio",  
		"Nonce": 0,  
		"PublicKey": "0x047db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf795962b8cccb87a2eb56b29fbe37d614e2f4c3c45b789ae4f1f51f4cb21972ffd",  
		"Code": "",  
		"CodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",  
		"CodeSize": 0,  
		"Balances": [{  
			"AssetID": 1,  
			"Balance": 200000000000100000000  
		}],  
		"Suicide": false,  
		"Destroy": false  
	}  
}  

account_getCode

Function:get contract code by account name

Argments:

  1. accountName - Name of the account

params: ['ftsystemio']

Response: Contract code

Example:

// Request

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

params: ['ftsystemio']

Response: the value of nonce

Example:

// Request

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

params: ['ftper foundation']

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":["ftper foundation"],"id":1}' http://localhost:8545

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"assetid": 1,
		"assetname": "ftper foundation",
		"symbol": "ft",
		"amount": 100000000,
		"decimals": 18,
		"owner": "ftsystemio"
	}
}

account_getAssetInfoByID

Function: get information of the asset by its id

Argments:

  1. assetID - id of the asset

params: [1]

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

params: [ 'ftsystemio', 1, ]

Response: QUANTITY - current balance(unit:wei).

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"account_getAccountBalanceByID","params":["ftsystemio", 1],"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. time - snapshot time

params: [ 'ftsystemio', 1, 1546054908000000000 ]

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", 1, 1546054908000000000],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": 200000010000  
}

account_getSnapshotLast

Function: get the latest snapshot time

Argments: None

Response: data - latest snapshot time

Example:

// Request

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

// Result

{  
  "id":1,  
  "jsonrpc": "2.0",  
  "result": 1546054908000000000
}  

account_getSnapshotTime

Function: get adjacent snapshot time

Argments:

  1. m - 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 transaction 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":"eth_sendRawTransaction","params":[{see above}],"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

params: [ '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', true ]

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": 132864,
		"extraData": "0x302e312e302d756e737461626c65",
		"gasLimit": 100000000,
		"gasUsed": 23520,
		"hash": "0x99a7eeda1b44e716344a2f7fb57193443cfb8553956b2cb98343510a11785893",
		"logsBloom": "0x0......0",
		"miner": "ftsystemio",
		"mixHash": "0x4dd7358f5c38cf3f88fff2806347d1f1bf06f4fb7886fc017848797d1ec752d8",
		"number": 29,
		"parentHash": "0xde283ba05f581237d303e253bac982e6e9a799f607d2027ed9bf8396aa2107df",
		"receiptsRoot": "0x8505338e394c4e84247daea29174d24d8f2c1ac75b8d5ab6d4088aaf96d10af2",
		"size": 618,
		"stateRoot": "0x9aa45c02e2631efc768811d103c2cc41aa3b5e6d300b888cdf6c3aae35315486",
		"timestamp": 1545796886,
		"totalDifficulty": 3958144,
		"transactions": [{...}],
		"transactionsRoot": "0xb0488864ff51869dc65c8e4adfd28db290c3bce15c0fa717ec834e963792e635"
	}
}

ft_getBlockByNumber

Function:get information of the block by its height

参数:

  1. QUANTITY|TAG - height of the bloack, "latest" or "earliest", "pending"
  2. Boolean - true when returned the entire block information,otherwise only hash of the transactions will be returned

params: [ 10, true ]

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_getTransactionByHash

Function:get information of transaction by its hash value

Argments:

  1. data - the hash value of the transaction

params: [ '0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece' ]

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": "",
			"gasPrice": null,
			"gas": 200000,
			"value": 0,
			"payload": "0xe5808a41737365746e616d65318753796d626f6c31865af3107a40000288746573746e616d65",
			"v": "0x26",
			"r": "0x26bbc51d9fc11ce8ba470bc2a779daa800301b7aba2d544e4ff471b14657bab7",
			"s": "0x568fbae5514d7ead5da8d03bcc17723f1221a75cee289e97dc95da71ad37d2c8",
			"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

params: [ '0x70833157d68177fbd8aede0099a56f9888420852d1449d101d5db8be05fdfece' ]

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": "0xe6a73eea5f21f0c045b3de6f21c728492c91e7f7634d079bd59e324b9964c06c",
		"blockNumber": 16,
		"txHash": "0xcf2ebeccce958496c39b59adf106a7568143f41f72c845dd258c8719d3c15abd",
		"transactionIndex": 0,
		"postState": "0xda5b23e14f3d637b3c92762241d3f48d61a404764c897d6a598d261a11ac5c70",
		"actionResults": [{
			"actionType": 11,
			"status": 1,
			"index": 0,
			"gasUsed": 21000,
			"error": ""
		}],
		"cumulativeGasUsed": 21000,
		"totalGasUsed": 21000,
		"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
		"logs": []
	}
}

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

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

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": {
		"AccountName": "ftsystemdpos",
		"ActivatedMinQuantity": 100,
		"BlockFrequency": 6,
		"BlockInterval": 3000,
		"BlockReward": 1,
		"Decimals": 18,
		"DelayEcho": 18,
		"ExtraBlockReward": 5,
		"MaxURLLen": 512,
		"ProducerMinQuantity": 10,
		"ProducerScheduleSize": 3,
		"SystemName": "ftsystemio",
		"SystemURL": "www.ftper.io",
		"UnitStake": 1000,
		"VoterMinQuantity": 1
	}
}

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": 0,
		"lastIrreversible": 0,
		"proposedIrreversible": 0
	}
}

dpos_epcho

Function:query producer schedule at a certain height

Argments:

  1. height - height of the block

params: [1]

Response: Object - object represents dpos status

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"ActivatedProducerSchedule": ["ftsystemio", "ftsystemio", "ftsystemio"],
		"ActivatedProducerScheduleUpdate": 1546054908000000000,
		"ActivatedTotalQuantity": 0,
		"Height": 1,
		"TotalQuantity": 0
	}
}

dpos_latestEpcho

Function: query producer schedule at latest height

Argments: None

Response: Object - object represents dpos status

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"ActivatedProducerSchedule": ["ftsystemio", "ftsystemio", "ftsystemio"],
		"ActivatedProducerScheduleUpdate": 1546054908000000000,
		"ActivatedTotalQuantity": 0,
		"Height": 76,
		"TotalQuantity": 0
	}
}

dpos_validateEpcho

Function: query producer schedule at valid height

Argments: None

Response: Object - object represents dpos status

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"ActivatedProducerSchedule": ["ftsystemio", "ftsystemio", "ftsystemio"],
		"ActivatedProducerScheduleUpdate": 1546054908000000000,
		"ActivatedTotalQuantity": 0,
		"Height": 39,
		"TotalQuantity": 0
	}
}

dpos_producers

Function:query current producer schedule

Argments: None

Response: the list of current producers

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": [{
		"Height": 0,
		"Name": "ftsystemio",
		"Quantity": 0,
		"TotalQuantity": 0,
		"URL": "www.ftper.io"
	}]
}

miner_start

Function: start mining

Argments: None

Response: null

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": null  
}

miner_stop

Function: stop mining

Argments: None

Response: true

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true  
}

miner_mining

Function: whether current node is mining

Argments: None

Response: true or false

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true  
}

miner_setExtra

Function: set extra data for block sealed by this node

Argments:

  1. extra - extra data,must be less than 32 bytes long

params: ["hello world"]

Response: null

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": null  
}

miner_setCoinbase

Function: set coinbase account

Argments:

  1. name - the name of the account
  2. privkey - a string represents the private key

params: ["miner_account","0x580b61f6ead9d518f0bd02afd53219ca23aaa0a9891f70ae74cf31e1185734dc"]

Response: true

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true  
}

p2p_selfNode

Function: get node address of current node

Argments: None

Response: true

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": "enode://f2f131ec968ff71b41ea49f27e91f607f5d146a33b33b483640586180b51d773d7591366efd6ae38f5bcea07e82ab9373a5631a645575f20bb01a63f13bb79bd@[::]:2018"  
}

p2p_peerCount

Function: get the number of peer nodes

Argments: None

Response: the number of peer nodes

Example:

// Request

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

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": 3
}

p2p_peers

Function: get the node address of peer nodes

Argments: None

Response: list of node address of peers

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": [
		"enode://a7a897e5bc66b3afb4b322123ed754b2b78d59fbaa03252d84adbfa702a792e9b89075118aca82ac9ad1fdfae321cb6c24edf5300b7540cd4d53c0634d62849f@127.0.0.1:50016",
		"enode://e3baaa2ecb33eff02ee99f82fe5b0fc3c2f46e93806bdde972c1f604c207bf6b02925891cfd45d4a258a10d02f992c8f08fecaee15aa55e22b874c967941798b@127.0.0.1:44290",
		"enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"
	]
}

p2p_addPeer

Function: add peer node

Argments:

  1. url - the address of peer node

params: ["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"]

Response: true

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"p2p_addPeer","params":["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true
}

p2p_removePeer

Function: remove peer node

Argments:

  1. url - the address of peer node

params: ["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"]

Response: true

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"p2p_removePeer","params":["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true
}

p2p_addTrustedPeer

Function: add trusted peer node

Argments:

  1. url - the address of peer node

params: ["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"]

Response: true

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"p2p_addTrustedPeer","params":["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true
}

p2p_removeTrustedPeer

Function: remove trusted peer node

Argments:

  1. url - the address of peer node

params: ["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"]

Response: true

Example:

// Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"p2p_removeTrustedPeer","params":["enode://4cc261784f24f1f12b7b5251f2626c4e0749676f18ef03080d3fbdc71644bfa04b9868583f44c1c1a495afa211f4c37329a78c4ce6f04ec19ed5a3ff4a52820d@127.0.0.1:2015"],"id":1}' http://localhost:8545

// Result

{  
	"jsonrpc": "2.0",  
	"id": 1,  
	"result": true
}

txpool_setGasPrice

Function: set gas price for this node

Argments:

  1. gasprice

params: [1000000000]

Response: true

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": true
}

txpool_status

Function: query the status of txpool

Argments: None

Response: the number of transaction in queue and pending

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"pending": 0,
		"queued": 0
	}
}

txpool_content

Function: query the content of txpool

Argments: None

Response: detailed content of queue and pending

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"pending": {},
		"queued": {}
	}
}

keystore_newAccount

Function: create new account

Argments:

  1. passphrase - passphrase for the account

params: ["123456"]

Response: Object - object represents new account

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"address": "0xc2451256f28d0ecf527db1cae00ea0fc4a634f45",
		"path": "/ft_ledger/keystore/UTC--2019-01-24T08-55-23.906261000Z--c2451256f28d0ecf527db1cae00ea0fc4a634f45",
		"privateKey": "0x2d50df41aa1193ac13e9e3aa2fa354505b89761a27392464ad5df91efa1d8d0a",
		"publicKey": "0x04ef05365fa4819f47d4d2e6b212fa670cd4c5153ad526c10bfd91cfcfdfec5615b9c77b5c975074141916a679ea742626896e56a41e918771b796fed0bad375e4"
	}
}

keystore_listAccount

Function: list accounts managed by this node

Argments: None

Response: list of accounts

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": [{
		"address": "0xc2451256f28d0ecf527db1cae00ea0fc4a634f45",
		"path": "/ft_ledger/keystore/UTC--2019-01-24T08-55-23.906261000Z--c2451256f28d0ecf527db1cae00ea0fc4a634f45"
	}, {
		"address": "0x0b98aa38c57cd88ce77c7a5b5b3b18b3b9064271",
		"path": "/ft_ledger/keystore/UTC--2019-01-25T07-59-39.848955000Z--0b98aa38c57cd88ce77c7a5b5b3b18b3b9064271"
	}]
}


keystore_update

Function: modify the passphrase of an account

Argments:

  1. addr - address of the account
  2. passphrase - old passphrase
  3. newPassphrase - new passphrase

params: ["0xc2451256f28d0ecf527db1cae00ea0fc4a634f45","123456","abcdef"]

Response: null

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": null
}

keystore_delete

Function: delete an account

Argments:

  1. addr - address of the account
  2. passphrase - passphrase for the account

params: ["0xc2451256f28d0ecf527db1cae00ea0fc4a634f45","123456"]

Response: null

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": null
}

keystore_exportRawKey

Function: export private key of an account

Argments:

  1. addr - address of the account
  2. passphrase - passphrase for the account

params: ["0xc2451256f28d0ecf527db1cae00ea0fc4a634f45","123456"]

Response: a string represents the private key

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": "0x580b61f6ead9d518f0bd02afd53219ca23aaa0a9891f70ae74cf31e1185734dc"
}

keystore_importRawKey

Function: import a private key and use it to create an account

Argments:

  1. privkey - a string represents the private key
  2. passphrase - passphrase for the account

params: ["580b61f6ead9d518f0bd02afd53219ca23aaa0a9891f70ae74cf31e1185734da","123456"]

Response: the address and path of the account

Example:

// Request

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

// Result

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"address": "0x64877483652ca764a79df7c1834c8c01e96d772b",
		"path": "/ft_ledger/keystore/UTC--2019-01-25T08-58-51.779218000Z--64877483652ca764a79df7c1834c8c01e96d772b"
	}
}