您的位置:首页 > Web前端 > JavaScript

以太坊开发文档08 - JSON-RPC接口

2017-12-14 14:17 549 查看

接口

Javascript控制台:
geth
可以通过交互式控制台启动,该控制台提供了一个JavaScript运行时环境,提供了一个JavaScript API来与您的节点进行交互。Javascript控制台API包含
web3
javascriptÐappAPI以及一个额外的管理API。
JSON-RPC服务器:
geth
可以使用公开JSON-RPC API的json-rpc服务器启动

命令行选项记录命令行参数以及子命令。

命令行选项

geth [global options] command [command options] [arguments...]

VERSION:
1.0.0

COMMANDS:
recover      attempts to recover a corrupted database by setting a new block by number or hash. See help recover.
blocktest    loads a block test file
import       import a blockchain file
export       export blockchain into file
upgradedb    upgrade chainblock database
removedb     Remove blockchain and state databases
dump         dump a specific block from storage
monitor      Geth Monitor: node metrics monitoring and visualization
makedag      generate ethash dag (for testing)
version      print ethereum version numbers
wallet       ethereum presale wallet
account      manage accounts
console      Geth Console: interactive JavaScript environment
attach       Geth Console: interactive JavaScript environment (connect to node)
js           executes the given JavaScript files in the Geth JavaScript VM
help         Shows a list of commands or help for one command

GLOBAL OPTIONS:
--identity                                                           Custom node name
--unlock                                                             Unlock the account given until this program exits (prompts for password). '--unlock n' unlocks the n-th account in order or creation.
--password                                                           Path to password file to use with options and subcommands needing a password
--genesis                                                            Inserts/Overwrites the genesis block (json format)
--bootnodes                                                          Space-separated enode URLs for p2p discovery bootstrap
--datadir "/Users/tron/Library/Ethereum"                             Data directory to be used
--blockchainversion "3"                                              Blockchain version (integer)
--jspath "."                                                         JS library path to be used with console and js subcommands
--port "30303"                                                       Network listening port
--maxpeers "25"                                                      Maximum number of network peers (network disabled if set to 0)
--maxpendpeers "0"                                                   Maximum number of pending connection attempts (defaults used if set to 0)
--etherbase "0"                                                      Public address for block mining rewards. By default the address first created is used
--gasprice "1000000000000"                                           Sets the minimal gasprice when mining transactions
--minerthreads "8"                                                   Number of miner threads
--mine                                                               Enable mining
--autodag                                                            Enable automatic DAG pregeneration
--nat "any"                                                          NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
--natspec                                                            Enable NatSpec confirmation notice
--nodiscover                                                         Disables the peer discovery mechanism (manual peer addition)
--nodekey                                                            P2P node key file
--nodekeyhex                                                         P2P node key as hex (for testing)
--rpc                                                                Enable the JSON-RPC server
--rpcaddr "127.0.0.1"                                                Listening address for the JSON-RPC server
--rpcport "8545"                                                     Port on which the JSON-RPC server should listen
--rpcapi "db,eth,net,web3"                                           Specify the API's which are offered over the HTTP RPC interface
--ipcdisable                                                         Disable the IPC-RPC server
--ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3"     Specify the API's which are offered over the IPC interface
--ipcpath "/Users/tron/Library/Ethereum/geth.ipc"                    Filename for IPC socket/pipe
--exec                                                               Execute javascript statement (only in combination with console/attach)
--shh                                                                Enable whisper
--vmdebug                                                            Virtual Machine debug output
--networkid "1"                                                      Network Id (integer)
--rpccorsdomain                                                      Domain on which to send Access-Control-Allow-Origin header
--verbosity "3"                                                      Logging verbosity: 0-6 (0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=debug detail)
--backtrace_at ":0"                                                  If set to a file and line number (e.g., "block.go:271") holding a logging statement, a stack trace will be logged
--logtostderr                                                        Logs are written to standard error instead of to files.
--vmodule ""                                                         The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the ".go" suffix) or "glob" pattern and N is a log verbosity level.
--logfile                                                            Send log output to a file
--logjson                                                            Send json structured log output to a file or '-' for standard output (default: no json output)
--pprof                                                              Enable the profiling server on localhost
--pprofport "6060"                                                   Port on which the profiler should listen
--metrics                                                            Enables metrics collection and reporting
--solc "solc"                                                        solidity compiler to be used
--gpomin "1000000000000"                                             Minimum suggested gas price
--gpomax "100000000000000"                                           Maximum suggested gas price
--gpofull "80"                                                       Full block threshold for gas price calculation (%)
--gpobasedown "10"                                                   Suggested gas price base step down ratio (1/1000)
--gpobaseup "100"                                                    Suggested gas price base step up ratio (1/1000)
--gpobasecf "110"                                                    Suggested gas price base correction factor (%)
--help, -h                                                           show help

请注意,datadir的默认值是特定于平台的。有关更多信息,请参阅备份和恢复

例子

帐号

请参阅帐户管理
将ether预售钱包导入您的节点(提示输入密码):
geth wallet import /path/to/my/etherwallet.json

将一个EC密钥导入以太坊帐户(提示输入密码):
geth account import /path/to/key.prv

Geth JavaScript运行时环境

请参阅Geth JavaScript控制台
调出geth JavaScript控制台:
geth --verbosity 5 --jspath /mydapp/js console 2>> /path/to/logfile

test.js
使用js API 执行javascript并将Debug级别的消息记录到
/path/to/logfile

geth --verbosity 6 js test.js  2>> /path/to/logfile

导入/导出链和转储块

从文件导入区块链:
geth import blockchain.bin

升级chainblock数据库

当一致性算法改变时,区块链中的块必须重新导入新算法。在需要的时候,Geth会通知用户说明何时以及如何做到这一点。
geth upgradedb

采矿和网络

使用分别侦听端口30303和30304的不同数据目录启动两个挖掘节点:
geth --mine --minerthreads 4 --datadir /usr/local/share/ethereum/30303 --port 30303
geth --mine --minerthreads 4 --datadir /usr/local/share/ethereum/30304 --port 30304

在端口8000上启动一个rpc客户端:
geth --rpc=true --rpcport 8000 --rpccorsdomain '"*"'

无网络启动客户端:
geth --maxpeers 0 --nodiscover --networdid 3301 js justwannarunthis.js

重置区块链

在datadir中,删除blockchain目录。对于上面的例子:
rm -rf /usr/local/share/ethereum/30303/blockchain

测试环境中的示例用法

以下各行仅用于测试网络和非交互式脚本使用的安全环境。
geth --datadir /tmp/eth/42 --password <(echo -n notsosecret) account new 2>> /tmp/eth/42.log
geth --datadir /tmp/eth/42 --port 30342  js <(echo 'console.log(admin.nodeInfo().NodeUrl)') > enode 2>> /tmp/eth/42.log
geth --datadir /tmp/eth/42 --port 30342 --password <(echo -n notsosecret) --unlock primary --minerthreads 4 --mine 2>> /tmp/eth/42.log

连接

将控制台连接到正在运行的geth实例。默认情况下,这发生在默认IPC端点上的IPC上,但是在必要时可以指定一个自定义端点:
geth attach ipc:/some/path
geth attach rpc:http://host:8545

设置标志的其他方法

警告:这不适用于最新的边界。
相同的标志可以通过配置文件(默认
<datadir>/conf.ini
)以及环境变量来设置。
优先级:默认<配置文件<环境变量<命令行

JSON RPC API

JSON是一种轻量级的数据交换格式。它可以表示数字,字符串,有序的值序列以及名称/值对的集合。
JSON-RPC是一种无状态,轻量级的远程过程调用(RPC)协议。这个规范主要定义了几个数据结构和围绕它们处理的规则。它是传输不可知的,因为这些概念可以在同一个进程中,在套接字上,在HTTP上,或在许多不同的消息传递环境中使用。它使用JSON(RFC
4627)作为数据格式。

JavaScript API

要从JavaScript应用程序内部与ethereum节点交谈,请使用web3.js库,该库为RPC方法提供了一个方便的接口。有关更多信息,请参阅JavaScript
API。

JSON-RPC端点

默认的JSON-RPC端点:
C++: http://localhost:8545 Go: http://localhost:8545 Py: http://localhost:4000

GO

您可以使用该
--rpc
标志启动HTTP JSON-RPC
geth --rpc

更改默认端口(8545)和列表地址(本地主机):
geth --rpc --rpcaddr <ip> --rpcport <portnumber>

如果从浏览器访问RPC,则CORS需要启用相应的域集。否则,JavaScript调用受到同源策略的限制,请求将失败:
geth --rpc --rpccorsdomain "http://localhost:3000"

JSON RPC也可以使用该命令从geth控制台启动
admin.startRPC(addr,
port)

C ++

您可以通过
eth
使用
-j
选项运行应用程序来启动它:
./eth -j

您也可以指定JSON-RPC端口(默认为8545):
./eth -j --json-rpc-port 8079

Python

在python中,JSONRPC服务器当前默认启动并侦听 
127.0.0.1:4000

您可以通过提供配置选项来更改端口和监听地址。
pyethapp -c jsonrpc.listen_port=4002 -c jsonrpc.listen_host=127.0.0.2 run

JSON-RPC支持

 CPP-复仇去-复仇PY-复仇
JSON-RPC 1.0  
JSON-RPC 2.0
批量请求
HTTP

输出HEX值

目前有两个通过JSON传递的关键数据类型:未格式化的字节数组和数量。两者都以十六进制编码传递,但对格式要求不同:
当编码QUANTITIES(整数,数字)时:编码为十六进制,前缀为“0x”,最紧凑的表示(略有例外:零应表示为“0x0”)。例子:
0x41(十进制65)
0x400(十进制1024)
错误:0x(应始终至少有一个数字 - 零是“0x0”)
错误:0x0400(不允许前导零)
错误:ff(必须加前缀0x)
编码UNFORMATTED DATA(字节数组,帐户地址,散列,字节码数组)时:编码为十六进制,前缀为“0x”,每个字节两个十六进制数字。例子:
0x41(大小1,“A”)
0x004200(大小3,“\ 0B \ 0”)
0x(大小0,“”)
错误:0xf0f0f(必须是偶数位数)
错误:004200(必须加前缀0x)
目前,cpp-ethereumgo-ethereum仅通过http提供JSON-RPC通信。

默认的块参数

以下方法具有额外的默认块参数:
eth_getBalance
eth_getCode
eth_getTransactionCount
eth_getStorageAt
eth_call
当请求作用于以太坊的状态时,最后的默认块参数决定块的高度。
以下选项可用于defaultBlock参数:
HEX String
 - 一个整数块号码
String "earliest"
 为最早/起源块
String "latest"
 - 为最新的开采块
String "pending"
 - 待处理状态/交易

JSON-RPC方法

web3_clientVersion
web3_sha3
net_version
net_peerCount
net_listening
eth_protocolVersion
eth_syncing
eth_coinbase
eth_mining
eth_hashrate
eth_gasPrice
eth_accounts
eth_blockNumber
eth_getBalance
eth_getStorageAt
eth_getTransactionCount
eth_getBlockTransactionCountByHash
eth_getBlockTransactionCountByNumber
eth_getUncleCountByBlockHash
eth_getUncleCountByBlockNumber
eth_getCode
eth_sign
eth_sendTransaction
eth_sendRawTransaction
eth_call
eth_estimateGas
eth_getBlockByHash
eth_getBlockByNumber
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionReceipt
eth_getUncleByBlockHashAndIndex
eth_getUncleByBlockNumberAndIndex
eth_getCompilers
eth_compileLLL
eth_compileSolidity
eth_compileSerpent
eth_newFilter
eth_newBlockFilter
eth_newPendingTransactionFilter
eth_uninstallFilter
eth_getFilterChanges
eth_getFilterLogs
eth_getLogs
eth_getWork
eth_submitWork
eth_submitHashrate
db_putString
db_getString
db_putHex
db_getHex
shh_post
shh_version
shh_newIdentity
shh_hasIdentity
shh_newGroup
shh_addToGroup
shh_newFilter
shh_uninstallFilter
shh_getFilterChanges
shh_getMessages

JSON RPC API参考

web3_clientVersion

返回当前的客户端版本。
参数
没有

返回
String
 - 当前的客户端版本

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}'

// Result
{
"id":67,
"jsonrpc":"2.0",
"result": "Mist/v0.9.3/darwin/go1.4.1"
}

web3_sha3

返回给定数据的Keccak-256(不是标准化的SHA3-256)。
参数
String
 - 要转换为SHA3哈希的数据
params: [
'0x68656c6c6f20776f726c64'
]

返回
DATA
 - 给定字符串的SHA3结果。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":64}'

// Result
{
"id":64,
"jsonrpc": "2.0",
"result": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
}

net_version

返回当前的网络协议版本。
参数
没有

返回
String
 - 当前的网络协议版本

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'

// Result
{
"id":67,
"jsonrpc": "2.0",
"result": "59"
}

net_listening

true
如果客户端正在主动侦听网络连接,则返回。
参数
没有

返回
Boolean
true
当听时,否则
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":67}'

// Result
{
"id":67,
"jsonrpc":"2.0",
"result":true
}

net_peerCount

返回当前连接到客户端的对端的数量。
参数
没有

返回
QUANTITY
 - 连接对等体的数量的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}'

// Result
{
"id":74,
"jsonrpc": "2.0",
"result": "0x2" // 2
}

eth_protocolVersion

返回当前的ethereum协议版本。
参数
没有

返回
String
 - 当前ethereum协议版本

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_protocolVersion","params":[],"id":67}'

// Result
{
"id":67,
"jsonrpc": "2.0",
"result": "54"
}

eth_syncing

用关于同步状态或FALSE的数据返回一个对象对象。
参数
没有

返回
Object|Boolean
,具有同步状态数据的对象,或者
FALSE
在不同步时:
startingBlock
QUANTITY
- 导入开始的块(只有在同步达到他的头后才会被重置)
currentBlock
QUANTITY
- 当前块,与eth_blockNumber相同
highestBlock
QUANTITY
- 估计的最高区块

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_isSyncing","params":[],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": {
startingBlock: '0x384',
currentBlock: '0x386',
highestBlock: '0x454'
}
}
// Or when not syncing
{
"id":1,
"jsonrpc": "2.0",
"result": false
}

eth_coinbase

返回客户的coinbase地址。
参数
没有

返回
DATA
,20字节 - 当前coinbase地址。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":64}'

// Result
{
"id":64,
"jsonrpc": "2.0",
"result": "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
}

eth_mining

true
如果客户端正在主动挖掘新块,则返回。
参数
没有

返回
Boolean
true
客户的回报是挖矿,否则
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":71}'

// Result
{
"id":71,
"jsonrpc": "2.0",
"result": true
}

eth_hashrate

返回节点正在挖掘的每秒散列数。
参数
没有

返回
QUANTITY
 - 每秒的哈希数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":71}'

// Result
{
"id":71,
"jsonrpc": "2.0",
"result": "0x38a"
}

eth_gasPrice

返回wei中每个气体的当前价格。
参数
没有

返回
QUANTITY
 - 当前天然气价格的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":73}'

// Result
{
"id":73,
"jsonrpc": "2.0",
"result": "0x09184e72a000" // 10000000000000
}

eth_accounts

返回客户端拥有的地址列表。
参数
没有

返回
Array of DATA
,20字节 - 客户拥有的地址。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]
}

eth_blockNumber

返回最近的块的数量。
参数
没有

返回
QUANTITY
 - 客户端所在的当前块号的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'

// Result
{
"id":83,
"jsonrpc": "2.0",
"result": "0x4b7" // 1207
}

eth_getBalance

返回给定地址的帐户的余额。
参数
DATA
,20字节 - 地址检查余额。
QUANTITY|TAG
- 整数块号或字符串
"latest"
"earliest"
或者
"pending"
,请参阅默认块参数
params: [
'0x407d73d8a49eeb85d32cf465507dd71d507100c1',
'latest'
]

返回
QUANTITY
 - wei中当前余额的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x0234c8a3397aab58" // 158972490234375000
}

eth_getStorageAt

返回给定地址的存储位置的值。
参数
DATA
,20字节 - 存储地址。
QUANTITY
 - 存储位置的整数。
QUANTITY|TAG
- 整数块号或字符串
"latest"
"earliest"
或者
"pending"
,请参阅默认块参数
params: [
'0x407d73d8a49eeb85d32cf465507dd71d507100c1',
'0x0', // storage position at 0
'0x2' // state at block number 2
]

返回
DATA
 - 这个存储位置的值。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "0x0", "0x2"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x03"
}

eth_getTransactionCount

返回从地址发送的事务数。
参数
DATA
,20字节 - 地址。
QUANTITY|TAG
- 整数块号或字符串
"latest"
"earliest"
或者
"pending"
,请参阅默认块参数
params: [
'0x407d73d8a49eeb85d32cf465507dd71d507100c1',
'latest' // state at the latest block
]

返回
QUANTITY
 - 从这个地址发送的交易数量的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1","latest"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}

eth_getBlockTransactionCountByHash

从匹配给定块散列的块中返回块中的事务数。
参数
DATA
,32字节 - 块的散列
params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]

返回
QUANTITY
 - 此区块中的交易数量的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xb" // 11
}

eth_getBlockTransactionCountByNumber

从与给定块号匹配的块中返回块中的事务数。
参数
QUANTITY|TAG
- 块号的整数,或字符串
"earliest"
"latest"
或者
"pending"
默认块参数中所示
params: [
'0xe8', // 232
]

返回
QUANTITY
 - 此区块中的交易数量的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0xe8"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xa" // 10
}

eth_getUncleCountByBlockHash

从匹配给定块散列的块中返回块中的叔数。
参数
DATA
,32字节 - 块的散列
params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]

返回
QUANTITY
 - 此块中的叔数的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id"Block:1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}

eth_getUncleCountByBlockNumber

从与给定块编号匹配的块中返回块中的圈数。
参数
QUANTITY
- 块号的整数,或字符串“最新”,“最早”或“挂起”,请参阅默认块参数
params: [
'0xe8', // 232
]

返回
QUANTITY
 - 此块中的叔数的整数。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockNumber","params":["0xe8"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}

eth_getCode

返回给定地址的代码。
参数
DATA
,20字节 - 地址
QUANTITY|TAG
- 整数块号或字符串
"latest"
"earliest"
或者
"pending"
,请参阅默认块参数
params: [
'0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
'0x2'  // 2
]

返回
DATA
 - 来自给定地址的代码。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}

eth_sign

用给定的地址标记数据。
注意签名的地址必须解锁。
参数
DATA
,20字节 - 地址
DATA
,要签署的数据
返回
DATA
:签名的数据

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sign","params":["0xd1ade25ccd3d550a7eb532ac759cac7be09c2719", "Schoolbus"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x2ac19db245478a06032e69cdbd2b54e648b78431d0a47bd1fbab18f79f820ba407466e37adbe9e84541cab97ab7d290f4a64a5825c876d22109f3bf813254e8601"
}

eth_sendTransaction

如果数据字段包含代码,则创建新的消息调用事务或创建合同。
参数
Object
 - 交易对象
from
DATA
,20字节 - 交易的发送地址。
to
DATA
,20字节 - (创建新合同时可选)交易指向的地址。
gas
QUANTITY
 - (可选,默认值:90000)为交易执行提供的天然气的整数。它会返回未使用的气体。
gasPrice
QUANTITY
 - (可选,默认:待确定)每种付费气体使用的gasPrice整数
value
QUANTITY
 - (可选)发送的值与此事务的整数
data
DATA
 - (可选)合同的编译代码
nonce
QUANTITY
 - (可选)一个随机数的整数。这允许覆盖使用相同的随机数的您自己的未决事务。

params: [{
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
"gas": "0x76c0", // 30400,
"gasPrice": "0x9184e72a000", // 10000000000000
"value": "0x9184e72a", // 2441406250
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]

返回
DATA
,32字节 - 事务散列,或者如果事务不可用,则为零散列。
在交易开始后,使用eth_getTransactionReceipt获取合同地址,当您创建合同时。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{see above}],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

eth_sendRawTransaction

创建新的消息调用事务或为签名的事务创建合同。
参数
Object
 - 交易对象
data
DATA
,签署的交易数据。

params: [{
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]

返回
DATA
,32字节 - 事务散列,或者如果事务不可用,则为零散列。
在交易开始后,使用eth_getTransactionReceipt获取合同地址,当您创建合同时。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

eth_call

立即执行新的消息调用,而不在块链上创建事务。
参数
Object
 - 事务调用对象
from
DATA
,20字节 - (可选)交易的发送地址。
to
DATA
,20字节 - 事务处理的地址。
gas
QUANTITY
 - (可选)为交易执行提供的天然气的整数。eth_call消耗零气体,但这个参数可能需要一些执行。
gasPrice
QUANTITY
 - (可选)用于每个付费气体的gasPrice的整数
value
QUANTITY
 - (可选)发送的值与此事务的整数
data
DATA
 - (可选)合同的编译代码

QUANTITY|TAG
- 整数块号或字符串
"latest"
"earliest"
或者
"pending"
,请参阅默认块参数
返回
DATA
 - 执行合同的回报价值。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{see above}],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x0"
}

eth_estimateGas

拨打电话或交易,这些电话或交易不会被添加到区块链中,并返回可用于估算废气的废气。
参数
请参阅eth_call参数,期望所有属性都是可选的。
返回
QUANTITY
 - 使用的气体量。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{see above}],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x5208" // 21000
}

eth_getBlockByHash

通过散列返回有关块的信息。
参数
DATA
,32字节 - 块的散列。
Boolean
- 如果
true
它返回完整的事务对象,则
false
只有事务的哈希值。
params: [
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
true
]

返回
Object
- 块对象,或者
null
没有找到块时:
number
QUANTITY
- 块号。
null
当其挂起的块。
hash
DATA
,32字节 - 块的散列。
null
当其挂起的块。
parentHash
DATA
,32字节 - 父块的散列。
nonce
DATA
,8字节 - 生成的工作量证明的散列值。
null
当其挂起的块。
sha3Uncles
DATA
,32个字节 - 块中的数据。
logsBloom
DATA
,256字节 - 块的日志的布隆过滤器。
null
当其挂起的块。
transactionsRoot
DATA
,32字节 - 块的事务树的根。
stateRoot
DATA
,32字节 - 块的最终状态树的根。
receiptsRoot
DATA
,32字节 - 块的收据特里的根。
miner
DATA
,20 Bytes - 给予采矿奖励的受益人的地址。
difficulty
QUANTITY
- 这个块的难度的整数。
totalDifficulty
QUANTITY
- 直到这个块的链条总难度的整数。
extraData
DATA
- 该块的“额外数据”字段。
size
QUANTITY
- 以字节为单位整数该块的大小。
gasLimit
QUANTITY
- 在这个区块允许的最大的气体。
gasUsed
QUANTITY
- 此区块内所有交易使用的天然气总量。
timestamp
QUANTITY
- 块整理时的unix时间戳。
transactions
Array
- 根据最后给定的参数,事务对象数组或32字节事务散列。
uncles
Array
- 一些叔叔哈希。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
"number": "0x1b4", // 436
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0x027f07", // 163591
"totalDifficulty":  "0x027f07", // 163591
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size":  "0x027f07", // 163591
"gasLimit": "0x9f759", // 653145
"minGasPrice": "0x9f759", // 653145
"gasUsed": "0x9f759", // 653145
"timestamp": "0x54e34e8e" // 1424182926
"transactions": [{...},{ ... }]
"uncles": ["0x1606e5...", "0xd5145a9..."]
}
}

eth_getBlockByNumber

通过块编号返回有关块的信息。
参数
QUANTITY|TAG
- 块号的整数,或字符串
"earliest"
"latest"
或者
"pending"
默认块参数中所示
Boolean
- 如果
true
它返回完整的事务对象,则
false
只有事务的哈希值。
params: [
'0x1b4', // 436
true
]

返回
请参阅eth_getBlockByHash

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}'

结果请参阅eth_getBlockByHash

eth_getTransactionByHash

返回有关事务散列请求的事务的信息。
参数
DATA
,32字节 - 交易的散列
params: [
"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"
]

返回
Object
- 一个交易对象,或者
null
当没有找到交易时:
hash
DATA
,32字节 - 交易的散列。
nonce
QUANTITY
- 发件人在此之前进行的交易次数。
blockHash
DATA
,32字节 - 当这个事务处于
null
挂起状态时,这个事务所在的块的散列。
blockNumber
QUANTITY
- 该交易所在
null
的区号。
transactionIndex
QUANTITY
- 块中交易指标位置的整数。
null
当它待定。
from
DATA
,20字节 - 发件人的地址。
to
DATA
,20字节 - 接收器的地址。
null
当其创建合同交易时。
value
QUANTITY
- 在魏的价值转移。
gasPrice
QUANTITY
- 魏先生提供的天然气价格。
gas
QUANTITY
- 发件人提供的气体。
input
DATA
- 数据与交易一起发送。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
"hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"nonce":"0x",
"blockHash": "0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
"blockNumber": "0x15df", // 5599
"transactionIndex":  "0x1", // 1
"from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1",
"value":"0x7f110" // 520464
"gas": "0x7f110" // 520464
"gasPrice":"0x09184e72a000",
"input":"0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360",
}
}

eth_getTransactionByBlockHashAndIndex

通过块散列和事务索引位置返回有关事务的信息。
参数
DATA
,32字节 - 块的散列。
QUANTITY
 - 交易指标头寸的整数。
params: [
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
'0x0' // 0
]

返回
请参阅eth_getBlockByHash

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":[0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b, "0x0"],"id":1}'

结果请参阅eth_getTransactionByHash

eth_getTransactionByBlockNumberAndIndex

通过块号和交易指标位置返回有关交易的信息。
参数
QUANTITY|TAG
- 块号或字符串
"earliest"
"latest"
或者
"pending"
默认块参数中所示
QUANTITY
 - 交易指标位置。
params: [
'0x29c', // 668
'0x0' // 0
]

返回
请参阅eth_getBlockByHash

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}'

结果请参阅eth_getTransactionByHash

eth_getTransactionReceipt

按事务散列返回事务的接收。
请注意,收据不可用于未完成的交易。
参数
DATA
,32字节 - 交易的散列
params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]

返回
Object
- 交易收据对象,或未
null
找到收据时:
transactionHash
DATA
,32字节 - 交易的散列。
transactionIndex
QUANTITY
- 块中交易指标位置的整数。
blockHash
DATA
,32字节 - 此事务所在块的散列。
blockNumber
QUANTITY
- 此交易所在的区号。
cumulativeGasUsed
QUANTITY
- 该交易在区块中执行时使用的天然气总量。
gasUsed
QUANTITY
- 这一特定交易单独使用的天然气量。
contractAddress
DATA
,20字节 - 创建的合同地址,如果交易是创建合同,则为其他
null

logs
Array
- 该事务生成的日志对象数组。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
transactionHash: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238',
transactionIndex:  '0x1', // 1
blockNumber: '0xb', // 11
blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
cumulativeGasUsed: '0x33bc', // 13244
gasUsed: '0x4dc', // 1244
contractAddress: '0xb60e8dd61c5d32be8058bb8eb970870f07233155' // or null, if none was created
logs: [{
// logs as returned by getFilterLogs, etc.
}, ...]
}
}

eth_getUncleByBlockHashAndIndex

通过哈希和叔叔索引位置返回一个块的叔叔的信息。
参数
DATA
,32字节 - 散列块。
QUANTITY
 - 叔叔的指数位置。
params: [
'0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
'0x0' // 0
]

返回
请参阅eth_getBlockByHash

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],"id":1}'

结果请参阅eth_getBlockByHash
注:叔叔不包含个人交易。

eth_getUncleByBlockNumberAndIndex

通过数字和叔叔索引位置返回一个块的叔叔的信息。
参数
QUANTITY|TAG
- 块号或字符串
"earliest"
"latest"
或者
"pending"
默认块参数中所示
QUANTITY
 - 叔叔的指数位置。
params: [
'0x29c', // 668
'0x0' // 0
]

返回
请参阅eth_getBlockByHash
注:叔叔不包含个人交易。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}'

结果请参阅eth_getBlockByHash

eth_getCompilers

返回客户端中可用编译器的列表。
参数
没有

返回
Array
 - 可用的编译器数组。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCompilers","params":[],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": ["solidity", "lll", "serpent"]
}

eth_compileSolidity

返回编译的固体代码。
参数
String
 - 源代码。
params: [
"contract test { function multiply(uint a) returns(uint d) {   return a * 7;   } }",
]

返回
DATA
 - 编译的源代码。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["contract test { function multiply(uint a) returns(uint d) {   return a * 7;   } }"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": {
"code": "0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056",
"info": {
"source": "contract test {\n   function multiply(uint a) constant returns(uint d) {\n       return a * 7;\n   }\n}\n",
"language": "Solidity",
"languageVersion": "0",
"compilerVersion": "0.9.19",
"abiDefinition": [
{
"constant": true,
"inputs": [
{
"name": "a",
"type": "uint256"
}
],
"name": "multiply",
"outputs": [
{
"name": "d",
"type": "uint256"
}
],
"type": "function"
}
],
"userDoc": {
"methods": {}
},
"developerDoc": {
"methods": {}
}
}

}

eth_compileLLL

返回编译的LLL代码。
参数
String
 - 源代码。
params: [
"(returnlll (suicide (caller)))",
]

返回
DATA
 - 编译的源代码。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["(returnlll (suicide (caller)))"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056" // the compiled source code
}

eth_compileSerpent

返回编译的蛇码。
参数
String
 - 源代码。
params: [
"/* some serpent */",
]

返回
DATA
 - 编译的源代码。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSerpent","params":["/* some serpent */"],"id":1}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056" // the compiled source code
}

eth_newFilter

根据过滤器选项创建过滤器对象,以通知状态何时更改(日志)。要检查状态是否改变,请调用eth_getFilterChanges
参数
Object
 - 过滤器选项:
fromBlock
QUANTITY|TAG
- (可选,默认:
"latest"
)整数块编号,或
"latest"
在过去的开采块或者
"pending"
"earliest"
对于尚未开采的交易。
toBlock
QUANTITY|TAG
- (可选,默认:
"latest"
)整数块编号,或
"latest"
在过去的开采块或者
"pending"
"earliest"
对于尚未开采的交易。
address
DATA|Array
,20字节 - (可选)合同地址或日志应从其发出的地址列表。
topics
Array of DATA
, - (可选)32字节的
DATA
主题数组。

params: [{
"fromBlock": "0x1",
"toBlock": "0x2",
"address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"topics": ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]
}]

返回
QUANTITY
 - 过滤器ID。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0x12341234"]}],"id":73}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}

eth_newBlockFilter

在节点中创建一个过滤器,通知新块到达的时间。要检查状态是否改变,请调用eth_getFilterChanges
参数
没有

返回
QUANTITY
 - 过滤器ID。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":73}'

// Result
{
"id":1,
"jsonrpc":  "2.0",
"result": "0x1" // 1
}

eth_newPendingTransactionFilter

在节点中创建一个过滤器,以便在新的未决事务到达时进行通知。要检查状态是否改变,请调用eth_getFilterChanges
参数
没有

返回
QUANTITY
 - 过滤器ID。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":73}'

// Result
{
"id":1,
"jsonrpc":  "2.0",
"result": "0x1" // 1
}

eth_uninstallFilter

卸载给定ID的过滤器。当不再需要手表时,应该始终调用。Additonally过滤一段时间没有被eth_getFilterChanges请求的超时。
参数
QUANTITY
 - 过滤器ID。
params: [
"0xb" // 11
]

返回
Boolean
true
如果过滤器被成功卸载,否则
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0xb"],"id":73}'

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

eth_getFilterChanges

轮询方法,用于返回自上次轮询以来发生的日志数组。
参数
QUANTITY
 - 过滤器ID。
params: [
"0x16" // 22
]

返回
Array
 - 日志对象数组,或者自上次轮询以来没有任何更改的空数组。
对于使用
eth_newBlockFilter
返回创建的过滤器是块哈希(
DATA
32字节),例如
["0x3454645634534..."]

对于使用
eth_newPendingTransactionFilter
return 创建的过滤器,是事务散列(
DATA
例如32字节)
["0x6345343454645..."]


eth_newFilter
日志创建的过滤器是具有以下参数的对象:
type
TAG
pending
日志未决时。
mined
如果日志已经被开采了。
logIndex
QUANTITY
- 块中日志索引位置的整数。
null
当其挂起的日志。
transactionIndex
QUANTITY
- 整数交易指标头寸日志是从中创建的。
null
当其挂起的日志。
transactionHash
DATA
,32字节 - 创建此日志的事务的散列值。
null
当其挂起的日志。
blockHash
DATA
,32字节 - 这个日志所在的块的哈希
null
null
当其挂起的日志。
blockNumber
QUANTITY
null
当其挂起时,该日志所在的块号。
null
当其挂起的日志。
address
DATA
,20字节 - 这个日志来自的地址。
data
DATA
- 包含日志的一个或多个32字节的非索引参数。
topics
Array of DATA
DATA
索引日志参数0到4 32字节的数组。(稳固性:第一个主题是事件签名的散列(例如
Deposit(address,bytes32,uint256)
),除了用说明
anonymous
符声明事件)。


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x16"],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": [{
"logIndex": "0x1", // 1
"blockNumber":"0x1b4" // 436
"blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"transactionHash":  "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
"transactionIndex": "0x0", // 0
"address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"data":"0x0000000000000000000000000000000000000000000000000000000000000000",
"topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"]
},{
...
}]
}

eth_getFilterLogs

返回匹配具有给定id的过滤器的所有日志的数组。
参数
QUANTITY
 - 过滤器ID。
params: [
"0x16" // 22
]

返回
请参阅eth_getFilterChanges

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x16"],"id":74}'

结果请参阅eth_getFilterChanges

eth_getLogs

返回与给定过滤器对象匹配的所有日志的数组。
参数
Object
- 过滤器对象,请参阅eth_newFilter参数
params: [{
"topics": ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]
}]

返回
请参阅eth_getFilterChanges

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}],"id":74}'

结果请参阅eth_getFilterChanges

eth_getWork

返回当前块的散列,seedHash和要满足的边界条件(“target”)。
参数
没有

返回
Array
 - 具有以下属性的数组:
DATA
,32字节 - 当前块标题pow-hash
DATA
,32字节 - 用于DAG的种子散列。
DATA
,32字节 - 边界条件(“目标”),2 ^ 256 /难度。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getWork","params":[],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0x5EED00000000000000000000000000005EED0000000000000000000000000000",
"0xd1ff1c01710000000000000000000000d1ff1c01710000000000000000000000"
]
}

eth_submitWork

用于提交工作证明解决方案。
参数
DATA
,8字节 - 发现的现时(64位)
DATA
,32字节 - 头部的pow-hash(256位)
DATA
,32字节 - 混合摘要(256位)
params: [
"0x0000000000000001",
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000"
]

返回
Boolean
true
如果提供的解决方案有效则返回,否则返回
false


// Request
curl -X POST --data '{"jsonrpc":"2.0", "method":"eth_submitWork", "params":["0x0000000000000001", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000D1GE5700000000000000000000000000"],"id":73}'

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

eth_submitHashrate

用于提交挖掘哈希率。
参数
Hashrate
,哈希率的十六进制字符串表示(32字节)
ID
,字符串 - 标识客户端的随机十六进制(32字节)标识
params: [
"0x0000000000000000000000000000000000000000000000000000000000500000",
"0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"
]

返回
Boolean
true
如果提交成功,
false
否则返回。

// Request
curl -X POST --data '{"jsonrpc":"2.0", "method":"eth_submitHashrate", "params":["0x0000000000000000000000000000000000000000000000000000000000500000", "0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"],"id":73}'

// Result
{
"id":73,
"jsonrpc":"2.0",
"result": true
}

db_putString

在本地数据库中存储一个字符串。
请注意,此功能已被弃用,将来会被删除。
参数
String
 - 数据库名称。
String
 - 重要名称
String
 - 要存储的字符串。
params: [
"testDB",
"myKey",
"myString"
]

返回
Boolean
true
如果值被存储则返回,否则返回
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"db_putString","params":["testDB","myKey","myString"],"id":73}'

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

db_getString

从本地数据库返回字符串。
请注意,此功能已被弃用,将来会被删除。
参数
String
 - 数据库名称。
String
 - 重要名称
params: [
"testDB",
"myKey",
]

返回
String
 - 以前存储的字符串。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"db_getString","params":["testDB","myKey"],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": "myString"
}

db_putHex

将二进制数据存储在本地数据库中。
请注意,此功能已被弃用,将来会被删除。
参数
String
 - 数据库名称。
String
 - 重要名称
DATA
 - 要存储的数据。
params: [
"testDB",
"myKey",
"0x68656c6c6f20776f726c64"
]

返回
Boolean
true
如果值被存储则返回,否则返回
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"db_putHex","params":["testDB","myKey","0x68656c6c6f20776f726c64"],"id":73}'

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

db_getHex

从本地数据库返回二进制数据。
请注意,此功能已被弃用,将来会被删除。
参数
String
 - 数据库名称。
String
 - 重要名称
params: [
"testDB",
"myKey",
]

返回
DATA
 - 以前存储的数据。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"db_getHex","params":["testDB","myKey"],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": "0x68656c6c6f20776f726c64"
}

shh_version

返回当前耳语协议版本。
参数
没有

返回
String
 - 当前耳语协议版本

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_version","params":[],"id":67}'

// Result
{
"id":67,
"jsonrpc": "2.0",
"result": "2"
}

shh_post

发送悄悄话消息。
参数
Object
 - 耳语后物体:
from
DATA
,60字节 - (可选)发件人的身份。
to
DATA
,60字节 - (可选)接收方的身份。当耳语将加密的消息,只有接收者可以解密它。
topics
Array of DATA
DATA
主题数组,供接收者识别消息。
payload
DATA
- 消息的有效载荷。
priority
QUANTITY
- 从...(?)开始的优先级的整数。
ttl
QUANTITY
- 以秒为单位的整数时间。

params: [{
from: "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1",
to: "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1",
topics: ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
payload: "0x7b2274797065223a226d6",
priority: "0x64",
ttl: "0x64",
}]

返回
Boolean
true
如果消息发送,则返回;否则
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_post","params":[{"from":"0xc931d93e97ab07fe42d923478ba2465f2..","topics": ["0x68656c6c6f20776f726c64"],"payload":"0x68656c6c6f20776f726c64","ttl":0x64,"priority":0x64}],"id":73}'

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

shh_newIdentity

在客户端创建新的耳语身份。
参数
没有

返回
DATA
,60字节 - 新的身份的地址。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_newIdentity","params":[],"id":73}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xc931d93e97ab07fe42d923478ba2465f283f440fd6cabea4dd7a2c807108f651b7135d1d6ca9007d5b68aa497e4619ac10aa3b27726e1863c1fd9b570d99bbaf"
}

shh_hasIdentity

检查客户是否持有给定身份的私钥。
参数
DATA
,60字节 - 要检查的身份地址。
params: [
"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"
]

返回
Boolean
true
如果客户端持有该身份的私钥,则返回;否则返回
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_hasIdentity","params":["0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"],"id":73}'

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

shh_newGroup

(?)

参数
没有

返回
DATA
,60字节 - 新组的地址。(?)

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_newIdentity","params":[],"id":73}'

// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0xc65f283f440fd6cabea4dd7a2c807108f651b7135d1d6ca90931d93e97ab07fe42d923478ba2407d5b68aa497e4619ac10aa3b27726e1863c1fd9b570d99bbaf"
}

shh_addToGroup

(?)

参数
DATA
,60字节 - 要添加到组(?)的身份地址。
params: [
"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"
]

返回
Boolean
true
如果身份已成功添加到组中,则返回;否则
false
(?)。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_hasIdentity","params":["0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"],"id":73}'

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

shh_newFilter

创建过滤器来通知,当客户端收到耳语消息匹配的过滤器选项。
参数
Object
 - 过滤器选项:
to
DATA
,60字节 - (可选)接收者的身份。如果存在,它将尝试解密任何传入的消息,如果客户端持有这个身份的私钥。
topics
Array of DATA
DATA
传入消息的主题应匹配的主题数组。您可以使用以下组合:
[A, B] = A && B

[A, [B, C]] = A && (B || C)

[null, A, B] = ANYTHING && A && B
 
null
 作为通配符工作

params: [{
"topics": ['0x12341234bf4b564f'],
"to": "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"
}]

返回
QUANTITY
 - 新创建的过滤器。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_newFilter","params":[{"topics": ['0x12341234bf4b564f'],"to": "0x2341234bf4b2341234bf4b564f..."}],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": "0x7" // 7
}

shh_uninstallFilter

卸载给定ID的过滤器。当不再需要手表时,应该始终调用。Additonally在没有使用shh_getFilterChanges一段时间请求时过滤超时。
参数
QUANTITY
 - 过滤器ID。
params: [
"0x7" // 7
]

返回
Boolean
true
如果过滤器被成功卸载,否则
false


// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_uninstallFilter","params":["0x7"],"id":73}'

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

shh_getFilterChanges

轮询过滤器的轮询方法。自上次调用此方法以来返回新消息。
请注意,调用shh_getMessages方法将重置此方法的缓冲区,以便您不会收到重复的消息。
参数
QUANTITY
 - 过滤器ID。
params: [
"0x7" // 7
]

返回
Array
 - 自上次投票以来收到的消息数组:
hash
DATA
,32字节(?) - 消息的散列。
from
DATA
,60字节 - 邮件的发件人,如果指定了发件人。
to
DATA
,60字节 - 消息的接收者,如果指定了接收者。
expiry
QUANTITY
- 此消息应该过期的时间(秒)的整数(?)。
ttl
QUANTITY
- 消息在系统中以秒(?)为单位浮动的时间的整数。
sent
QUANTITY
- 消息发送时的unix时间戳的整数。
topics
Array of DATA
DATA
消息包含的主题数组。
payload
DATA
- 消息的有效载荷。
workProved
QUANTITY
- 这个消息在发送之前需要的整数(?)。

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_getFilterChanges","params":["0x7"],"id":73}'

// Result
{
"id":1,
"jsonrpc":"2.0",
"result": [{
"hash": "0x33eb2da77bf3527e28f8bf493650b1879b08c4f2a362beae4ba2f71bafcd91f9",
"from": "0x3ec052fc33..",
"to": "0x87gdf76g8d7fgdfg...",
"expiry": "0x54caa50a", // 1422566666
"sent": "0x54ca9ea2", // 1422565026
"ttl": "0x64" // 100
"topics": ["0x6578616d"],
"payload": "0x7b2274797065223a226d657373616765222c2263686...",
"workProved": "0x0"
}]
}

shh_getMessages

获取匹配过滤器的所有消息,这些消息仍然存在于节点的缓冲区中。
注意调用这个方法,也会重置shh_getFilterChanges方法的缓冲区,这样你就不会收到重复的消息。
参数
QUANTITY
 - 过滤器ID。
params: [
"0x7" // 7
]

返回
请参阅shh_getFilterChanges

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"shh_getMessages","params":["0x7"],"id":73}'

结果请参阅shh_getFilterChanges
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: