diff --git a/.gitignore b/.gitignore index 12c734dec0..4af39b13a5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ build/_vendor/pkg /build/_workspace/ /build/cache/ /build/bin/ +/build/static/ /geth*.zip # travis @@ -54,4 +55,4 @@ les/transactions.rlp # Files generated by docs build /MANIFEST /manifest.json -/site \ No newline at end of file +/site diff --git a/Makefile b/Makefile index c83ec21ac0..843525476c 100644 --- a/Makefile +++ b/Makefile @@ -131,6 +131,9 @@ clean: clean-evmc mkdocs-serve: ## Serve generated documentation (during development) @build/mkdocs-serve.sh +docs-generate: ## Generate JSON RPC API documentation from the OpenRPC service discovery document. + env COREGETH_GEN_OPENRPC_DOCS=on go test -count=1 -run BuildStatic ./ethclient + # The devtools target installs tools required for 'go generate'. # You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'. diff --git a/docs/apis/jsonrpc-apis.md b/docs/JSON-RPC-API/index.md similarity index 99% rename from docs/apis/jsonrpc-apis.md rename to docs/JSON-RPC-API/index.md index 771b8652e3..3a04e01f10 100644 --- a/docs/apis/jsonrpc-apis.md +++ b/docs/JSON-RPC-API/index.md @@ -3,7 +3,7 @@ hide: - toc # Hide table of contents --- -# JSON-RPC APIs +# Using JSON-RPC APIs ## Programmatically interfacing `geth` nodes diff --git a/docs/JSON-RPC-API/modules/admin.md b/docs/JSON-RPC-API/modules/admin.md new file mode 100755 index 0000000000..75a9bd20e8 --- /dev/null +++ b/docs/JSON-RPC-API/modules/admin.md @@ -0,0 +1,1650 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### admin_addPeer + +AddPeer requests connecting to a remote node, and also maintaining the new +connection at all times, even reconnecting if it is lost. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_addPeer", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.addPeer(url); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) AddPeer(url string) (bool, error) { + server := api.node.Server() + if server == nil { + return false, ErrNodeStopped + } + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.AddPeer(node) + return true, nil +}// AddPeer requests connecting to a remote node, and also maintaining the new +// connection at all times, even reconnecting if it is lost. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_addTrustedPeer + +AddTrustedPeer allows a remote node to always connect, even if slots are full + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_addTrustedPeer", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.addTrustedPeer(url); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) AddTrustedPeer(url string) (bool, error) { + server := api.node.Server() + if server == nil { + return false, ErrNodeStopped + } + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.AddTrustedPeer(node) + return true, nil +}// AddTrustedPeer allows a remote node to always connect, even if slots are full + +``` +View on GitHub → +

+
+ +--- + + + +### admin_datadir + +Datadir retrieves the current data directory the node is using. + + +#### Params (0) + +_None_ + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_datadir", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.datadir(); + ``` + + +
Source code +

+```go +func (api *publicAdminAPI) Datadir() string { + return api.node.DataDir() +}// Datadir retrieves the current data directory the node is using. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_ecbp1100 + + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_ecbp1100", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.ecbp1100(blockNr); + ``` + + +
Source code +

+```go +func (api *PrivateAdminAPI) Ecbp1100(blockNr rpc.BlockNumber) (bool, error) { + i := uint64(blockNr.Int64()) + err := api.eth.blockchain.Config().SetECBP1100Transition(&i) + return api.eth.blockchain.IsArtificialFinalityEnabled() && api.eth.blockchain.Config().IsEnabled(api.eth.blockchain.Config().GetECBP1100Transition, api.eth.blockchain.CurrentBlock().Number()), err +} +``` +View on GitHub → +

+
+ +--- + + + +### admin_exportChain + +ExportChain exports the current blockchain into a local file, +or a range of blocks if first and last are non-nil + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +first *uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +last *uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_exportChain", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + admin.exportChain(file,first,last); + ``` + + +
Source code +

+```go +func (api *PrivateAdminAPI) ExportChain(file string, first *uint64, last *uint64) (bool, error) { + if first == nil && last != nil { + return false, errors.New("last cannot be specified without first") + } + if first != nil && last == nil { + head := api.eth.BlockChain().CurrentHeader().Number.Uint64() + last = &head + } + if _, err := os.Stat(file); err == nil { + return false, errors.New("location would overwrite an existing file") + } + out, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) + if err != nil { + return false, err + } + defer out.Close() + var writer io.Writer = out + if strings.HasSuffix(file, ".gz") { + writer = gzip.NewWriter(writer) + defer writer.(*gzip.Writer).Close() + } + if first != nil { + if err := api.eth.BlockChain().ExportN(writer, *first, *last); err != nil { + return false, err + } + } else if err := api.eth.BlockChain().Export(writer); err != nil { + return false, err + } + return true, nil +}// ExportChain exports the current blockchain into a local file, +// or a range of blocks if first and last are non-nil + +``` +View on GitHub → +

+
+ +--- + + + +### admin_importChain + +ImportChain imports a blockchain from a local file. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_importChain", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.importChain(file); + ``` + + +
Source code +

+```go +func (api *PrivateAdminAPI) ImportChain(file string) (bool, error) { + in, err := os.Open(file) + if err != nil { + return false, err + } + defer in.Close() + var reader io.Reader = in + if strings.HasSuffix(file, ".gz") { + if reader, err = gzip.NewReader(reader); err != nil { + return false, err + } + } + stream := rlp.NewStream(reader, 0) + blocks, index := make([ // ImportChain imports a blockchain from a local file. + ]*types.Block, 0, 2500), 0 + for batch := 0; ; batch++ { + for len(blocks) < cap(blocks) { + block := new(types.Block) + if err := stream.Decode(block); err == io.EOF { + break + } else if err != nil { + return false, fmt.Errorf("block %d: failed to parse: %v", index, err) + } + blocks = append(blocks, block) + index++ + } + if len(blocks) == 0 { + break + } + if hasAllBlocks(api.eth.BlockChain(), blocks) { + blocks = blocks[:0] + continue + } + if _, err := api.eth.BlockChain().InsertChain(blocks); err != nil { + return false, fmt.Errorf("batch %d: failed to insert: %v", batch, err) + } + blocks = blocks[:0] + } + return true, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### admin_maxPeers + +MaxPeers sets the maximum peer limit for the protocol manager and the p2p server. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +n int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_maxPeers", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.maxPeers(n); + ``` + + +
Source code +

+```go +func (api *PrivateAdminAPI) MaxPeers(n int) (bool, error) { + api.eth.protocolManager.maxPeers = n + api.eth.p2pServer.MaxPeers = n + for i := api.eth.protocolManager.peers.Len(); i > n; i = api.eth.protocolManager.peers.Len() { + p := api.eth.protocolManager.peers.WorstPeer() + if p == nil { + break + } + api.eth.protocolManager.removePeer(p.id) + } + return true, nil +}// MaxPeers sets the maximum peer limit for the protocol manager and the p2p server. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_nodeInfo + +NodeInfo retrieves all the information we know about the host node at the +protocol granularity. + + +#### Params (0) + +_None_ + +#### Result + + + + +*p2p.NodeInfo + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - enode: + - type: `string` + + - enr: + - type: `string` + + - id: + - type: `string` + + - ip: + - type: `string` + + - listenAddr: + - type: `string` + + - name: + - type: `string` + + - ports: + - additionalProperties: `false` + - properties: + - discovery: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - listener: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: `object` + + - protocols: + - additionalProperties: `false` + - properties: + - discovery: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - listener: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "enode": { + "type": "string" + }, + "enr": { + "type": "string" + }, + "id": { + "type": "string" + }, + "ip": { + "type": "string" + }, + "listenAddr": { + "type": "string" + }, + "name": { + "type": "string" + }, + "ports": { + "additionalProperties": false, + "properties": { + "discovery": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "listener": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": "object" + }, + "protocols": { + "additionalProperties": false, + "properties": { + "discovery": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "listener": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_nodeInfo", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.nodeInfo(); + ``` + + +
Source code +

+```go +func (api *publicAdminAPI) NodeInfo() (*p2p.NodeInfo, error) { + server := api.node.Server() + if server == nil { + return nil, ErrNodeStopped + } + return server.NodeInfo(), nil +}// NodeInfo retrieves all the information we know about the host node at the +// protocol granularity. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_peers + +Peers retrieves all the information we know about each individual peer at the +protocol granularity. + + +#### Params (0) + +_None_ + +#### Result + + + +p2pPeerInfo []*p2p.PeerInfo + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - caps: + - items: + - type: `string` + + - type: `array` + + - enode: + - type: `string` + + - enr: + - type: `string` + + - id: + - type: `string` + + - name: + - type: `string` + + - network: + - additionalProperties: `false` + - properties: + - inbound: + - type: `boolean` + + - localAddress: + - type: `string` + + - remoteAddress: + - type: `string` + + - static: + - type: `boolean` + + - trusted: + - type: `boolean` + + + - type: `object` + + - protocols: + - additionalProperties: `false` + - properties: + - inbound: + - type: `boolean` + + - localAddress: + - type: `string` + + - remoteAddress: + - type: `string` + + - static: + - type: `boolean` + + - trusted: + - type: `boolean` + + + - type: `object` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "caps": { + "items": { + "type": "string" + }, + "type": "array" + }, + "enode": { + "type": "string" + }, + "enr": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "network": { + "additionalProperties": false, + "properties": { + "inbound": { + "type": "boolean" + }, + "localAddress": { + "type": "string" + }, + "remoteAddress": { + "type": "string" + }, + "static": { + "type": "boolean" + }, + "trusted": { + "type": "boolean" + } + }, + "type": "object" + }, + "protocols": { + "additionalProperties": false, + "properties": { + "inbound": { + "type": "boolean" + }, + "localAddress": { + "type": "string" + }, + "remoteAddress": { + "type": "string" + }, + "static": { + "type": "boolean" + }, + "trusted": { + "type": "boolean" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_peers", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.peers(); + ``` + + +
Source code +

+```go +func (api *publicAdminAPI) Peers() ([ // Peers retrieves all the information we know about each individual peer at the +// protocol granularity. +]*p2p.PeerInfo, error) { + server := api.node.Server() + if server == nil { + return nil, ErrNodeStopped + } + return server.PeersInfo(), nil +} +``` +View on GitHub → +

+
+ +--- + + + +### admin_removePeer + +RemovePeer disconnects from a remote node if the connection exists + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_removePeer", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.removePeer(url); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) RemovePeer(url string) (bool, error) { + server := api.node.Server() + if server == nil { + return false, ErrNodeStopped + } + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.RemovePeer(node) + return true, nil +}// RemovePeer disconnects from a remote node if the connection exists + +``` +View on GitHub → +

+
+ +--- + + + +### admin_removeTrustedPeer + +RemoveTrustedPeer removes a remote node from the trusted peer set, but it +does not disconnect it automatically. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_removeTrustedPeer", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.removeTrustedPeer(url); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) RemoveTrustedPeer(url string) (bool, error) { + server := api.node.Server() + if server == nil { + return false, ErrNodeStopped + } + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.RemoveTrustedPeer(node) + return true, nil +}// RemoveTrustedPeer removes a remote node from the trusted peer set, but it +// does not disconnect it automatically. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_startRPC + +StartRPC starts the HTTP RPC API server. + + +#### Params (5) + +Parameters must be given _by position_. + + +__1:__ +host *string + + + Required: ✓ Yes + + + + + +__2:__ +port *int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +cors *string + + + Required: ✓ Yes + + + + + +__4:__ +apis *string + + + Required: ✓ Yes + + + + + +__5:__ +vhosts *string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_startRPC", "params": [, , , , ]}' + ``` + +=== "Javascript Console" + + ``` js + admin.startRPC(host,port,cors,apis,vhosts); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error) { + api.node.lock.Lock() + defer api.node.lock.Unlock() + if host == nil { + h := DefaultHTTPHost + if api.node.config.HTTPHost != "" { + h = api.node.config.HTTPHost + } + host = &h + } + if port == nil { + port = &api.node.config.HTTPPort + } + config := httpConfig{CorsAllowedOrigins: api.node.config.HTTPCors, Vhosts: api.node.config.HTTPVirtualHosts, Modules: api.node.config.HTTPModules} + if cors != nil { + config.CorsAllowedOrigins = nil + for _, origin := // StartRPC starts the HTTP RPC API server. + range strings.Split(*cors, ",") { + config.CorsAllowedOrigins = append(config.CorsAllowedOrigins, strings.TrimSpace(origin)) + } + } + if vhosts != nil { + config.Vhosts = nil + for _, vhost := range strings.Split(*host, ",") { + config.Vhosts = append(config.Vhosts, strings.TrimSpace(vhost)) + } + } + if apis != nil { + config.Modules = nil + for _, m := range strings.Split(*apis, ",") { + config.Modules = append(config.Modules, strings.TrimSpace(m)) + } + } + if err := api.node.http.setListenAddr(*host, *port); err != nil { + return false, err + } + if err := api.node.http.enableRPC(api.node.rpcAPIs, config); err != nil { + return false, err + } + if err := api.node.http.start(); err != nil { + return false, err + } + return true, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### admin_startWS + +StartWS starts the websocket RPC API server. + + +#### Params (4) + +Parameters must be given _by position_. + + +__1:__ +host *string + + + Required: ✓ Yes + + + + + +__2:__ +port *int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +allowedOrigins *string + + + Required: ✓ Yes + + + + + +__4:__ +apis *string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_startWS", "params": [, , , ]}' + ``` + +=== "Javascript Console" + + ``` js + admin.startWS(host,port,allowedOrigins,apis); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error) { + api.node.lock.Lock() + defer api.node.lock.Unlock() + if host == nil { + h := DefaultWSHost + if api.node.config.WSHost != "" { + h = api.node.config.WSHost + } + host = &h + } + if port == nil { + port = &api.node.config.WSPort + } + config := wsConfig{Modules: api.node.config.WSModules, Origins: api.node.config.WSOrigins} + if apis != nil { + config.Modules = nil + for _, m := // StartWS starts the websocket RPC API server. + range strings.Split(*apis, ",") { + config.Modules = append(config.Modules, strings.TrimSpace(m)) + } + } + if allowedOrigins != nil { + config.Origins = nil + for _, origin := range strings.Split(*allowedOrigins, ",") { + config.Origins = append(config.Origins, strings.TrimSpace(origin)) + } + } + server := api.node.wsServerForPort(*port) + if err := server.setListenAddr(*host, *port); err != nil { + return false, err + } + if err := server.enableWS(api.node.rpcAPIs, config); err != nil { + return false, err + } + if err := server.start(); err != nil { + return false, err + } + api.node.http.log.Info("WebSocket endpoint opened", "url", api.node.WSEndpoint()) + return true, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### admin_stopRPC + +StopRPC shuts down the HTTP server. + + +#### Params (0) + +_None_ + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_stopRPC", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.stopRPC(); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) StopRPC() (bool, error) { + api.node.http.stop() + return true, nil +}// StopRPC shuts down the HTTP server. + +``` +View on GitHub → +

+
+ +--- + + + +### admin_stopWS + +StopWS terminates all WebSocket servers. + + +#### Params (0) + +_None_ + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "admin_stopWS", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + admin.stopWS(); + ``` + + +
Source code +

+```go +func (api *privateAdminAPI) StopWS() (bool, error) { + api.node.http.stopWS() + api.node.ws.stop() + return true, nil +}// StopWS terminates all WebSocket servers. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/debug.md b/docs/JSON-RPC-API/modules/debug.md new file mode 100755 index 0000000000..ecf15d36ad --- /dev/null +++ b/docs/JSON-RPC-API/modules/debug.md @@ -0,0 +1,6659 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### debug_accountRange + +AccountRange enumerates all accounts in the given block and start point in paging request + + +#### Params (6) + +Parameters must be given _by position_. + + +__1:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + +__2:__ +start []byte + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a variable length byte array` + - pattern: `^0x([a-fA-F0-9]?)+$` + - title: `bytes` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a variable length byte array", + "pattern": "^0x([a-fA-F0-9]?)+$", + "title": "bytes", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +maxResults int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__4:__ +nocode bool + + + Required: ✓ Yes + + + + + +__5:__ +nostorage bool + + + Required: ✓ Yes + + + + + +__6:__ +incompletes bool + + + Required: ✓ Yes + + + + + + +#### Result + + + + +state.IteratorDump + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - accounts: + - patternProperties: + - .*: + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - balance: + - type: `string` + + - code: + - type: `string` + + - codeHash: + - type: `string` + + - key: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - root: + - type: `string` + + - storage: + - patternProperties: + - .*: + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: `object` + + - next: + - pattern: `^0x([a-fA-F0-9]?)+$` + - title: `bytes` + - type: `string` + + - root: + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "accounts": { + "patternProperties": { + ".*": { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "balance": { + "type": "string" + }, + "code": { + "type": "string" + }, + "codeHash": { + "type": "string" + }, + "key": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "root": { + "type": "string" + }, + "storage": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "next": { + "pattern": "^0x([a-fA-F0-9]?)+$", + "title": "bytes", + "type": "string" + }, + "root": { + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_accountRange", "params": [, , , , , ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.accountRange(blockNrOrHash,start,maxResults,nocode,nostorage,incompletes); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start [ // AccountRange enumerates all accounts in the given block and start point in paging request +]byte, maxResults int, nocode, nostorage, incompletes bool) (state.IteratorDump, error) { + var stateDb *state.StateDB + var err error + if number, ok := blockNrOrHash.Number(); ok { + if number == rpc.PendingBlockNumber { + _, stateDb = api.eth.miner.Pending() + } else { + var block *types.Block + if number == rpc.LatestBlockNumber { + block = api.eth.blockchain.CurrentBlock() + } else { + block = api.eth.blockchain.GetBlockByNumber(uint64(number)) + } + if block == nil { + return state.IteratorDump{}, fmt.Errorf("block #%d not found", number) + } + stateDb, err = api.eth.BlockChain().StateAt(block.Root()) + if err != nil { + return state.IteratorDump{}, err + } + } + } else if hash, ok := blockNrOrHash.Hash(); ok { + block := api.eth.blockchain.GetBlockByHash(hash) + if block == nil { + return state.IteratorDump{}, fmt.Errorf("block %s not found", hash.Hex()) + } + stateDb, err = api.eth.BlockChain().StateAt(block.Root()) + if err != nil { + return state.IteratorDump{}, err + } + } else { + return state.IteratorDump{}, errors.New("either block number or block hash must be specified") + } + if maxResults > AccountRangeMaxResults || maxResults <= 0 { + maxResults = AccountRangeMaxResults + } + return stateDb.IteratorDump(nocode, nostorage, incompletes, start, maxResults), nil +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_backtraceAt + +BacktraceAt sets the log backtrace location. See package log for details on +the pattern syntax. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +location string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_backtraceAt", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.backtraceAt(location); + ``` + + +
Source code +

+```go +func (*HandlerT) BacktraceAt(location string) error { + return glogger.BacktraceAt(location) +}// BacktraceAt sets the log backtrace location. See package log for details on +// the pattern syntax. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_blockProfile + +BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to +file. It uses a profile rate of 1 for most accurate information. If a different rate is +desired, set the rate and write the profile manually. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +nsec uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_blockProfile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.blockProfile(file,nsec); + ``` + + +
Source code +

+```go +func (*HandlerT) BlockProfile(file string, nsec uint) error { + runtime.SetBlockProfileRate(1) + time.Sleep(time.Duration(nsec) * time.Second) + defer runtime.SetBlockProfileRate(0) + return writeProfile("block", file) +}// BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to +// file. It uses a profile rate of 1 for most accurate information. If a different rate is +// desired, set the rate and write the profile manually. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_chaindbCompact + +ChaindbCompact flattens the entire key-value database into a single level, +removing all unused slots and merging all keys. + + +#### Params (0) + +_None_ + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_chaindbCompact", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.chaindbCompact(); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) ChaindbCompact() error { + for b := byte(0); b < 255; b++ { + log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1)) + if err := api.b.ChainDb().Compact([ // ChaindbCompact flattens the entire key-value database into a single level, + // removing all unused slots and merging all keys. + ]byte{b}, []byte{b + 1}); err != nil { + log.Error("Database compaction failed", "err", err) + return err + } + } + return nil +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_chaindbProperty + +ChaindbProperty returns leveldb properties of the key-value database. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +property string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_chaindbProperty", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.chaindbProperty(property); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) { + if property == "" { + property = "leveldb.stats" + } else if !strings.HasPrefix(property, "leveldb.") { + property = "leveldb." + property + } + return api.b.ChainDb().Stat(property) +}// ChaindbProperty returns leveldb properties of the key-value database. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_cpuProfile + +CpuProfile turns on CPU profiling for nsec seconds and writes +profile data to file. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +nsec uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_cpuProfile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.cpuProfile(file,nsec); + ``` + + +
Source code +

+```go +func (h *HandlerT) CpuProfile(file string, nsec uint) error { + if err := h.StartCPUProfile(file); err != nil { + return err + } + time.Sleep(time.Duration(nsec) * time.Second) + h.StopCPUProfile() + return nil +}// CpuProfile turns on CPU profiling for nsec seconds and writes +// profile data to file. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_dumpBlock + +DumpBlock retrieves the entire state of the database at a given block. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + + +#### Result + + + + +state.Dump + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - accounts: + - patternProperties: + - .*: + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - balance: + - type: `string` + + - code: + - type: `string` + + - codeHash: + - type: `string` + + - key: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - root: + - type: `string` + + - storage: + - patternProperties: + - .*: + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: `object` + + - root: + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "accounts": { + "patternProperties": { + ".*": { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "balance": { + "type": "string" + }, + "code": { + "type": "string" + }, + "codeHash": { + "type": "string" + }, + "key": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "root": { + "type": "string" + }, + "storage": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "root": { + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_dumpBlock", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.dumpBlock(blockNr); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) { + if blockNr == rpc.PendingBlockNumber { + _, stateDb := api.eth.miner.Pending() + return stateDb.RawDump(false, false, true), nil + } + var block *types.Block + if blockNr == rpc.LatestBlockNumber { + block = api.eth.blockchain.CurrentBlock() + } else { + block = api.eth.blockchain.GetBlockByNumber(uint64(blockNr)) + } + if block == nil { + return state.Dump{}, fmt.Errorf("block #%d not found", blockNr) + } + stateDb, err := api.eth.BlockChain().StateAt(block.Root()) + if err != nil { + return state.Dump{}, err + } + return stateDb.RawDump(false, false, true), nil +}// DumpBlock retrieves the entire state of the database at a given block. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_freeOSMemory + +FreeOSMemory forces a garbage collection. + + +#### Params (0) + +_None_ + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_freeOSMemory", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.freeOSMemory(); + ``` + + +
Source code +

+```go +func (*HandlerT) FreeOSMemory() { + debug.FreeOSMemory() +}// FreeOSMemory forces a garbage collection. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_gcStats + +GcStats returns GC statistics. + + +#### Params (0) + +_None_ + +#### Result + + + + +*debug.GCStats + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - LastGC: + - format: `date-time` + - type: `string` + + - NumGC: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Pause: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - type: `array` + + - PauseEnd: + - items: + - format: `date-time` + - type: `string` + + - type: `array` + + - PauseQuantiles: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - type: `array` + + - PauseTotal: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "LastGC": { + "format": "date-time", + "type": "string" + }, + "NumGC": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Pause": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "type": "array" + }, + "PauseEnd": { + "items": { + "format": "date-time", + "type": "string" + }, + "type": "array" + }, + "PauseQuantiles": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "type": "array" + }, + "PauseTotal": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_gcStats", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.gcStats(); + ``` + + +
Source code +

+```go +func (*HandlerT) GcStats() *debug.GCStats { + s := new(debug.GCStats) + debug.ReadGCStats(s) + return s +}// GcStats returns GC statistics. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_getBadBlocks + +GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network +and returns them as a JSON list of block-hashes + + +#### Params (0) + +_None_ + +#### Result + + + +BadBlockArgs []*BadBlockArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - block: + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - error: + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactions: + - items: + - additionalProperties: `true` + + - type: `array` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - uncles: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + + - type: `object` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - rlp: + - type: `string` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "block": { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "error": { + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactions": { + "items": { + "additionalProperties": true + }, + "type": "array" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "uncles": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "rlp": { + "type": "string" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_getBadBlocks", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.getBadBlocks(); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([ // GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network +// and returns them as a JSON list of block-hashes +]*BadBlockArgs, error) { + blocks := api.eth.BlockChain().BadBlocks() + results := make([]*BadBlockArgs, len(blocks)) + var err error + for i, block := range blocks { + results[i] = &BadBlockArgs{Hash: block.Hash()} + if rlpBytes, err := rlp.EncodeToBytes(block); err != nil { + results[i].RLP = err.Error() + } else { + results[i].RLP = fmt.Sprintf("0x%x", rlpBytes) + } + if results[i].Block, err = ethapi.RPCMarshalBlock(block, true, true); err != nil { + results[i].Block = ðapi.RPCMarshalBlockT{Error: err.Error()} + } + } + return results, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_getBlockRlp + +GetBlockRlp retrieves the RLP encoded for of a single block. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +number uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_getBlockRlp", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.getBlockRlp(number); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (string, error) { + block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) + if block == nil { + return "", fmt.Errorf("block #%d not found", number) + } + encoded, err := rlp.EncodeToBytes(block) + if err != nil { + return "", err + } + return fmt.Sprintf("%x", encoded), nil +}// GetBlockRlp retrieves the RLP encoded for of a single block. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_getModifiedAccountsByHash + +GetModifiedAccountsByHash returns all accounts that have changed between the +two blocks specified. A change is defined as a difference in nonce, balance, +code hash, or storage hash. + +With one parameter, returns the list of accounts modified in the specified block. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +startHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +endHash *common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + +commonAddress []common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_getModifiedAccountsByHash", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.getModifiedAccountsByHash(startHash,endHash); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([ // GetModifiedAccountsByHash returns all accounts that have changed between the +// two blocks specified. A change is defined as a difference in nonce, balance, +// code hash, or storage hash. +// +// With one parameter, returns the list of accounts modified in the specified block. +]common.Address, error) { + var startBlock, endBlock *types.Block + startBlock = api.eth.blockchain.GetBlockByHash(startHash) + if startBlock == nil { + return nil, fmt.Errorf("start block %x not found", startHash) + } + if endHash == nil { + endBlock = startBlock + startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash()) + if startBlock == nil { + return nil, fmt.Errorf("block %x has no parent", endBlock.Number()) + } + } else { + endBlock = api.eth.blockchain.GetBlockByHash(*endHash) + if endBlock == nil { + return nil, fmt.Errorf("end block %x not found", *endHash) + } + } + return api.getModifiedAccounts(startBlock, endBlock) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_getModifiedAccountsByNumber + +GetModifiedAccountsByNumber returns all accounts that have changed between the +two blocks specified. A change is defined as a difference in nonce, balance, +code hash, or storage hash. + +With one parameter, returns the list of accounts modified in the specified block. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +startNum uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +endNum *uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + +commonAddress []common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_getModifiedAccountsByNumber", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.getModifiedAccountsByNumber(startNum,endNum); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([ // GetModifiedAccountsByNumber returns all accounts that have changed between the +// two blocks specified. A change is defined as a difference in nonce, balance, +// code hash, or storage hash. +// +// With one parameter, returns the list of accounts modified in the specified block. +]common.Address, error) { + var startBlock, endBlock *types.Block + startBlock = api.eth.blockchain.GetBlockByNumber(startNum) + if startBlock == nil { + return nil, fmt.Errorf("start block %x not found", startNum) + } + if endNum == nil { + endBlock = startBlock + startBlock = api.eth.blockchain.GetBlockByHash(startBlock.ParentHash()) + if startBlock == nil { + return nil, fmt.Errorf("block %x has no parent", endBlock.Number()) + } + } else { + endBlock = api.eth.blockchain.GetBlockByNumber(*endNum) + if endBlock == nil { + return nil, fmt.Errorf("end block %d not found", *endNum) + } + } + return api.getModifiedAccounts(startBlock, endBlock) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_goTrace + +GoTrace turns on tracing for nsec seconds and writes +trace data to file. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +nsec uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_goTrace", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.goTrace(file,nsec); + ``` + + +
Source code +

+```go +func (h *HandlerT) GoTrace(file string, nsec uint) error { + if err := h.StartGoTrace(file); err != nil { + return err + } + time.Sleep(time.Duration(nsec) * time.Second) + h.StopGoTrace() + return nil +}// GoTrace turns on tracing for nsec seconds and writes +// trace data to file. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_memStats + +MemStats returns detailed runtime memory statistics. + + +#### Params (0) + +_None_ + +#### Result + + + + +*runtime.MemStats + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Alloc: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - BuckHashSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - BySize: + - items: + - additionalProperties: `false` + - properties: + - Frees: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Mallocs: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Size: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: `object` + + - maxItems: `61` + - minItems: `61` + - type: `array` + + - DebugGC: + - type: `boolean` + + - EnableGC: + - type: `boolean` + + - Frees: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - GCCPUFraction: + - type: `number` + + - GCSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapAlloc: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapIdle: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapInuse: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapObjects: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapReleased: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - HeapSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - LastGC: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Lookups: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - MCacheInuse: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - MCacheSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - MSpanInuse: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - MSpanSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Mallocs: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - NextGC: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - NumForcedGC: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - NumGC: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - OtherSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - PauseEnd: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - PauseNs: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - PauseTotalNs: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - StackInuse: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - StackSys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Sys: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - TotalAlloc: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Alloc": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "BuckHashSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "BySize": { + "items": { + "additionalProperties": false, + "properties": { + "Frees": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Mallocs": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Size": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": "object" + }, + "maxItems": 61, + "minItems": 61, + "type": "array" + }, + "DebugGC": { + "type": "boolean" + }, + "EnableGC": { + "type": "boolean" + }, + "Frees": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "GCCPUFraction": { + "type": "number" + }, + "GCSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapAlloc": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapIdle": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapInuse": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapObjects": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapReleased": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "HeapSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "LastGC": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Lookups": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "MCacheInuse": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "MCacheSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "MSpanInuse": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "MSpanSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Mallocs": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "NextGC": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "NumForcedGC": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "NumGC": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "OtherSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "PauseEnd": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "PauseNs": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "PauseTotalNs": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "StackInuse": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "StackSys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Sys": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "TotalAlloc": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_memStats", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.memStats(); + ``` + + +
Source code +

+```go +func (*HandlerT) MemStats() *runtime.MemStats { + s := new(runtime.MemStats) + runtime.ReadMemStats(s) + return s +}// MemStats returns detailed runtime memory statistics. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_mutexProfile + +MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file. +It uses a profile rate of 1 for most accurate information. If a different rate is +desired, set the rate and write the profile manually. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +nsec uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_mutexProfile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.mutexProfile(file,nsec); + ``` + + +
Source code +

+```go +func (*HandlerT) MutexProfile(file string, nsec uint) error { + runtime.SetMutexProfileFraction(1) + time.Sleep(time.Duration(nsec) * time.Second) + defer runtime.SetMutexProfileFraction(0) + return writeProfile("mutex", file) +}// MutexProfile turns on mutex profiling for nsec seconds and writes profile data to file. +// It uses a profile rate of 1 for most accurate information. If a different rate is +// desired, set the rate and write the profile manually. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_preimage + +Preimage is a debug API function that returns the preimage for a sha3 hash, if known. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_preimage", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.preimage(hash); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { + if preimage := rawdb.ReadPreimage(api.eth.ChainDb(), hash); preimage != nil { + return preimage, nil + } + return nil, errors.New("unknown preimage") +}// Preimage is a debug API function that returns the preimage for a sha3 hash, if known. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_printBlock + +PrintBlock retrieves a block and returns its pretty printed form. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +number uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_printBlock", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.printBlock(number); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) { + block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) + if block == nil { + return "", fmt.Errorf("block #%d not found", number) + } + return spew.Sdump(block), nil +}// PrintBlock retrieves a block and returns its pretty printed form. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_removePendingTransaction + +RemovePendingTransaction removes a transaction from the txpool. +It returns the transaction removed, if any. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*types.Transaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_removePendingTransaction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.removePendingTransaction(hash); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) RemovePendingTransaction(hash common.Hash) (*types.Transaction, error) { + return api.eth.txPool.RemoveTx(hash), nil +}// RemovePendingTransaction removes a transaction from the txpool. +// It returns the transaction removed, if any. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_seedHash + +SeedHash retrieves the seed hash of a block. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +number uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_seedHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.seedHash(number); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string, error) { + block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) + if block == nil { + return "", fmt.Errorf("block #%d not found", number) + } + ecip1099FBlock := api.b.ChainConfig().GetEthashECIP1099Transition() + epochLength := ethash.CalcEpochLength(number, ecip1099FBlock) + epoch := ethash.CalcEpoch(number, epochLength) + return fmt.Sprintf("0x%x", ethash.SeedHash(epoch, epochLength)), nil +}// SeedHash retrieves the seed hash of a block. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_setBlockProfileRate + +SetBlockProfileRate sets the rate of goroutine block profile data collection. +rate 0 disables block profiling. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +rate int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_setBlockProfileRate", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.setBlockProfileRate(rate); + ``` + + +
Source code +

+```go +func (*HandlerT) SetBlockProfileRate(rate int) { + runtime.SetBlockProfileRate(rate) +}// SetBlockProfileRate sets the rate of goroutine block profile data collection. +// rate 0 disables block profiling. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_setGCPercent + +SetGCPercent sets the garbage collection target percentage. It returns the previous +setting. A negative value disables GC. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +v int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_setGCPercent", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.setGCPercent(v); + ``` + + +
Source code +

+```go +func (*HandlerT) SetGCPercent(v int) int { + return debug.SetGCPercent(v) +}// SetGCPercent sets the garbage collection target percentage. It returns the previous +// setting. A negative value disables GC. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_setHead + +SetHead rewinds the head of the blockchain to a previous block. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +number hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_setHead", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.setHead(number); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64) { + api.b.SetHead(uint64(number)) +}// SetHead rewinds the head of the blockchain to a previous block. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_setMutexProfileFraction + +SetMutexProfileFraction sets the rate of mutex profiling. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +rate int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_setMutexProfileFraction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.setMutexProfileFraction(rate); + ``` + + +
Source code +

+```go +func (*HandlerT) SetMutexProfileFraction(rate int) { + runtime.SetMutexProfileFraction(rate) +}// SetMutexProfileFraction sets the rate of mutex profiling. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_stacks + +Stacks returns a printed representation of the stacks of all goroutines. + + +#### Params (0) + +_None_ + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_stacks", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.stacks(); + ``` + + +
Source code +

+```go +func (*HandlerT) Stacks() string { + buf := new(bytes.Buffer) + pprof.Lookup("goroutine").WriteTo(buf, 2) + return buf.String() +}// Stacks returns a printed representation of the stacks of all goroutines. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_standardTraceBadBlockToFile + +StandardTraceBadBlockToFile dumps the structured logs created during the +execution of EVM against a block pulled from the pool of bad ones to the +local file system and returns a list of files to the caller. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *StdTraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - TxHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "TxHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +string []string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_standardTraceBadBlockToFile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.standardTraceBadBlockToFile(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([ // StandardTraceBadBlockToFile dumps the structured logs created during the +// execution of EVM against a block pulled from the pool of bad ones to the +// local file system and returns a list of files to the caller. +]string, error) { + blocks := api.eth.blockchain.BadBlocks() + for _, block := range blocks { + if block.Hash() == hash { + return api.standardTraceBlockToFile(ctx, block, config) + } + } + return nil, fmt.Errorf("bad block %#x not found", hash) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_standardTraceBlockToFile + +StandardTraceBlockToFile dumps the structured logs created during the +execution of EVM to the local file system and returns a list of files +to the caller. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *StdTraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - TxHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "TxHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +string []string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_standardTraceBlockToFile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.standardTraceBlockToFile(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([ // StandardTraceBlockToFile dumps the structured logs created during the +// execution of EVM to the local file system and returns a list of files +// to the caller. +]string, error) { + block := api.eth.blockchain.GetBlockByHash(hash) + if block == nil { + return nil, fmt.Errorf("block %#x not found", hash) + } + return api.standardTraceBlockToFile(ctx, block, config) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_startCPUProfile + +StartCPUProfile turns on CPU profiling, writing to the given file. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_startCPUProfile", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.startCPUProfile(file); + ``` + + +
Source code +

+```go +func (h *HandlerT) StartCPUProfile(file string) error { + h.mu.Lock() + defer h.mu.Unlock() + if h.cpuW != nil { + return errors.New("CPU profiling already in progress") + } + f, err := os.Create(expandHome(file)) + if err != nil { + return err + } + if err := pprof.StartCPUProfile(f); err != nil { + f.Close() + return err + } + h.cpuW = f + h.cpuFile = file + log.Info("CPU profiling started", "dump", h.cpuFile) + return nil +}// StartCPUProfile turns on CPU profiling, writing to the given file. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_startGoTrace + +StartGoTrace turns on tracing, writing to the given file. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_startGoTrace", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.startGoTrace(file); + ``` + + +
Source code +

+```go +func (h *HandlerT) StartGoTrace(file string) error { + h.mu.Lock() + defer h.mu.Unlock() + if h.traceW != nil { + return errors.New("trace already in progress") + } + f, err := os.Create(expandHome(file)) + if err != nil { + return err + } + if err := trace.Start(f); err != nil { + f.Close() + return err + } + h.traceW = f + h.traceFile = file + log.Info("Go tracing started", "dump", h.traceFile) + return nil +}// StartGoTrace turns on tracing, writing to the given file. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_stopCPUProfile + +StopCPUProfile stops an ongoing CPU profile. + + +#### Params (0) + +_None_ + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_stopCPUProfile", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.stopCPUProfile(); + ``` + + +
Source code +

+```go +func (h *HandlerT) StopCPUProfile() error { + h.mu.Lock() + defer h.mu.Unlock() + pprof.StopCPUProfile() + if h.cpuW == nil { + return errors.New("CPU profiling not in progress") + } + log.Info("Done writing CPU profile", "dump", h.cpuFile) + h.cpuW.Close() + h.cpuW = nil + h.cpuFile = "" + return nil +}// StopCPUProfile stops an ongoing CPU profile. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_stopGoTrace + +StopTrace stops an ongoing trace. + + +#### Params (0) + +_None_ + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_stopGoTrace", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.stopGoTrace(); + ``` + + +
Source code +

+```go +func (h *HandlerT) StopGoTrace() error { + h.mu.Lock() + defer h.mu.Unlock() + trace.Stop() + if h.traceW == nil { + return errors.New("trace not in progress") + } + log.Info("Done writing Go trace", "dump", h.traceFile) + h.traceW.Close() + h.traceW = nil + h.traceFile = "" + return nil +}// StopTrace stops an ongoing trace. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_storageRangeAt + +StorageRangeAt returns the storage at the given block height and transaction index. + + +#### Params (5) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +txIndex int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +contractAddress common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__4:__ +keyStart hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + +__5:__ +maxResult int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +StorageRangeResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - nextKey: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - storage: + - patternProperties: + - .*: + - additionalProperties: `false` + - properties: + - key: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "nextKey": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "storage": { + "patternProperties": { + ".*": { + "additionalProperties": false, + "properties": { + "key": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_storageRangeAt", "params": [, , , , ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.storageRangeAt(blockHash,txIndex,contractAddress,keyStart,maxResult); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) StorageRangeAt(blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { + block := api.eth.blockchain.GetBlockByHash(blockHash) + if block == nil { + return StorageRangeResult{}, fmt.Errorf("block %#x not found", blockHash) + } + _, _, statedb, err := api.computeTxEnv(block, txIndex, 0) + if err != nil { + return StorageRangeResult{}, err + } + st := statedb.StorageTrie(contractAddress) + if st == nil { + return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress) + } + return storageRangeAt(st, keyStart, maxResult) +}// StorageRangeAt returns the storage at the given block height and transaction index. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_testSignCliqueBlock + +TestSignCliqueBlock fetches the given block number, and attempts to sign it as a clique header with the +given address, returning the address of the recovered signature + +This is a temporary method to debug the externalsigner integration, +TODO: Remove this method when the integration is mature + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +number uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_testSignCliqueBlock", "params": [
, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.testSignCliqueBlock(address,number); + ``` + + +
Source code +

+```go +func (api *PublicDebugAPI) TestSignCliqueBlock(ctx context.Context, address common.Address, number uint64) (common.Address, error) { + block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) + if block == nil { + return common.Address{}, fmt.Errorf("block #%d not found", number) + } + header := block.Header() + header.Extra = make([ // TestSignCliqueBlock fetches the given block number, and attempts to sign it as a clique header with the + // given address, returning the address of the recovered signature + // + // This is a temporary method to debug the externalsigner integration, + // TODO: Remove this method when the integration is mature + ]byte, 32+65) + encoded := clique.CliqueRLP(header) + account := accounts.Account{Address: address} + wallet, err := api.b.AccountManager().Find(account) + if err != nil { + return common.Address{}, err + } + signature, err := wallet.SignData(account, accounts.MimetypeClique, encoded) + if err != nil { + return common.Address{}, err + } + sealHash := clique.SealHash(header).Bytes() + log.Info("test signing of clique block", "Sealhash", fmt.Sprintf("%x", sealHash), "signature", fmt.Sprintf("%x", signature)) + pubkey, err := crypto.Ecrecover(sealHash, signature) + if err != nil { + return common.Address{}, err + } + var signer common.Address + copy(signer[:], crypto.Keccak256(pubkey[1:])[12:]) + return signer, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceBadBlock + +TraceBadBlock returns the structured logs created during the execution of +EVM against a block pulled from the pool of bad ones and returns them as a JSON +object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceBadBlock", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceBadBlock(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceBadBlock(ctx context.Context, hash common.Hash, config *TraceConfig) ([ // TraceBadBlock returns the structured logs created during the execution of +// EVM against a block pulled from the pool of bad ones and returns them as a JSON +// object. +]*txTraceResult, error) { + blocks := api.eth.blockchain.BadBlocks() + for _, block := range blocks { + if block.Hash() == hash { + return api.traceBlock(ctx, block, config) + } + } + return nil, fmt.Errorf("bad block %#x not found", hash) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceBlock + +TraceBlock returns the structured logs created during the execution of EVM +and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blob []byte + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a variable length byte array` + - pattern: `^0x([a-fA-F0-9]?)+$` + - title: `bytes` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a variable length byte array", + "pattern": "^0x([a-fA-F0-9]?)+$", + "title": "bytes", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceBlock", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceBlock(blob,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob [ // TraceBlock returns the structured logs created during the execution of EVM +// and returns them as a JSON object. +]byte, config *TraceConfig) ([]*txTraceResult, error) { + return traceBlockRLP(ctx, api.eth, blob, config) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceBlockByHash + +TraceBlockByHash returns the structured logs created during the execution of +EVM and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceBlockByHash", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceBlockByHash(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([ // TraceBlockByHash returns the structured logs created during the execution of +// EVM and returns them as a JSON object. +]*txTraceResult, error) { + block := api.eth.blockchain.GetBlockByHash(hash) + if block == nil { + return nil, fmt.Errorf("block %#x not found", hash) + } + return api.traceBlock(ctx, block, config) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceBlockByNumber + +TraceBlockByNumber returns the structured logs created during the execution of +EVM and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +number rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceBlockByNumber", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceBlockByNumber(number,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([ // TraceBlockByNumber returns the structured logs created during the execution of +// EVM and returns them as a JSON object. +]*txTraceResult, error) { + return traceBlockByNumber(ctx, api.eth, number, config) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceBlockFromFile + +TraceBlockFromFile returns the structured logs created during the execution of +EVM and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceBlockFromFile", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceBlockFromFile(file,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([ // TraceBlockFromFile returns the structured logs created during the execution of +// EVM and returns them as a JSON object. +]*txTraceResult, error) { + blob, err := ioutil.ReadFile(file) + if err != nil { + return nil, fmt.Errorf("could not read file: %v", err) + } + return api.TraceBlock(ctx, blob, config) +} +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceCall + +TraceCall lets you trace a given eth_call. It collects the structured logs created during the execution of EVM +if the given transaction was added on top of the provided block and returns them as a JSON object. +You can provide -2 as a block number to trace on top of the pending block. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +args ethapi.CallArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + +__3:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +interface interface{} + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceCall", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceCall(args,blockNrOrHash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (interface{}, error) { + statedb, header, err := api.eth.APIBackend.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + var block *types.Block + if hash, ok := blockNrOrHash.Hash(); ok { + block = api.eth.blockchain.GetBlockByHash(hash) + } else if number, ok := blockNrOrHash.Number(); ok { + block = api.eth.blockchain.GetBlockByNumber(uint64(number)) + } + if block == nil { + return nil, fmt.Errorf("block %v not found: %v", blockNrOrHash, err) + } + reexec := defaultTraceReexec + if config != nil && config.Reexec != nil { + reexec = *config.Reexec + } + _, _, statedb, err = api.computeTxEnv(block, 0, reexec) + if err != nil { + return nil, err + } + } + msg := args.ToMessage(api.eth.APIBackend.RPCGasCap()) + vmctx := core.NewEVMContext(msg, header, api.eth.blockchain, nil) + return api.traceTx(ctx, msg, vmctx, statedb, config) +}// TraceCall lets you trace a given eth_call. It collects the structured logs created during the execution of EVM +// if the given transaction was added on top of the provided block and returns them as a JSON object. +// You can provide -2 as a block number to trace on top of the pending block. +// Try to retrieve the specified block + +``` +View on GitHub → +

+
+ +--- + + + +### debug_traceTransaction + +TraceTransaction returns the structured logs created during the execution of EVM +and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +interface interface{} + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_traceTransaction", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + debug.traceTransaction(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { + return traceTransaction(ctx, api.eth, hash, config) +}// TraceTransaction returns the structured logs created during the execution of EVM +// and returns them as a JSON object. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_verbosity + +Verbosity sets the log verbosity ceiling. The verbosity of individual packages +and source files can be raised using Vmodule. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +level int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_verbosity", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.verbosity(level); + ``` + + +
Source code +

+```go +func (*HandlerT) Verbosity(level int) { + glogger.Verbosity(log.Lvl(level)) +}// Verbosity sets the log verbosity ceiling. The verbosity of individual packages +// and source files can be raised using Vmodule. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_vmodule + +Vmodule sets the log verbosity pattern. See package log for details on the +pattern syntax. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +pattern string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_vmodule", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.vmodule(pattern); + ``` + + +
Source code +

+```go +func (*HandlerT) Vmodule(pattern string) error { + return glogger.Vmodule(pattern) +}// Vmodule sets the log verbosity pattern. See package log for details on the +// pattern syntax. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_writeBlockProfile + +WriteBlockProfile writes a goroutine blocking profile to the given file. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_writeBlockProfile", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.writeBlockProfile(file); + ``` + + +
Source code +

+```go +func (*HandlerT) WriteBlockProfile(file string) error { + return writeProfile("block", file) +}// WriteBlockProfile writes a goroutine blocking profile to the given file. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_writeMemProfile + +WriteMemProfile writes an allocation profile to the given file. +Note that the profiling rate cannot be set through the API, +it must be set on the command line. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_writeMemProfile", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.writeMemProfile(file); + ``` + + +
Source code +

+```go +func (*HandlerT) WriteMemProfile(file string) error { + return writeProfile("heap", file) +}// WriteMemProfile writes an allocation profile to the given file. +// Note that the profiling rate cannot be set through the API, +// it must be set on the command line. + +``` +View on GitHub → +

+
+ +--- + + + +### debug_writeMutexProfile + +WriteMutexProfile writes a goroutine blocking profile to the given file. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +file string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "debug_writeMutexProfile", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + debug.writeMutexProfile(file); + ``` + + +
Source code +

+```go +func (*HandlerT) WriteMutexProfile(file string) error { + return writeProfile("mutex", file) +}// WriteMutexProfile writes a goroutine blocking profile to the given file. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/eth.md b/docs/JSON-RPC-API/modules/eth.md new file mode 100755 index 0000000000..7ecf4b8928 --- /dev/null +++ b/docs/JSON-RPC-API/modules/eth.md @@ -0,0 +1,9692 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### eth_accounts + +Accounts returns the collection of accounts this node manages + + +#### Params (0) + +_None_ + +#### Result + + + +commonAddress []common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_accounts", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.accounts(); + ``` + + +
Source code +

+```go +func (s *PublicAccountAPI) Accounts() [ // Accounts returns the collection of accounts this node manages +]common.Address { + return s.am.Accounts() +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_blockNumber + +BlockNumber returns the block number of the chain head. + + +#### Params (0) + +_None_ + +#### Result + + + + +hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_blockNumber", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.blockNumber(); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64 { + header, _ := s.b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber) + return hexutil.Uint64(header.Number.Uint64()) +}// BlockNumber returns the block number of the chain head. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_call + +Call executes the given transaction on the state for the given block number. + +Additionally, the caller can specify a batch of contract for fields overriding. + +Note, this function doesn't make and changes in the state/blockchain and is +useful to execute and retrieve values. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +args CallArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + +__3:__ +overrides *map[common.Address]account + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - patternProperties: + - .*: + - additionalProperties: `false` + - properties: + - balance: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - code: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - state: + - patternProperties: + - .*: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + + - type: `object` + + - stateDiff: + - patternProperties: + - .*: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "patternProperties": { + ".*": { + "additionalProperties": false, + "properties": { + "balance": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "code": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "state": { + "patternProperties": { + ".*": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + } + }, + "type": "object" + }, + "stateDiff": { + "patternProperties": { + ".*": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_call", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.call(args,blockNrOrHash,overrides); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map // Call executes the given transaction on the state for the given block number. +// +// Additionally, the caller can specify a batch of contract for fields overriding. +// +// Note, this function doesn't make and changes in the state/blockchain and is +// useful to execute and retrieve values. +[common.Address]account) (hexutil.Bytes, error) { + var accounts map[common.Address]account + if overrides != nil { + accounts = *overrides + } + result, err := DoCall(ctx, s.b, args, blockNrOrHash, accounts, vm.Config{}, 5*time.Second, s.b.RPCGasCap()) + if err != nil { + return nil, err + } + if len(result.Revert()) > 0 { + return nil, newRevertError(result) + } + return result.Return(), result.Err +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_chainId + +ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. + + +#### Params (0) + +_None_ + +#### Result + + + + +hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_chainId", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.chainId(); + ``` + + +
Source code +

+```go +func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 { + chainID := new(big.Int) + if config := api.e.blockchain.Config(); config.IsEnabled(config.GetEIP155Transition, api.e.blockchain.CurrentBlock().Number()) { + chainID = config.GetChainID() + } + return (hexutil.Uint64)(chainID.Uint64()) +}// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_chainId + +ChainId returns the chainID value for transaction replay protection. + + +#### Params (0) + +_None_ + +#### Result + + + + +*hexutil.Big + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_chainId", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.chainId(); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) ChainId() *hexutil.Big { + return (*hexutil.Big)(s.b.ChainConfig().GetChainID()) +}// ChainId returns the chainID value for transaction replay protection. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_coinbase + +Coinbase is the address that mining rewards will be send to (alias for Etherbase) + + +#### Params (0) + +_None_ + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_coinbase", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.coinbase(); + ``` + + +
Source code +

+```go +func (api *PublicEthereumAPI) Coinbase() (common.Address, error) { + return api.Etherbase() +}// Coinbase is the address that mining rewards will be send to (alias for Etherbase) + +``` +View on GitHub → +

+
+ +--- + + + +### eth_estimateGas + +EstimateGas returns an estimate of the amount of gas needed to execute the +given transaction against the current pending block. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +args CallArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +blockNrOrHash *rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_estimateGas", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.estimateGas(args,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { + bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) + if blockNrOrHash != nil { + bNrOrHash = *blockNrOrHash + } + return DoEstimateGas(ctx, s.b, args, bNrOrHash, s.b.RPCGasCap()) +}// EstimateGas returns an estimate of the amount of gas needed to execute the +// given transaction against the current pending block. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_etherbase + +Etherbase is the address that mining rewards will be send to + + +#### Params (0) + +_None_ + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_etherbase", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.etherbase(); + ``` + + +
Source code +

+```go +func (api *PublicEthereumAPI) Etherbase() (common.Address, error) { + return api.e.Etherbase() +}// Etherbase is the address that mining rewards will be send to + +``` +View on GitHub → +

+
+ +--- + + + +### eth_fillTransaction + +FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction, +and returns it to the caller for further processing (signing + broadcast) + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + + +*SignTransactionResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - raw: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - tx: + - additionalProperties: `false` + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "raw": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "tx": { + "additionalProperties": false, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_fillTransaction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.fillTransaction(args); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) { + if err := args.setDefaults(ctx, s.b); err != nil { + return nil, err + } + tx := args.toTransaction() + data, err := rlp.EncodeToBytes(tx) + if err != nil { + return nil, err + } + return &SignTransactionResult{data, tx}, nil +}// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction, +// and returns it to the caller for further processing (signing + broadcast) + +``` +View on GitHub → +

+
+ +--- + + + +### eth_gasPrice + +GasPrice returns a suggestion for a gas price. + + +#### Params (0) + +_None_ + +#### Result + + + + +*hexutil.Big + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_gasPrice", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.gasPrice(); + ``` + + +
Source code +

+```go +func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { + price, err := s.b.SuggestPrice(ctx) + return (*hexutil.Big)(price), err +}// GasPrice returns a suggestion for a gas price. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getBalance + +GetBalance returns the amount of wei for the given address in the state of the +given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta +block numbers are also allowed. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*hexutil.Big + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getBalance", "params": [
, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getBalance(address,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) { + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + return (*hexutil.Big)(state.GetBalance(address)), state.Error() +}// GetBalance returns the amount of wei for the given address in the state of the +// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta +// block numbers are also allowed. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getBlockByHash + +GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full +detail, otherwise only the transaction hash is returned. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +fullTx bool + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*RPCMarshalBlockT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - error: + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactions: + - items: + - additionalProperties: `true` + + - type: `array` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - uncles: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "error": { + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactions": { + "items": { + "additionalProperties": true + }, + "type": "array" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "uncles": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getBlockByHash", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getBlockByHash(hash,fullTx); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (*RPCMarshalBlockT, error) { + block, err := s.b.BlockByHash(ctx, hash) + if block != nil { + return s.rpcMarshalBlock(ctx, block, true, fullTx) + } + return nil, err +}// GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full +// detail, otherwise only the transaction hash is returned. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getBlockByNumber + +GetBlockByNumber returns the requested canonical block. +* When blockNr is -1 the chain head is returned. +* When blockNr is -2 the pending chain head is returned. +* When fullTx is true all transactions in the block are returned, otherwise + only the transaction hash is returned. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +number rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +fullTx bool + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*RPCMarshalBlockT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - error: + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactions: + - items: + - additionalProperties: `true` + + - type: `array` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - uncles: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "error": { + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactions": { + "items": { + "additionalProperties": true + }, + "type": "array" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "uncles": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getBlockByNumber", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getBlockByNumber(number,fullTx); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (*RPCMarshalBlockT, error) { + block, err := s.b.BlockByNumber(ctx, number) + if block != nil && err == nil { + response, err := s.rpcMarshalBlock(ctx, block, true, fullTx) + if err == nil && number == rpc.PendingBlockNumber { + response.setAsPending() + } + return response, err + } + return nil, err +}// GetBlockByNumber returns the requested canonical block. +// * When blockNr is -1 the chain head is returned. +// * When blockNr is -2 the pending chain head is returned. +// * When fullTx is true all transactions in the block are returned, otherwise +// only the transaction hash is returned. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getBlockTransactionCountByHash + +GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getBlockTransactionCountByHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getBlockTransactionCountByHash(blockHash); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint { + if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { + n := hexutil.Uint(len(block.Transactions())) + return &n + } + return nil +}// GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getBlockTransactionCountByNumber + +GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + + +#### Result + + + + +*hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getBlockTransactionCountByNumber", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getBlockTransactionCountByNumber(blockNr); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint { + if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil { + n := hexutil.Uint(len(block.Transactions())) + return &n + } + return nil +}// GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getCode + +GetCode returns the code stored at the given address in the state for the given block number. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getCode", "params": [
, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getCode(address,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + code := state.GetCode(address) + return code, state.Error() +}// GetCode returns the code stored at the given address in the state for the given block number. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getFilterChanges + +GetFilterChanges returns the logs for the filter with the given id since +last time it was called. This can be used for polling. + +For pending transaction and block filters the result is []common.Hash. +(pending)Log filters return []Log. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +id rpc.ID + + + Required: ✓ Yes + + + + + + +#### Result + + + +interface interface{} + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getFilterChanges", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getFilterChanges(id); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) { + api.filtersMu.Lock() + defer api.filtersMu.Unlock() + if f, found := api.filters[id]; found { + if !f.deadline.Stop() { + <-f.deadline.C + } + f.deadline.Reset(deadline) + switch f.typ { + case PendingTransactionsSubscription, BlocksSubscription, SideBlocksSubscription: + hashes := f.hashes + f.hashes = nil + return returnHashes(hashes), nil + case LogsSubscription, MinedAndPendingLogsSubscription: + logs := f.logs + f.logs = nil + return returnLogs(logs), nil + } + } + return [ // GetFilterChanges returns the logs for the filter with the given id since + // last time it was called. This can be used for polling. + // + // For pending transaction and block filters the result is []common.Hash. + // (pending)Log filters return []Log. + // + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges + ]interface{}{}, fmt.Errorf("filter not found") +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getFilterLogs + +GetFilterLogs returns the logs for the filter with the given id. +If the filter could not be found an empty array of logs is returned. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +id rpc.ID + + + Required: ✓ Yes + + + + + + +#### Result + + + +typesLog []*types.Log + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - data: + - pattern: `^0x([a-fA-F0-9]?)+$` + - title: `bytes` + - type: `string` + + - logIndex: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - removed: + - type: `boolean` + + - topics: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - transactionHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "data": { + "pattern": "^0x([a-fA-F0-9]?)+$", + "title": "bytes", + "type": "string" + }, + "logIndex": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "removed": { + "type": "boolean" + }, + "topics": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "transactionHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getFilterLogs", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getFilterLogs(id); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([ // GetFilterLogs returns the logs for the filter with the given id. +// If the filter could not be found an empty array of logs is returned. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs +]*types.Log, error) { + api.filtersMu.Lock() + f, found := api.filters[id] + api.filtersMu.Unlock() + if !found || f.typ != LogsSubscription { + return nil, fmt.Errorf("filter not found") + } + var filter *Filter + if f.crit.BlockHash != nil { + filter = NewBlockFilter(api.backend, *f.crit.BlockHash, f.crit.Addresses, f.crit.Topics) + } else { + begin := rpc.LatestBlockNumber.Int64() + if f.crit.FromBlock != nil { + begin = f.crit.FromBlock.Int64() + } + end := rpc.LatestBlockNumber.Int64() + if f.crit.ToBlock != nil { + end = f.crit.ToBlock.Int64() + } + filter = NewRangeFilter(api.backend, begin, end, f.crit.Addresses, f.crit.Topics) + } + logs, err := filter.Logs(ctx) + if err != nil { + return nil, err + } + return returnLogs(logs), nil +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getHashrate + +GetHashrate returns the current hashrate for local CPU miner and remote miner. + + +#### Params (0) + +_None_ + +#### Result + + + + +uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getHashrate", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getHashrate(); + ``` + + +
Source code +

+```go +func (api *API) GetHashrate() uint64 { + return uint64(api.ethash.Hashrate()) +}// GetHashrate returns the current hashrate for local CPU miner and remote miner. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getHeaderByHash + +GetHeaderByHash returns the requested header by hash. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCMarshalHeaderT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getHeaderByHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getHeaderByHash(hash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) *RPCMarshalHeaderT { + header, _ := s.b.HeaderByHash(ctx, hash) + if header != nil { + return s.rpcMarshalHeader(ctx, header) + } + return nil +}// GetHeaderByHash returns the requested header by hash. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getHeaderByNumber + +GetHeaderByNumber returns the requested canonical block header. +* When blockNr is -1 the chain head is returned. +* When blockNr is -2 the pending chain head is returned. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +number rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + + +#### Result + + + + +*RPCMarshalHeaderT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getHeaderByNumber", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getHeaderByNumber(number); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*RPCMarshalHeaderT, error) { + header, err := s.b.HeaderByNumber(ctx, number) + if header != nil && err == nil { + response := s.rpcMarshalHeader(ctx, header) + if number == rpc.PendingBlockNumber { + response.setAsPending() + } + return response, err + } + return nil, err +}// GetHeaderByNumber returns the requested canonical block header. +// * When blockNr is -1 the chain head is returned. +// * When blockNr is -2 the pending chain head is returned. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getLogs + +GetLogs returns logs matching the given argument that are stored within the state. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +crit FilterCriteria + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Addresses: + - items: + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - BlockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - FromBlock: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - ToBlock: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Topics: + - items: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Addresses": { + "items": { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "BlockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "FromBlock": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "ToBlock": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Topics": { + "items": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +typesLog []*types.Log + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - data: + - pattern: `^0x([a-fA-F0-9]?)+$` + - title: `bytes` + - type: `string` + + - logIndex: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - removed: + - type: `boolean` + + - topics: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - transactionHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "data": { + "pattern": "^0x([a-fA-F0-9]?)+$", + "title": "bytes", + "type": "string" + }, + "logIndex": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "removed": { + "type": "boolean" + }, + "topics": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "transactionHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getLogs", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getLogs(crit); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([ // GetLogs returns logs matching the given argument that are stored within the state. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs +]*types.Log, error) { + var filter *Filter + if crit.BlockHash != nil { + filter = NewBlockFilter(api.backend, *crit.BlockHash, crit.Addresses, crit.Topics) + } else { + begin := rpc.LatestBlockNumber.Int64() + if crit.FromBlock != nil { + begin = crit.FromBlock.Int64() + } + end := rpc.LatestBlockNumber.Int64() + if crit.ToBlock != nil { + end = crit.ToBlock.Int64() + } + filter = NewRangeFilter(api.backend, begin, end, crit.Addresses, crit.Topics) + } + logs, err := filter.Logs(ctx) + if err != nil { + return nil, err + } + return returnLogs(logs), err +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getProof + +GetProof returns the Merkle-proof for a given account and optionally some storage keys. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +storageKeys []string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + + +__3:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*AccountResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - accountProof: + - items: + - type: `string` + + - type: `array` + + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - balance: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - codeHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - storageHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - storageProof: + - items: + - additionalProperties: `false` + - properties: + - key: + - type: `string` + + - proof: + - items: + - type: `string` + + - type: `array` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: `object` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "accountProof": { + "items": { + "type": "string" + }, + "type": "array" + }, + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "balance": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "codeHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "storageHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "storageProof": { + "items": { + "additionalProperties": false, + "properties": { + "key": { + "type": "string" + }, + "proof": { + "items": { + "type": "string" + }, + "type": "array" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getProof", "params": [
, , ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getProof(address,storageKeys,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys [ // GetProof returns the Merkle-proof for a given account and optionally some storage keys. +]string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error) { + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + storageTrie := state.StorageTrie(address) + storageHash := types.EmptyRootHash + codeHash := state.GetCodeHash(address) + storageProof := make([]StorageResult, len(storageKeys)) + if storageTrie != nil { + storageHash = storageTrie.Hash() + } else { + codeHash = crypto.Keccak256Hash(nil) + } + for i, key := range storageKeys { + if storageTrie != nil { + proof, storageError := state.GetStorageProof(address, common.HexToHash(key)) + if storageError != nil { + return nil, storageError + } + storageProof[i] = StorageResult{key, (*hexutil.Big)(state.GetState(address, common.HexToHash(key)).Big()), toHexSlice(proof)} + } else { + storageProof[i] = StorageResult{key, &hexutil.Big{}, []string{}} + } + } + accountProof, proofErr := state.GetProof(address) + if proofErr != nil { + return nil, proofErr + } + return &AccountResult{Address: address, AccountProof: toHexSlice(accountProof), Balance: (*hexutil.Big)(state.GetBalance(address)), CodeHash: codeHash, Nonce: hexutil.Uint64(state.GetNonce(address)), StorageHash: storageHash, StorageProof: storageProof}, state.Error() +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getRawTransactionByBlockHashAndIndex + +GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getRawTransactionByBlockHashAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getRawTransactionByBlockHashAndIndex(blockHash,index); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes { + if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { + return newRPCRawTransactionFromBlockIndex(block, uint64(index)) + } + return nil +}// GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getRawTransactionByBlockNumberAndIndex + +GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getRawTransactionByBlockNumberAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getRawTransactionByBlockNumberAndIndex(blockNr,index); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes { + if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil { + return newRPCRawTransactionFromBlockIndex(block, uint64(index)) + } + return nil +}// GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getRawTransactionByHash + +GetRawTransactionByHash returns the bytes of the transaction for the given hash. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getRawTransactionByHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getRawTransactionByHash(hash); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { + tx, _, _, _, err := s.b.GetTransaction(ctx, hash) + if err != nil { + return nil, err + } + if tx == nil { + if tx = s.b.GetPoolTransaction(hash); tx == nil { + return nil, nil + } + } + return rlp.EncodeToBytes(tx) +}// GetRawTransactionByHash returns the bytes of the transaction for the given hash. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getStorageAt + +GetStorageAt returns the storage from the state at the given address, key and +block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block +numbers are also allowed. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +key string + + + Required: ✓ Yes + + + + + +__3:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getStorageAt", "params": [
, , ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getStorageAt(address,key,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + res := state.GetState(address, common.HexToHash(key)) + return res[ // GetStorageAt returns the storage from the state at the given address, key and + // block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block + // numbers are also allowed. + :], state.Error() +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getTransactionByBlockHashAndIndex + +GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCTransaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - r: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - s: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - v: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "r": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "s": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "v": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getTransactionByBlockHashAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getTransactionByBlockHashAndIndex(blockHash,index); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction { + if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { + return newRPCTransactionFromBlockIndex(block, uint64(index)) + } + return nil +}// GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getTransactionByBlockNumberAndIndex + +GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCTransaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - r: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - s: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - v: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "r": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "s": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "v": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getTransactionByBlockNumberAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getTransactionByBlockNumberAndIndex(blockNr,index); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction { + if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil { + return newRPCTransactionFromBlockIndex(block, uint64(index)) + } + return nil +}// GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getTransactionByHash + +GetTransactionByHash returns the transaction for the given hash + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCTransaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - r: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - s: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - v: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "r": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "s": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "v": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getTransactionByHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getTransactionByHash(hash); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) { + tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash) + if err != nil { + return nil, err + } + if tx != nil { + return newRPCTransaction(tx, blockHash, blockNumber, index), nil + } + if tx := s.b.GetPoolTransaction(hash); tx != nil { + return newRPCPendingTransaction(tx), nil + } + return nil, nil +}// GetTransactionByHash returns the transaction for the given hash + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getTransactionCount + +GetTransactionCount returns the number of transactions the given address has sent for the given block number + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +address common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +blockNrOrHash rpc.BlockNumberOrHash + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getTransactionCount", "params": [
, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getTransactionCount(address,blockNrOrHash); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) { + if blockNr, ok := blockNrOrHash.Number(); ok && blockNr == rpc.PendingBlockNumber { + nonce, err := s.b.GetPoolNonce(ctx, address) + if err != nil { + return nil, err + } + return (*hexutil.Uint64)(&nonce), nil + } + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + nonce := state.GetNonce(address) + return (*hexutil.Uint64)(&nonce), state.Error() +}// GetTransactionCount returns the number of transactions the given address has sent for the given block number + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getTransactionReceipt + +GetTransactionReceipt returns the transaction receipt for the given transaction hash. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + +mapstringinterface map[string]interface{} + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - patternProperties: + - .*: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "patternProperties": { + ".*": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getTransactionReceipt", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getTransactionReceipt(hash); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map // GetTransactionReceipt returns the transaction receipt for the given transaction hash. +[string]interface{}, error) { + tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash) + if err != nil { + return nil, nil + } + receipts, err := s.b.GetReceipts(ctx, blockHash) + if err != nil { + return nil, err + } + if len(receipts) <= int(index) { + return nil, nil + } + receipt := receipts[index] + var signer types.Signer = types.FrontierSigner{} + if tx.Protected() { + signer = types.NewEIP155Signer(tx.ChainId()) + } + from, _ := types.Sender(signer, tx) + fields := map[string]interface{}{"blockHash": blockHash, "blockNumber": hexutil.Uint64(blockNumber), "transactionHash": hash, "transactionIndex": hexutil.Uint64(index), "from": from, "to": tx.To(), "gasUsed": hexutil.Uint64(receipt.GasUsed), "cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed), "contractAddress": nil, "logs": receipt.Logs, "logsBloom": receipt.Bloom} + if len(receipt.PostState) > 0 { + fields["root"] = hexutil.Bytes(receipt.PostState) + } else { + fields["status"] = hexutil.Uint(receipt.Status) + } + if receipt.Logs == nil { + fields["logs"] = [][]*types.Log{} + } + if receipt.ContractAddress != (common.Address{}) { + fields["contractAddress"] = receipt.ContractAddress + } + return fields, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_getUncleByBlockHashAndIndex + +GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true +all transactions in the block are returned in full detail, otherwise only the transaction hash is returned. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCMarshalBlockT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - error: + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactions: + - items: + - additionalProperties: `true` + + - type: `array` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - uncles: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "error": { + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactions": { + "items": { + "additionalProperties": true + }, + "type": "array" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "uncles": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getUncleByBlockHashAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getUncleByBlockHashAndIndex(blockHash,index); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (*RPCMarshalBlockT, error) { + block, err := s.b.BlockByHash(ctx, blockHash) + if block != nil { + uncles := block.Uncles() + if index >= hexutil.Uint(len(uncles)) { + log.Debug("Requested uncle not found", "number", block.Number(), "hash", blockHash, "index", index) + return nil, nil + } + block = types.NewBlockWithHeader(uncles[index]) + return s.rpcMarshalBlock(ctx, block, false, false) + } + return nil, err +}// GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true +// all transactions in the block are returned in full detail, otherwise only the transaction hash is returned. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getUncleByBlockNumberAndIndex + +GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true +all transactions in the block are returned in full detail, otherwise only the transaction hash is returned. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +index hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*RPCMarshalBlockT + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - difficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - error: + - type: `string` + + - extraData: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - gasLimit: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasUsed: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - logsBloom: + - items: + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - maxItems: `256` + - minItems: `256` + - type: `array` + + - miner: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - mixHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - nonce: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - number: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - parentHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - receiptsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - sha3Uncles: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - size: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - stateRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - timestamp: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - totalDifficulty: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - transactions: + - items: + - additionalProperties: `true` + + - type: `array` + + - transactionsRoot: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - uncles: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "difficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "error": { + "type": "string" + }, + "extraData": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "gasLimit": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasUsed": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "logsBloom": { + "items": { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "maxItems": 256, + "minItems": 256, + "type": "array" + }, + "miner": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "mixHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "nonce": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "number": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "parentHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "receiptsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "sha3Uncles": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "size": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "stateRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "timestamp": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "totalDifficulty": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "transactions": { + "items": { + "additionalProperties": true + }, + "type": "array" + }, + "transactionsRoot": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "uncles": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getUncleByBlockNumberAndIndex", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.getUncleByBlockNumberAndIndex(blockNr,index); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (*RPCMarshalBlockT, error) { + block, err := s.b.BlockByNumber(ctx, blockNr) + if block != nil { + uncles := block.Uncles() + if index >= hexutil.Uint(len(uncles)) { + log.Debug("Requested uncle not found", "number", blockNr, "hash", block.Hash(), "index", index) + return nil, nil + } + block = types.NewBlockWithHeader(uncles[index]) + return s.rpcMarshalBlock(ctx, block, false, false) + } + return nil, err +}// GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true +// all transactions in the block are returned in full detail, otherwise only the transaction hash is returned. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getUncleCountByBlockHash + +GetUncleCountByBlockHash returns number of uncles in the block for the given block hash + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockHash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +*hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getUncleCountByBlockHash", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getUncleCountByBlockHash(blockHash); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint { + if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { + n := hexutil.Uint(len(block.Uncles())) + return &n + } + return nil +}// GetUncleCountByBlockHash returns number of uncles in the block for the given block hash + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getUncleCountByBlockNumber + +GetUncleCountByBlockNumber returns number of uncles in the block for the given block number + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +blockNr rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + + +#### Result + + + + +*hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getUncleCountByBlockNumber", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getUncleCountByBlockNumber(blockNr); + ``` + + +
Source code +

+```go +func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint { + if block, _ := s.b.BlockByNumber(ctx, blockNr); block != nil { + n := hexutil.Uint(len(block.Uncles())) + return &n + } + return nil +}// GetUncleCountByBlockNumber returns number of uncles in the block for the given block number + +``` +View on GitHub → +

+
+ +--- + + + +### eth_getWork + +GetWork returns a work package for external miner. + +The work package consists of 3 strings: + result[0] - 32 bytes hex encoded current block header pow-hash + result[1] - 32 bytes hex encoded seed hash used for DAG + result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty + result[3] - hex encoded block number + + +#### Params (0) + +_None_ + +#### Result + + + +num4string [4]string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - type: string + + + - maxItems: `4` + - minItems: `4` + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "type": [ + "string" + ] + } + ], + "maxItems": 4, + "minItems": 4, + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_getWork", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.getWork(); + ``` + + +
Source code +

+```go +func (api *API) GetWork() ([4]string, error) { + if api.ethash.remote == nil { + return [4]string{}, errors.New("not supported") + } + var ( + workCh = make(chan [4]string, 1) + errc = make(chan error, 1) + ) + select { + case api.ethash.remote.fetchWorkCh <- &sealWork{errc: errc, res: workCh}: + case <-api.ethash.remote.exitCh: + return [4]string{}, errEthashStopped + } + select { + case work := <-workCh: + return work, nil + case err := <-errc: + return [4]string{}, err + } +}// GetWork returns a work package for external miner. +// +// The work package consists of 3 strings: +// result[0] - 32 bytes hex encoded current block header pow-hash +// result[1] - 32 bytes hex encoded seed hash used for DAG +// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty +// result[3] - hex encoded block number + +``` +View on GitHub → +

+
+ +--- + + + +### eth_hashrate + +Hashrate returns the POW hashrate + + +#### Params (0) + +_None_ + +#### Result + + + + +hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_hashrate", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.hashrate(); + ``` + + +
Source code +

+```go +func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 { + return hexutil.Uint64(api.e.Miner().HashRate()) +}// Hashrate returns the POW hashrate + +``` +View on GitHub → +

+
+ +--- + + + +### eth_mining + +Mining returns an indication if this node is currently mining. + + +#### Params (0) + +_None_ + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_mining", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.mining(); + ``` + + +
Source code +

+```go +func (api *PublicMinerAPI) Mining() bool { + return api.e.IsMining() +}// Mining returns an indication if this node is currently mining. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_newBlockFilter + +NewBlockFilter creates a filter that fetches blocks that are imported into the chain. +It is part of the filter package since polling goes with eth_getFilterChanges. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter + + +#### Params (0) + +_None_ + +#### Result + + + + +rpc.ID + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_newBlockFilter", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.newBlockFilter(); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) NewBlockFilter() rpc.ID { + var ( + headers = make(chan *types.Header) + headerSub = api.events.SubscribeNewHeads(headers) + ) + api.filtersMu.Lock() + api.filters[headerSub.ID] = &filter{typ: BlocksSubscription, deadline: time.NewTimer(deadline), hashes: make([ // NewBlockFilter creates a filter that fetches blocks that are imported into the chain. + // It is part of the filter package since polling goes with eth_getFilterChanges. + // + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter + ]common.Hash, 0), s: headerSub} + api.filtersMu.Unlock() + go func() { + for { + select { + case h := <-headers: + api.filtersMu.Lock() + if f, found := api.filters[headerSub.ID]; found { + f.hashes = append(f.hashes, h.Hash()) + } + api.filtersMu.Unlock() + case <-headerSub.Err(): + api.filtersMu.Lock() + delete(api.filters, headerSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + return headerSub.ID +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_newFilter + +NewFilter creates a new filter and returns the filter id. It can be +used to retrieve logs when the state changes. This method cannot be +used to fetch logs that are already stored in the state. + +Default criteria for the from and to block are "latest". +Using "latest" as block number will return logs for mined blocks. +Using "pending" as block number returns logs for not yet mined (pending) blocks. +In case logs are removed (chain reorg) previously returned logs are returned +again but with the removed property set to true. + +In case "fromBlock" > "toBlock" an error is returned. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +crit FilterCriteria + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Addresses: + - items: + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - BlockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - FromBlock: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - ToBlock: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Topics: + - items: + - items: + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - type: `array` + + - type: `array` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Addresses": { + "items": { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "BlockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "FromBlock": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "ToBlock": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Topics": { + "items": { + "items": { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "type": "array" + }, + "type": "array" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + + +rpc.ID + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_newFilter", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.newFilter(crit); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) { + logs := make(chan [ // NewFilter creates a new filter and returns the filter id. It can be + // used to retrieve logs when the state changes. This method cannot be + // used to fetch logs that are already stored in the state. + // + // Default criteria for the from and to block are "latest". + // Using "latest" as block number will return logs for mined blocks. + // Using "pending" as block number returns logs for not yet mined (pending) blocks. + // In case logs are removed (chain reorg) previously returned logs are returned + // again but with the removed property set to true. + // + // In case "fromBlock" > "toBlock" an error is returned. + // + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter + ]*types.Log) + logsSub, err := api.events.SubscribeLogs(ethereum.FilterQuery(crit), logs) + if err != nil { + return rpc.ID(""), err + } + api.filtersMu.Lock() + api.filters[logsSub.ID] = &filter{typ: LogsSubscription, crit: crit, deadline: time.NewTimer(deadline), logs: make([]*types.Log, 0), s: logsSub} + api.filtersMu.Unlock() + go func() { + for { + select { + case l := <-logs: + api.filtersMu.Lock() + if f, found := api.filters[logsSub.ID]; found { + f.logs = append(f.logs, l...) + } + api.filtersMu.Unlock() + case <-logsSub.Err(): + api.filtersMu.Lock() + delete(api.filters, logsSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + return logsSub.ID, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_newPendingTransactionFilter + +NewPendingTransactionFilter creates a filter that fetches pending transaction hashes +as transactions enter the pending state. + +It is part of the filter package because this filter can be used through the +`eth_getFilterChanges` polling method that is also used for log filters. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter + + +#### Params (0) + +_None_ + +#### Result + + + + +rpc.ID + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_newPendingTransactionFilter", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.newPendingTransactionFilter(); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID { + var ( + pendingTxs = make(chan [ // NewPendingTransactionFilter creates a filter that fetches pending transaction hashes + // as transactions enter the pending state. + // + // It is part of the filter package because this filter can be used through the + // `eth_getFilterChanges` polling method that is also used for log filters. + // + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter + ]common.Hash) + pendingTxSub = api.events.SubscribePendingTxs(pendingTxs) + ) + api.filtersMu.Lock() + api.filters[pendingTxSub.ID] = &filter{typ: PendingTransactionsSubscription, deadline: time.NewTimer(deadline), hashes: make([]common.Hash, 0), s: pendingTxSub} + api.filtersMu.Unlock() + go func() { + for { + select { + case ph := <-pendingTxs: + api.filtersMu.Lock() + if f, found := api.filters[pendingTxSub.ID]; found { + f.hashes = append(f.hashes, ph...) + } + api.filtersMu.Unlock() + case <-pendingTxSub.Err(): + api.filtersMu.Lock() + delete(api.filters, pendingTxSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + return pendingTxSub.ID +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_newSideBlockFilter + +NewSideBlockFilter creates a filter that fetches blocks that are imported into the chain with a non-canonical status. +It is part of the filter package since polling goes with eth_getFilterChanges. + + +#### Params (0) + +_None_ + +#### Result + + + + +rpc.ID + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_newSideBlockFilter", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.newSideBlockFilter(); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) NewSideBlockFilter() rpc.ID { + var ( + headers = make(chan *types.Header) + headerSub = api.events.SubscribeNewSideHeads(headers) + ) + api.filtersMu.Lock() + api.filters[headerSub.ID] = &filter{typ: SideBlocksSubscription, deadline: time.NewTimer(deadline), hashes: make([ // NewSideBlockFilter creates a filter that fetches blocks that are imported into the chain with a non-canonical status. + // It is part of the filter package since polling goes with eth_getFilterChanges. + ]common.Hash, 0), s: headerSub} + api.filtersMu.Unlock() + go func() { + for { + select { + case h := <-headers: + api.filtersMu.Lock() + if f, found := api.filters[headerSub.ID]; found { + f.hashes = append(f.hashes, h.Hash()) + } + api.filtersMu.Unlock() + case <-headerSub.Err(): + api.filtersMu.Lock() + delete(api.filters, headerSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + return headerSub.ID +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_pendingTransactions + +PendingTransactions returns the transactions that are in the transaction pool +and have a from address that is one of the accounts this node manages. + + +#### Params (0) + +_None_ + +#### Result + + + +RPCTransaction []*RPCTransaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - r: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - s: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - v: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "r": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "s": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "v": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_pendingTransactions", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.pendingTransactions(); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) PendingTransactions() ([ // PendingTransactions returns the transactions that are in the transaction pool +// and have a from address that is one of the accounts this node manages. +]*RPCTransaction, error) { + pending, err := s.b.GetPoolTransactions() + if err != nil { + return nil, err + } + accounts := make(map[common.Address]struct{}) + for _, wallet := range s.b.AccountManager().Wallets() { + for _, account := range wallet.Accounts() { + accounts[account.Address] = struct{}{} + } + } + transactions := make([]*RPCTransaction, 0, len(pending)) + for _, tx := range pending { + var signer types.Signer = types.HomesteadSigner{} + if tx.Protected() { + signer = types.NewEIP155Signer(tx.ChainId()) + } + from, _ := types.Sender(signer, tx) + if _, exists := accounts[from]; exists { + transactions = append(transactions, newRPCPendingTransaction(tx)) + } + } + return transactions, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_protocolVersion + +ProtocolVersion returns the current Ethereum protocol version this node supports + + +#### Params (0) + +_None_ + +#### Result + + + + +hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_protocolVersion", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.protocolVersion(); + ``` + + +
Source code +

+```go +func (s *PublicEthereumAPI) ProtocolVersion() hexutil.Uint { + return hexutil.Uint(s.b.ProtocolVersion()) +}// ProtocolVersion returns the current Ethereum protocol version this node supports + +``` +View on GitHub → +

+
+ +--- + + + +### eth_resend + +Resend accepts an existing transaction and a new gas price and limit. It will remove +the given transaction from the pool and reinsert it with the new gas price and limit. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +sendArgs SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +gasPrice *hexutil.Big + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +gasLimit *hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_resend", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.resend(sendArgs,gasPrice,gasLimit); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { + if sendArgs.Nonce == nil { + return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec") + } + if err := sendArgs.setDefaults(ctx, s.b); err != nil { + return common.Hash{}, err + } + matchTx := sendArgs.toTransaction() + var price = matchTx.GasPrice() + if gasPrice != nil { + price = gasPrice.ToInt() + } + var gas = matchTx.Gas() + if gasLimit != nil { + gas = uint64(*gasLimit) + } + if err := checkTxFee(price, gas, s.b.RPCTxFeeCap()); err != nil { + return common.Hash{}, err + } + pending, err := s.b.GetPoolTransactions() + if err != nil { + return common.Hash{}, err + } + for _, p := // Resend accepts an existing transaction and a new gas price and limit. It will remove + // the given transaction from the pool and reinsert it with the new gas price and limit. + // Before replacing the old transaction, ensure the _new_ transaction fee is reasonable. + range pending { + var signer types.Signer = types.HomesteadSigner{} + if p.Protected() { + signer = types.NewEIP155Signer(p.ChainId()) + } + wantSigHash := signer.Hash(matchTx) + if pFrom, err := types.Sender(signer, p); err == nil && pFrom == sendArgs.From && signer.Hash(p) == wantSigHash { + if gasPrice != nil && (*big.Int)(gasPrice).Sign() != 0 { + sendArgs.GasPrice = gasPrice + } + if gasLimit != nil && *gasLimit != 0 { + sendArgs.Gas = gasLimit + } + signedTx, err := s.sign(sendArgs.From, sendArgs.toTransaction()) + if err != nil { + return common.Hash{}, err + } + if err = s.b.SendTx(ctx, signedTx); err != nil { + return common.Hash{}, err + } + return signedTx.Hash(), nil + } + } + return common.Hash{}, fmt.Errorf("transaction %#x not found", matchTx.Hash()) +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_sendRawTransaction + +SendRawTransaction will add the signed transaction to the transaction pool. +The sender is responsible for signing the transaction and using the correct nonce. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +encodedTx hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_sendRawTransaction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.sendRawTransaction(encodedTx); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) { + tx := new(types.Transaction) + if err := rlp.DecodeBytes(encodedTx, tx); err != nil { + return common.Hash{}, err + } + return SubmitTransaction(ctx, s.b, tx) +}// SendRawTransaction will add the signed transaction to the transaction pool. +// The sender is responsible for signing the transaction and using the correct nonce. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_sendTransaction + +SendTransaction creates a transaction for the given argument, sign it and submit it to the +transaction pool. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + + +common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_sendTransaction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.sendTransaction(args); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error) { + account := accounts.Account{Address: args.From} + wallet, err := s.b.AccountManager().Find(account) + if err != nil { + return common.Hash{}, err + } + if args.Nonce == nil { + s.nonceLock.LockAddr(args.From) + defer s.nonceLock.UnlockAddr(args.From) + } + if err := args.setDefaults(ctx, s.b); err != nil { + return common.Hash{}, err + } + tx := args.toTransaction() + signed, err := wallet.SignTx(account, tx, s.b.ChainConfig().GetChainID()) + if err != nil { + return common.Hash{}, err + } + return SubmitTransaction(ctx, s.b, signed) +}// SendTransaction creates a transaction for the given argument, sign it and submit it to the +// transaction pool. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_sign + +Sign calculates an ECDSA signature for: +keccack256("\x19Ethereum Signed Message:\n" + len(message) + message). + +Note, the produced signature conforms to the secp256k1 curve R, S and V values, +where the V value will be 27 or 28 for legacy reasons. + +The account associated with addr must be unlocked. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +addr common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +data hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_sign", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.sign(addr,data); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { + account := accounts.Account{Address: addr} + wallet, err := s.b.AccountManager().Find(account) + if err != nil { + return nil, err + } + signature, err := wallet.SignText(account, data) + if err == nil { + signature[64] += 27 + } + return signature, err +}// Sign calculates an ECDSA signature for: +// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message). +// +// Note, the produced signature conforms to the secp256k1 curve R, S and V values, +// where the V value will be 27 or 28 for legacy reasons. +// +// The account associated with addr must be unlocked. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + +``` +View on GitHub → +

+
+ +--- + + + +### eth_signTransaction + +SignTransaction will sign the given transaction with the from account. +The node needs to have the private key of the account corresponding with +the given from address and it needs to be unlocked. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + + +*SignTransactionResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - raw: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - tx: + - additionalProperties: `false` + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "raw": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "tx": { + "additionalProperties": false, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_signTransaction", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.signTransaction(args); + ``` + + +
Source code +

+```go +func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) { + if args.Gas == nil { + return nil, fmt.Errorf("gas not specified") + } + if args.GasPrice == nil { + return nil, fmt.Errorf("gasPrice not specified") + } + if args.Nonce == nil { + return nil, fmt.Errorf("nonce not specified") + } + if err := args.setDefaults(ctx, s.b); err != nil { + return nil, err + } + if err := checkTxFee(args.GasPrice.ToInt(), uint64(*args.Gas), s.b.RPCTxFeeCap()); err != nil { + return nil, err + } + tx, err := s.sign(args.From, args.toTransaction()) + if err != nil { + return nil, err + } + data, err := rlp.EncodeToBytes(tx) + if err != nil { + return nil, err + } + return &SignTransactionResult{data, tx}, nil +}// SignTransaction will sign the given transaction with the from account. +// The node needs to have the private key of the account corresponding with +// the given from address and it needs to be unlocked. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_submitHashRate + +SubmitHashrate can be used for remote miners to submit their hash rate. +This enables the node to report the combined hash rate of all miners +which submit work through this node. + +It accepts the miner hash rate and an identifier which must be unique +between nodes. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +rate hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +id common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_submitHashRate", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.submitHashRate(rate,id); + ``` + + +
Source code +

+```go +func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool { + if api.ethash.remote == nil { + return false + } + var done = make(chan struct{}, 1) + select { + case api.ethash.remote.submitRateCh <- &hashrate{done: done, rate: uint64(rate), id: id}: + case <-api.ethash.remote.exitCh: + return false + } + <-done + return true +}// SubmitHashrate can be used for remote miners to submit their hash rate. +// This enables the node to report the combined hash rate of all miners +// which submit work through this node. +// +// It accepts the miner hash rate and an identifier which must be unique +// between nodes. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_submitWork + +SubmitWork can be used by external miner to submit their POW solution. +It returns an indication if the work was accepted. +Note either an invalid solution, a stale work a non-existent work will return false. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +nonce types.BlockNonce + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +digest common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_submitWork", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.submitWork(nonce,hash,digest); + ``` + + +
Source code +

+```go +func (api *API) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) bool { + if api.ethash.remote == nil { + return false + } + var errc = make(chan error, 1) + select { + case api.ethash.remote.submitWorkCh <- &mineResult{nonce: nonce, mixDigest: digest, hash: hash, errc: errc}: + case <-api.ethash.remote.exitCh: + return false + } + err := <-errc + return err == nil +}// SubmitWork can be used by external miner to submit their POW solution. +// It returns an indication if the work was accepted. +// Note either an invalid solution, a stale work a non-existent work will return false. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_subscribe + +Subscribe creates a subscription to an event channel. +Subscriptions are not available over HTTP; they are only available over WS, IPC, and Process connections. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +subscriptionName RPCSubscriptionParamsName + + + Required: ✓ Yes + + + + + +__2:__ +subscriptionOptions interface{} + + + Required: No + + + + + + +#### Result + + + +subscriptionID rpc.ID + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_subscribe", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + eth.subscribe(subscriptionName,subscriptionOptions); + ``` + + +
Source code +

+```go +func (sub *RPCSubscription) Subscribe(subscriptionName RPCSubscriptionParamsName, subscriptionOptions interface{}) (subscriptionID rpc.ID, err error) { + return +}// Subscribe creates a subscription to an event channel. +// Subscriptions are not available over HTTP; they are only available over WS, IPC, and Process connections. + +``` +View on GitHub → +

+
+ +--- + + + +### eth_syncing + +Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not +yet received the latest block headers from its pears. In case it is synchronizing: +- startingBlock: block number this node started to synchronise from +- currentBlock: block number this node is currently importing +- highestBlock: block number of the highest block header this node has received from peers +- pulledStates: number of state entries processed until now +- knownStates: number of known state entries that still need to be pulled + + +#### Params (0) + +_None_ + +#### Result + + + +interface interface{} + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_syncing", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.syncing(); + ``` + + +
Source code +

+```go +func (s *PublicEthereumAPI) Syncing() (interface{}, error) { + progress := s.b.Downloader().Progress() + if progress.CurrentBlock >= progress.HighestBlock { + return false, nil + } + return map // Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not + // yet received the latest block headers from its pears. In case it is synchronizing: + // - startingBlock: block number this node started to synchronise from + // - currentBlock: block number this node is currently importing + // - highestBlock: block number of the highest block header this node has received from peers + // - pulledStates: number of state entries processed until now + // - knownStates: number of known state entries that still need to be pulled + [string]interface{}{"startingBlock": hexutil.Uint64(progress.StartingBlock), "currentBlock": hexutil.Uint64(progress.CurrentBlock), "highestBlock": hexutil.Uint64(progress.HighestBlock), "pulledStates": hexutil.Uint64(progress.PulledStates), "knownStates": hexutil.Uint64(progress.KnownStates)}, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### eth_uninstallFilter + +UninstallFilter removes the filter with the given filter id. + +https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +id rpc.ID + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_uninstallFilter", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.uninstallFilter(id); + ``` + + +
Source code +

+```go +func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool { + api.filtersMu.Lock() + f, found := api.filters[id] + if found { + delete(api.filters, id) + } + api.filtersMu.Unlock() + if found { + f.s.Unsubscribe() + } + return found +}// UninstallFilter removes the filter with the given filter id. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter + +``` +View on GitHub → +

+
+ +--- + + + +### eth_unsubscribe + +Unsubscribe terminates an existing subscription by ID. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +id rpc.ID + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "eth_unsubscribe", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + eth.unsubscribe(id); + ``` + + +
Source code +

+```go +func (sub *RPCSubscription) Unsubscribe(id rpc.ID) error { + return nil +}// Unsubscribe terminates an existing subscription by ID. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/ethash.md b/docs/JSON-RPC-API/modules/ethash.md new file mode 100755 index 0000000000..4bd3371876 --- /dev/null +++ b/docs/JSON-RPC-API/modules/ethash.md @@ -0,0 +1,519 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### ethash_getHashrate + +GetHashrate returns the current hashrate for local CPU miner and remote miner. + + +#### Params (0) + +_None_ + +#### Result + + + + +uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "ethash_getHashrate", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + ethash.getHashrate(); + ``` + + +
Source code +

+```go +func (api *API) GetHashrate() uint64 { + return uint64(api.ethash.Hashrate()) +}// GetHashrate returns the current hashrate for local CPU miner and remote miner. + +``` +View on GitHub → +

+
+ +--- + + + +### ethash_getWork + +GetWork returns a work package for external miner. + +The work package consists of 3 strings: + result[0] - 32 bytes hex encoded current block header pow-hash + result[1] - 32 bytes hex encoded seed hash used for DAG + result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty + result[3] - hex encoded block number + + +#### Params (0) + +_None_ + +#### Result + + + +num4string [4]string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - type: string + + + - maxItems: `4` + - minItems: `4` + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "type": [ + "string" + ] + } + ], + "maxItems": 4, + "minItems": 4, + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "ethash_getWork", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + ethash.getWork(); + ``` + + +
Source code +

+```go +func (api *API) GetWork() ([4]string, error) { + if api.ethash.remote == nil { + return [4]string{}, errors.New("not supported") + } + var ( + workCh = make(chan [4]string, 1) + errc = make(chan error, 1) + ) + select { + case api.ethash.remote.fetchWorkCh <- &sealWork{errc: errc, res: workCh}: + case <-api.ethash.remote.exitCh: + return [4]string{}, errEthashStopped + } + select { + case work := <-workCh: + return work, nil + case err := <-errc: + return [4]string{}, err + } +}// GetWork returns a work package for external miner. +// +// The work package consists of 3 strings: +// result[0] - 32 bytes hex encoded current block header pow-hash +// result[1] - 32 bytes hex encoded seed hash used for DAG +// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty +// result[3] - hex encoded block number + +``` +View on GitHub → +

+
+ +--- + + + +### ethash_submitHashRate + +SubmitHashrate can be used for remote miners to submit their hash rate. +This enables the node to report the combined hash rate of all miners +which submit work through this node. + +It accepts the miner hash rate and an identifier which must be unique +between nodes. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +rate hexutil.Uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +id common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "ethash_submitHashRate", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + ethash.submitHashRate(rate,id); + ``` + + +
Source code +

+```go +func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool { + if api.ethash.remote == nil { + return false + } + var done = make(chan struct{}, 1) + select { + case api.ethash.remote.submitRateCh <- &hashrate{done: done, rate: uint64(rate), id: id}: + case <-api.ethash.remote.exitCh: + return false + } + <-done + return true +}// SubmitHashrate can be used for remote miners to submit their hash rate. +// This enables the node to report the combined hash rate of all miners +// which submit work through this node. +// +// It accepts the miner hash rate and an identifier which must be unique +// between nodes. + +``` +View on GitHub → +

+
+ +--- + + + +### ethash_submitWork + +SubmitWork can be used by external miner to submit their POW solution. +It returns an indication if the work was accepted. +Note either an invalid solution, a stale work a non-existent work will return false. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +nonce types.BlockNonce + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +digest common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "ethash_submitWork", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + ethash.submitWork(nonce,hash,digest); + ``` + + +
Source code +

+```go +func (api *API) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) bool { + if api.ethash.remote == nil { + return false + } + var errc = make(chan error, 1) + select { + case api.ethash.remote.submitWorkCh <- &mineResult{nonce: nonce, mixDigest: digest, hash: hash, errc: errc}: + case <-api.ethash.remote.exitCh: + return false + } + err := <-errc + return err == nil +}// SubmitWork can be used by external miner to submit their POW solution. +// It returns an indication if the work was accepted. +// Note either an invalid solution, a stale work a non-existent work will return false. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/miner.md b/docs/JSON-RPC-API/modules/miner.md new file mode 100755 index 0000000000..dfcc3537a9 --- /dev/null +++ b/docs/JSON-RPC-API/modules/miner.md @@ -0,0 +1,556 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### miner_getHashrate + +GetHashrate returns the current hashrate of the miner. + + +#### Params (0) + +_None_ + +#### Result + + + + +uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_getHashrate", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.getHashrate(); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) GetHashrate() uint64 { + return api.e.miner.HashRate() +}// GetHashrate returns the current hashrate of the miner. + +``` +View on GitHub → +

+
+ +--- + + + +### miner_setEtherbase + +SetEtherbase sets the etherbase of the miner + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +etherbase common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_setEtherbase", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.setEtherbase(etherbase); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool { + api.e.SetEtherbase(etherbase) + return true +}// SetEtherbase sets the etherbase of the miner + +``` +View on GitHub → +

+
+ +--- + + + +### miner_setExtra + +SetExtra sets the extra data string that is included when this miner mines a block. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +extra string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_setExtra", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.setExtra(extra); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) SetExtra(extra string) (bool, error) { + if err := api.e.Miner().SetExtra([ // SetExtra sets the extra data string that is included when this miner mines a block. + ]byte(extra)); err != nil { + return false, err + } + return true, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### miner_setGasPrice + +SetGasPrice sets the minimum accepted gas price for the miner. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +gasPrice hexutil.Big + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_setGasPrice", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.setGasPrice(gasPrice); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool { + api.e.lock.Lock() + api.e.gasPrice = (*big.Int)(&gasPrice) + api.e.lock.Unlock() + api.e.txPool.SetGasPrice((*big.Int)(&gasPrice)) + return true +}// SetGasPrice sets the minimum accepted gas price for the miner. + +``` +View on GitHub → +

+
+ +--- + + + +### miner_setRecommitInterval + +SetRecommitInterval updates the interval for miner sealing work recommitting. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +interval int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_setRecommitInterval", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.setRecommitInterval(interval); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) SetRecommitInterval(interval int) { + api.e.Miner().SetRecommitInterval(time.Duration(interval) * time.Millisecond) +}// SetRecommitInterval updates the interval for miner sealing work recommitting. + +``` +View on GitHub → +

+
+ +--- + + + +### miner_start + +Start starts the miner with the given number of threads. If threads is nil, +the number of workers started is equal to the number of logical CPUs that are +usable by this process. If mining is already running, this method adjust the +number of threads allowed to use and updates the minimum price required by the +transaction pool. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +threads *int + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_start", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.start(threads); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) Start(threads *int) error { + if threads == nil { + return api.e.StartMining(runtime.NumCPU()) + } + return api.e.StartMining(*threads) +}// Start starts the miner with the given number of threads. If threads is nil, +// the number of workers started is equal to the number of logical CPUs that are +// usable by this process. If mining is already running, this method adjust the +// number of threads allowed to use and updates the minimum price required by the +// transaction pool. + +``` +View on GitHub → +

+
+ +--- + + + +### miner_stop + +Stop terminates the miner, both at the consensus engine level as well as at +the block creation level. + + +#### Params (0) + +_None_ + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "miner_stop", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + miner.stop(); + ``` + + +
Source code +

+```go +func (api *PrivateMinerAPI) Stop() { + api.e.StopMining() +}// Stop terminates the miner, both at the consensus engine level as well as at +// the block creation level. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/net.md b/docs/JSON-RPC-API/modules/net.md new file mode 100755 index 0000000000..f9c0501601 --- /dev/null +++ b/docs/JSON-RPC-API/modules/net.md @@ -0,0 +1,196 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### net_listening + +Listening returns an indication if the node is listening for network connections. + + +#### Params (0) + +_None_ + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "net_listening", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + net.listening(); + ``` + + +
Source code +

+```go +func (s *PublicNetAPI) Listening() bool { + return true +}// Listening returns an indication if the node is listening for network connections. + +``` +View on GitHub → +

+
+ +--- + + + +### net_peerCount + +PeerCount returns the number of connected peers + + +#### Params (0) + +_None_ + +#### Result + + + + +hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "net_peerCount", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + net.peerCount(); + ``` + + +
Source code +

+```go +func (s *PublicNetAPI) PeerCount() hexutil.Uint { + return hexutil.Uint(s.net.PeerCount()) +}// PeerCount returns the number of connected peers + +``` +View on GitHub → +

+
+ +--- + + + +### net_version + +Version returns the current ethereum protocol version. + + +#### Params (0) + +_None_ + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "net_version", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + net.version(); + ``` + + +
Source code +

+```go +func (s *PublicNetAPI) Version() string { + return fmt.Sprintf("%d", s.networkVersion) +}// Version returns the current ethereum protocol version. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/personal.md b/docs/JSON-RPC-API/modules/personal.md new file mode 100755 index 0000000000..dd2dc538a3 --- /dev/null +++ b/docs/JSON-RPC-API/modules/personal.md @@ -0,0 +1,2133 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### personal_deriveAccount + +DeriveAccount requests a HD wallet to derive a new account, optionally pinning +it for later reuse. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + +__2:__ +path string + + + Required: ✓ Yes + + + + + +__3:__ +pin *bool + + + Required: ✓ Yes + + + + + + +#### Result + + + + +accounts.Account + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - url: + - additionalProperties: `false` + - properties: + - Path: + - type: `string` + + - Scheme: + - type: `string` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "url": { + "additionalProperties": false, + "properties": { + "Path": { + "type": "string" + }, + "Scheme": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_deriveAccount", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.deriveAccount(url,path,pin); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) { + wallet, err := s.am.Wallet(url) + if err != nil { + return accounts.Account{}, err + } + derivPath, err := accounts.ParseDerivationPath(path) + if err != nil { + return accounts.Account{}, err + } + if pin == nil { + pin = new(bool) + } + return wallet.Derive(derivPath, *pin) +}// DeriveAccount requests a HD wallet to derive a new account, optionally pinning +// it for later reuse. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_ecRecover + +EcRecover returns the address for the account that was used to create the signature. +Note, this function is compatible with eth_sign and personal_sign. As such it recovers +the address of: +hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) +addr = ecrecover(hash, signature) + +Note, the signature must conform to the secp256k1 curve R, S and V values, where +the V value must be 27 or 28 for legacy reasons. + +https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +data hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +sig hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_ecRecover", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.ecRecover(data,sig); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error) { + if len(sig) != crypto.SignatureLength { + return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength) + } + if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 { + return common.Address{}, fmt.Errorf("invalid Ethereum signature (V is not 27 or 28)") + } + sig[crypto.RecoveryIDOffset] -= 27 + rpk, err := crypto.SigToPub(accounts.TextHash(data), sig) + if err != nil { + return common.Address{}, err + } + return crypto.PubkeyToAddress(*rpk), nil +}// EcRecover returns the address for the account that was used to create the signature. +// Note, this function is compatible with eth_sign and personal_sign. As such it recovers +// the address of: +// hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) +// addr = ecrecover(hash, signature) +// +// Note, the signature must conform to the secp256k1 curve R, S and V values, where +// the V value must be 27 or 28 for legacy reasons. +// +// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover + +``` +View on GitHub → +

+
+ +--- + + + +### personal_importRawKey + +ImportRawKey stores the given hex encoded ECDSA key into the key directory, +encrypting it with the passphrase. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +privkey string + + + Required: ✓ Yes + + + + + +__2:__ +password string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_importRawKey", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.importRawKey(privkey,password); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { + key, err := crypto.HexToECDSA(privkey) + if err != nil { + return common.Address{}, err + } + ks, err := fetchKeystore(s.am) + if err != nil { + return common.Address{}, err + } + acc, err := ks.ImportECDSA(key, password) + return acc.Address, err +}// ImportRawKey stores the given hex encoded ECDSA key into the key directory, +// encrypting it with the passphrase. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_initializeWallet + +InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_initializeWallet", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + personal.initializeWallet(url); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error) { + wallet, err := s.am.Wallet(url) + if err != nil { + return "", err + } + entropy, err := bip39.NewEntropy(256) + if err != nil { + return "", err + } + mnemonic, err := bip39.NewMnemonic(entropy) + if err != nil { + return "", err + } + seed := bip39.NewSeed(mnemonic, "") + switch wallet := wallet.( // InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key. + type) { + case *scwallet.Wallet: + return mnemonic, wallet.Initialize(seed) + default: + return "", fmt.Errorf("specified wallet does not support initialization") + } +} +``` +View on GitHub → +

+
+ +--- + + + +### personal_listAccounts + +listAccounts will return a list of addresses for accounts this node manages. + + +#### Params (0) + +_None_ + +#### Result + + + +commonAddress []common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_listAccounts", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + personal.listAccounts(); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) ListAccounts() [ // listAccounts will return a list of addresses for accounts this node manages. +]common.Address { + return s.am.Accounts() +} +``` +View on GitHub → +

+
+ +--- + + + +### personal_listWallets + +ListWallets will return a list of wallets this node manages. + + +#### Params (0) + +_None_ + +#### Result + + + +rawWallet []rawWallet + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - accounts: + - items: + - additionalProperties: `false` + - properties: + - address: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - url: + - additionalProperties: `false` + - properties: + - Path: + - type: `string` + + - Scheme: + - type: `string` + + + - type: `object` + + + - type: `object` + + - type: `array` + + - failure: + - type: `string` + + - status: + - type: `string` + + - url: + - type: `string` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "accounts": { + "items": { + "additionalProperties": false, + "properties": { + "address": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "url": { + "additionalProperties": false, + "properties": { + "Path": { + "type": "string" + }, + "Scheme": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "type": "array" + }, + "failure": { + "type": "string" + }, + "status": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_listWallets", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + personal.listWallets(); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) ListWallets() [ // ListWallets will return a list of wallets this node manages. +]rawWallet { + wallets := make([]rawWallet, 0) + for _, wallet := range s.am.Wallets() { + status, failure := wallet.Status() + raw := rawWallet{URL: wallet.URL().String(), Status: status, Accounts: wallet.Accounts()} + if failure != nil { + raw.Failure = failure.Error() + } + wallets = append(wallets, raw) + } + return wallets +} +``` +View on GitHub → +

+
+ +--- + + + +### personal_lockAccount + +LockAccount will lock the account associated with the given address when it's unlocked. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +addr common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_lockAccount", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + personal.lockAccount(addr); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool { + if ks, err := fetchKeystore(s.am); err == nil { + return ks.Lock(addr) == nil + } + return false +}// LockAccount will lock the account associated with the given address when it's unlocked. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_newAccount + +NewAccount will create a new account and returns the address for the new account. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +password string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_newAccount", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + personal.newAccount(password); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error) { + ks, err := fetchKeystore(s.am) + if err != nil { + return common.Address{}, err + } + acc, err := ks.NewAccount(password) + if err == nil { + log.Info("Your new key was generated", "address", acc.Address) + log.Warn("Please backup your key file!", "path", acc.URL.Path) + log.Warn("Please remember your password!") + return acc.Address, nil + } + return common.Address{}, err +}// NewAccount will create a new account and returns the address for the new account. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_openWallet + +OpenWallet initiates a hardware wallet opening procedure, establishing a USB +connection and attempting to authenticate via the provided passphrase. Note, +the method may return an extra challenge requiring a second open (e.g. the +Trezor PIN matrix challenge). + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + +__2:__ +passphrase *string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_openWallet", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.openWallet(url,passphrase); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error { + wallet, err := s.am.Wallet(url) + if err != nil { + return err + } + pass := "" + if passphrase != nil { + pass = *passphrase + } + return wallet.Open(pass) +}// OpenWallet initiates a hardware wallet opening procedure, establishing a USB +// connection and attempting to authenticate via the provided passphrase. Note, +// the method may return an extra challenge requiring a second open (e.g. the +// Trezor PIN matrix challenge). + +``` +View on GitHub → +

+
+ +--- + + + +### personal_sendTransaction + +SendTransaction will create a transaction from the given arguments and +tries to sign it with the key associated with args.To. If the given passwd isn't +able to decrypt the key it fails. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +passwd string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_sendTransaction", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.sendTransaction(args,passwd); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { + if args.Nonce == nil { + s.nonceLock.LockAddr(args.From) + defer s.nonceLock.UnlockAddr(args.From) + } + signed, err := s.signTransaction(ctx, &args, passwd) + if err != nil { + log.Warn("Failed transaction send attempt", "from", args.From, "to", args.To, "value", args.Value.ToInt(), "err", err) + return common.Hash{}, err + } + return SubmitTransaction(ctx, s.b, signed) +}// SendTransaction will create a transaction from the given arguments and +// tries to sign it with the key associated with args.To. If the given passwd isn't +// able to decrypt the key it fails. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_sign + +Sign calculates an Ethereum ECDSA signature for: +keccack256("\x19Ethereum Signed Message:\n" + len(message) + message)) + +Note, the produced signature conforms to the secp256k1 curve R, S and V values, +where the V value will be 27 or 28 for legacy reasons. + +The key used to calculate the signature is decrypted with the given password. + +https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +data hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +addr common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__3:__ +passwd string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_sign", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.sign(data,addr,passwd); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error) { + account := accounts.Account{Address: addr} + wallet, err := s.b.AccountManager().Find(account) + if err != nil { + return nil, err + } + signature, err := wallet.SignTextWithPassphrase(account, passwd, data) + if err != nil { + log.Warn("Failed data sign attempt", "address", addr, "err", err) + return nil, err + } + signature[crypto.RecoveryIDOffset] += 27 + return signature, nil +}// Sign calculates an Ethereum ECDSA signature for: +// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message)) +// +// Note, the produced signature conforms to the secp256k1 curve R, S and V values, +// where the V value will be 27 or 28 for legacy reasons. +// +// The key used to calculate the signature is decrypted with the given password. +// +// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + +``` +View on GitHub → +

+
+ +--- + + + +### personal_signAndSendTransaction + +SignAndSendTransaction was renamed to SendTransaction. This method is deprecated +and will be removed in the future. It primary goal is to give clients time to update. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +passwd string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_signAndSendTransaction", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.signAndSendTransaction(args,passwd); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { + return s.SendTransaction(ctx, args, passwd) +}// SignAndSendTransaction was renamed to SendTransaction. This method is deprecated +// and will be removed in the future. It primary goal is to give clients time to update. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_signTransaction + +SignTransaction will create a transaction from the given arguments and +tries to sign it with the key associated with args.To. If the given passwd isn't +able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast +to other nodes + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +args SendTxArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +passwd string + + + Required: ✓ Yes + + + + + + +#### Result + + + + +*SignTransactionResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - raw: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - tx: + - additionalProperties: `false` + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "raw": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "tx": { + "additionalProperties": false, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_signTransaction", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.signTransaction(args,passwd); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error) { + if args.Gas == nil { + return nil, fmt.Errorf("gas not specified") + } + if args.GasPrice == nil { + return nil, fmt.Errorf("gasPrice not specified") + } + if args.Nonce == nil { + return nil, fmt.Errorf("nonce not specified") + } + if err := checkTxFee(args.GasPrice.ToInt(), uint64(*args.Gas), s.b.RPCTxFeeCap()); err != nil { + return nil, err + } + signed, err := s.signTransaction(ctx, &args, passwd) + if err != nil { + log.Warn("Failed transaction sign attempt", "from", args.From, "to", args.To, "value", args.Value.ToInt(), "err", err) + return nil, err + } + data, err := rlp.EncodeToBytes(signed) + if err != nil { + return nil, err + } + return &SignTransactionResult{data, signed}, nil +}// SignTransaction will create a transaction from the given arguments and +// tries to sign it with the key associated with args.To. If the given passwd isn't +// able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast +// to other nodes + +``` +View on GitHub → +

+
+ +--- + + + +### personal_unlockAccount + +UnlockAccount will unlock the account associated with the given address with +the given password for duration seconds. If duration is nil it will use a +default of 300 seconds. It returns an indication if the account was unlocked. + + +#### Params (3) + +Parameters must be given _by position_. + + +__1:__ +addr common.Address + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash POINTER` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash POINTER", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +password string + + + Required: ✓ Yes + + + + + +__3:__ +duration *uint64 + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of the integer` + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of the integer", + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +bool + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_unlockAccount", "params": [, , ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.unlockAccount(addr,password,duration); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error) { + if s.b.ExtRPCEnabled() && !s.b.AccountManager().Config().InsecureUnlockAllowed { + return false, errors.New("account unlock with HTTP access is forbidden") + } + const max = uint64(time.Duration(math.MaxInt64) / time.Second) + var d time.Duration + if duration == nil { + d = 300 * time.Second + } else if *duration > max { + return false, errors.New("unlock duration too large") + } else { + d = time.Duration(*duration) * time.Second + } + ks, err := fetchKeystore(s.am) + if err != nil { + return false, err + } + err = ks.TimedUnlock(accounts.Account{Address: addr}, password, d) + if err != nil { + log.Warn("Failed account unlock attempt", "address", addr, "err", err) + } + return err == nil, err +}// UnlockAccount will unlock the account associated with the given address with +// the given password for duration seconds. If duration is nil it will use a +// default of 300 seconds. It returns an indication if the account was unlocked. + +``` +View on GitHub → +

+
+ +--- + + + +### personal_unpair + +Unpair deletes a pairing between wallet and geth. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +url string + + + Required: ✓ Yes + + + + + +__2:__ +pin string + + + Required: ✓ Yes + + + + + + +#### Result + +_None_ + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "personal_unpair", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + personal.unpair(url,pin); + ``` + + +
Source code +

+```go +func (s *PrivateAccountAPI) Unpair(ctx context.Context, url string, pin string) error { + wallet, err := s.am.Wallet(url) + if err != nil { + return err + } + switch wallet := wallet.( // Unpair deletes a pairing between wallet and geth. + type) { + case *scwallet.Wallet: + return wallet.Unpair([]byte(pin)) + default: + return fmt.Errorf("specified wallet does not support pairing") + } +} +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/trace.md b/docs/JSON-RPC-API/modules/trace.md new file mode 100755 index 0000000000..c182c1c806 --- /dev/null +++ b/docs/JSON-RPC-API/modules/trace.md @@ -0,0 +1,791 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### trace_block + +Block returns the structured logs created during the execution of +EVM and returns them as a JSON object. +The correct name will be TraceBlockByNumber, though we want to be compatible with Parity trace module. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +number rpc.BlockNumber + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - oneOf: + + - description: `The block height description` + - enum: earliest, latest, pending + - title: `blockNumberTag` + - type: string + + + - description: `Hex representation of a uint64` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: string + + + - title: `blockNumberIdentifier` + + + ``` + +=== "Raw" + + ``` Raw + { + "oneOf": [ + { + "description": "The block height description", + "enum": [ + "earliest", + "latest", + "pending" + ], + "title": "blockNumberTag", + "type": [ + "string" + ] + }, + { + "description": "Hex representation of a uint64", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": [ + "string" + ] + } + ], + "title": "blockNumberIdentifier" + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +interface []interface{} + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `true` + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": true + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "trace_block", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + trace.block(number,config); + ``` + + +
Source code +

+```go +func (api *PrivateTraceAPI) Block(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([ // Block returns the structured logs created during the execution of +// EVM and returns them as a JSON object. +// The correct name will be TraceBlockByNumber, though we want to be compatible with Parity trace module. +]interface{}, error) { + var block *types.Block + switch number { + case rpc.PendingBlockNumber: + block = api.eth.miner.PendingBlock() + case rpc.LatestBlockNumber: + block = api.eth.blockchain.CurrentBlock() + default: + block = api.eth.blockchain.GetBlockByNumber(uint64(number)) + } + if block == nil { + return nil, fmt.Errorf("block #%d not found", number) + } + config = setConfigTracerToParity(config) + traceResults, err := traceBlockByNumber(ctx, api.eth, number, config) + if err != nil { + return nil, err + } + traceReward, err := traceBlockReward(ctx, api.eth, block, config) + if err != nil { + return nil, err + } + traceUncleRewards, err := traceBlockUncleRewards(ctx, api.eth, block, config) + if err != nil { + return nil, err + } + results := [ // Fetch the block that we want to trace + ]interface{}{} + for _, result := range traceResults { + var tmp []interface{} + if err := json.Unmarshal(result.Result.(json.RawMessage), &tmp); err != nil { + return nil, err + } + results = append(results, tmp...) + } + results = append(results, traceReward) + for _, uncleReward := range traceUncleRewards { + results = append(results, uncleReward) + } + return results, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### trace_filter + + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +args ethapi.CallArgs + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - data: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "data": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +txTraceResult []*txTraceResult + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - items: + + - additionalProperties: `false` + - properties: + - error: + - type: `string` + + - result: + - additionalProperties: `true` + + + - type: object + + + - type: array + + + ``` + +=== "Raw" + + ``` Raw + { + "items": [ + { + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + }, + "result": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ], + "type": [ + "array" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "trace_filter", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + trace.filter(args,config); + ``` + + +
Source code +

+```go +func (api *PrivateTraceAPI) Filter(ctx context.Context, args ethapi.CallArgs, config *TraceConfig) ([]*txTraceResult, error) { + return nil, nil +} +``` +View on GitHub → +

+
+ +--- + + + +### trace_transaction + +Transaction returns the structured logs created during the execution of EVM +and returns them as a JSON object. + + +#### Params (2) + +Parameters must be given _by position_. + + +__1:__ +hash common.Hash + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of a Keccak 256 hash` + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of a Keccak 256 hash", + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": [ + "string" + ] + } + ``` + + + + +__2:__ +config *TraceConfig + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - additionalProperties: `false` + - properties: + - Debug: + - type: `boolean` + + - DisableMemory: + - type: `boolean` + + - DisableReturnData: + - type: `boolean` + + - DisableStack: + - type: `boolean` + + - DisableStorage: + - type: `boolean` + + - Limit: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Reexec: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - Timeout: + - type: `string` + + - Tracer: + - type: `string` + + - overrides: + - additionalProperties: `true` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "additionalProperties": false, + "properties": { + "Debug": { + "type": "boolean" + }, + "DisableMemory": { + "type": "boolean" + }, + "DisableReturnData": { + "type": "boolean" + }, + "DisableStack": { + "type": "boolean" + }, + "DisableStorage": { + "type": "boolean" + }, + "Limit": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Reexec": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "Timeout": { + "type": "string" + }, + "Tracer": { + "type": "string" + }, + "overrides": { + "additionalProperties": true + } + }, + "type": [ + "object" + ] + } + ``` + + + + + +#### Result + + + +interface interface{} + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "trace_transaction", "params": [, ]}' + ``` + +=== "Javascript Console" + + ``` js + trace.transaction(hash,config); + ``` + + +
Source code +

+```go +func (api *PrivateTraceAPI) Transaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { + config = setConfigTracerToParity(config) + return traceTransaction(ctx, api.eth, hash, config) +}// Transaction returns the structured logs created during the execution of EVM +// and returns them as a JSON object. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/txpool.md b/docs/JSON-RPC-API/modules/txpool.md new file mode 100755 index 0000000000..8cd8063507 --- /dev/null +++ b/docs/JSON-RPC-API/modules/txpool.md @@ -0,0 +1,489 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### txpool_content + +Content returns the transactions contained within the transaction pool. + + +#### Params (0) + +_None_ + +#### Result + + + +mapstringmapstringmapstringRPCTransaction map[string]map[string]map[string]*RPCTransaction + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - patternProperties: + - .*: + - patternProperties: + - .*: + - patternProperties: + - .*: + - additionalProperties: `false` + - properties: + - blockHash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - blockNumber: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - from: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - gas: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - gasPrice: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - hash: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - input: + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: `string` + + - nonce: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - r: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - s: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - to: + - pattern: `^0x[a-fA-F\d]{64}$` + - title: `keccak` + - type: `string` + + - transactionIndex: + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint64` + - type: `string` + + - v: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + - value: + - pattern: `^0x[a-fA-F0-9]+$` + - title: `integer` + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "patternProperties": { + ".*": { + "patternProperties": { + ".*": { + "patternProperties": { + ".*": { + "additionalProperties": false, + "properties": { + "blockHash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "blockNumber": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "from": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "gas": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "gasPrice": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "hash": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "input": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": "string" + }, + "nonce": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "r": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "s": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "to": { + "pattern": "^0x[a-fA-F\\d]{64}$", + "title": "keccak", + "type": "string" + }, + "transactionIndex": { + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint64", + "type": "string" + }, + "v": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + }, + "value": { + "pattern": "^0x[a-fA-F0-9]+$", + "title": "integer", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "txpool_content", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + txpool.content(); + ``` + + +
Source code +

+```go +func (s *PublicTxPoolAPI) Content() map // Content returns the transactions contained within the transaction pool. +[string]map[string]map[string]*RPCTransaction { + content := map[string]map[string]map[string]*RPCTransaction{"pending": make(map[string]map[string]*RPCTransaction), "queued": make(map[string]map[string]*RPCTransaction)} + pending, queue := s.b.TxPoolContent() + for account, txs := range pending { + dump := make(map[string]*RPCTransaction) + for _, tx := range txs { + dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx) + } + content["pending"][account.Hex()] = dump + } + for account, txs := range queue { + dump := make(map[string]*RPCTransaction) + for _, tx := range txs { + dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx) + } + content["queued"][account.Hex()] = dump + } + return content +} +``` +View on GitHub → +

+
+ +--- + + + +### txpool_inspect + +Inspect retrieves the content of the transaction pool and flattens it into an +easily inspectable list. + + +#### Params (0) + +_None_ + +#### Result + + + +mapstringmapstringmapstringstring map[string]map[string]map[string]string + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - patternProperties: + - .*: + - patternProperties: + - .*: + - patternProperties: + - .*: + - type: `string` + + + - type: `object` + + + - type: `object` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "patternProperties": { + ".*": { + "patternProperties": { + ".*": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "txpool_inspect", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + txpool.inspect(); + ``` + + +
Source code +

+```go +func (s *PublicTxPoolAPI) Inspect() map // Inspect retrieves the content of the transaction pool and flattens it into an +// easily inspectable list. +[string]map[string]map[string]string { + content := map[string]map[string]map[string]string{"pending": make(map[string]map[string]string), "queued": make(map[string]map[string]string)} + pending, queue := s.b.TxPoolContent() + var format = func(tx *types.Transaction) string { + if to := tx.To(); to != nil { + return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To().Hex(), tx.Value(), tx.Gas(), tx.GasPrice()) + } + return fmt.Sprintf("contract creation: %v wei + %v gas × %v wei", tx.Value(), tx.Gas(), tx.GasPrice()) + } + for account, txs := // Define a formatter to flatten a transaction into a string + range pending { + dump := make(map[string]string) + for _, tx := range txs { + dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx) + } + content["pending"][account.Hex()] = dump + } + for account, txs := range queue { + dump := make(map[string]string) + for _, tx := range txs { + dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx) + } + content["queued"][account.Hex()] = dump + } + return content +} +``` +View on GitHub → +

+
+ +--- + + + +### txpool_status + +Status returns the number of pending and queued transaction in the pool. + + +#### Params (0) + +_None_ + +#### Result + + + +mapstringhexutilUint map[string]hexutil.Uint + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - patternProperties: + - .*: + - description: `Hex representation of a uint` + - pattern: `^0x([a-fA-F\d])+$` + - title: `uint` + - type: `string` + + + - type: object + + + ``` + +=== "Raw" + + ``` Raw + { + "patternProperties": { + ".*": { + "description": "Hex representation of a uint", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "uint", + "type": "string" + } + }, + "type": [ + "object" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "txpool_status", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + txpool.status(); + ``` + + +
Source code +

+```go +func (s *PublicTxPoolAPI) Status() map // Status returns the number of pending and queued transaction in the pool. +[string]hexutil.Uint { + pending, queue := s.b.Stats() + return map[string]hexutil.Uint{"pending": hexutil.Uint(pending), "queued": hexutil.Uint(queue)} +} +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/JSON-RPC-API/modules/web3.md b/docs/JSON-RPC-API/modules/web3.md new file mode 100755 index 0000000000..8492cdef78 --- /dev/null +++ b/docs/JSON-RPC-API/modules/web3.md @@ -0,0 +1,182 @@ + + + + + + + +| Entity | Version | +| --- | --- | +| Source | 1.11.22-unstable/generated-at:2021-01-23T04:50:40-06:00 | +| OpenRPC | 1.2.6 | + +--- + + + + +### web3_clientVersion + +ClientVersion returns the node name + + +#### Params (0) + +_None_ + +#### Result + + + + +string + + + Required: ✓ Yes + + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "web3_clientVersion", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + web3.clientVersion(); + ``` + + +
Source code +

+```go +func (s *publicWeb3API) ClientVersion() string { + return s.stack.Server().Name +}// ClientVersion returns the node name + +``` +View on GitHub → +

+
+ +--- + + + +### web3_sha3 + +Sha3 applies the ethereum sha3 implementation on the input. +It assumes the input is hex encoded. + + +#### Params (1) + +Parameters must be given _by position_. + + +__1:__ +input hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + + + +#### Result + + + + +hexutil.Bytes + + + Required: ✓ Yes + + +=== "Schema" + + ``` Schema + + - description: `Hex representation of some bytes` + - pattern: `^0x([a-fA-F\d])+$` + - title: `dataWord` + - type: string + + + ``` + +=== "Raw" + + ``` Raw + { + "description": "Hex representation of some bytes", + "pattern": "^0x([a-fA-F\\d])+$", + "title": "dataWord", + "type": [ + "string" + ] + } + ``` + + + +#### Client Method Invocation Examples + +=== "Shell" + + ``` shell + curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "web3_sha3", "params": []}' + ``` + +=== "Javascript Console" + + ``` js + web3.sha3(input); + ``` + + +
Source code +

+```go +func (s *publicWeb3API) Sha3(input hexutil.Bytes) hexutil.Bytes { + return crypto.Keccak256(input) +}// Sha3 applies the ethereum sha3 implementation on the input. +// It assumes the input is hex encoded. + +``` +View on GitHub → +

+
+ +--- + diff --git a/docs/apis/openrpc.md b/docs/JSON-RPC-API/openrpc.md similarity index 90% rename from docs/apis/openrpc.md rename to docs/JSON-RPC-API/openrpc.md index de85f79b7a..db0be057ae 100644 --- a/docs/apis/openrpc.md +++ b/docs/JSON-RPC-API/openrpc.md @@ -1,10 +1,14 @@ --- +title: OpenRPC Discovery hide: - toc # Hide table of contents --- # OpenRPC +!!! tldr "TLDR" + The `rpc.discover` returns an API service description structured per the [OpenRPC specification](https://github.com/open-rpc/spec/blob/master/spec.md). + ## Discovery CoreGeth supports [OpenRPC's Service Discovery method](https://spec.open-rpc.org/#service-discovery-method), enabling efficient and well-spec'd JSON RPC interfacing and tooling. This method follows the established JSON RPC patterns, and is accessible via HTTP, WebSocket, IPC, and console servers. To use this method: diff --git a/docs/assets/css/extra.css b/docs/assets/css/extra.css new file mode 100644 index 0000000000..04b92b5cf1 --- /dev/null +++ b/docs/assets/css/extra.css @@ -0,0 +1,3 @@ +nav.md-nav.md-nav--secondary > ul ul { + display: none; +} diff --git a/docs/core/alltools.md b/docs/core/alltools.md index 21d6726e80..d75c6b5439 100644 --- a/docs/core/alltools.md +++ b/docs/core/alltools.md @@ -1,6 +1,7 @@ --- hide: - toc # Hide table of contents +title: Included Tools --- ## Executables diff --git a/docs/core/index.md b/docs/core/index.md new file mode 100644 index 0000000000..82e0c47bb5 --- /dev/null +++ b/docs/core/index.md @@ -0,0 +1,164 @@ +--- +title: About +--- + +# Core-Geth + +CoreGeth is sponsored by and maintained with the leadership of [ETC Labs](https://etclabs.org) with an obvious core intention of stewarding +the Ethereum Classic opinion that the reversion of transactions in inconvenient situations shouldn't be permissible. + +But the spirit of the project intends to reach beyond Ethereum and Ethereum Classic, and indeed to reimagine an EVM node software that +approaches the EVM-based protocols as technology that can -- and should -- be generalizable. + +While CoreGeth inherits from and exposes complete feature parity with Ethereum Foundation's :registered: [ethereum/go-ethereum](https://github.com/ethereum/go-ethereum), +there are quite few things that make CoreGeth unique. + +## Additional Features + +CoreGeth maintainers are [regular](https://github.com/ethereum/go-ethereum/pulls?q=author%3Ameowsbits) [contributors](https://github.com/ethereum/go-ethereum/pulls?q=author%3Aziogaschr+) [upstream](https://github.com/ethereum/go-ethereum/pulls?q=author%3Aiquidus+), but not all CoreGeth features are practicable or accepted there. The following categories document features specific to CoreGeth that ethereum/go-ethereum can't, or won't, implement. + +### Extended RPC API + +#### Comprehensive RPC API Service Discovery + +CoreGeth features a synthetic build/+runtime service discovery API, allowing you to get a [well structured](https://open-rpc.org/) +description of _all_ available methods, their parameters, and results. + +!!! tip "RPC Service Documentation" + For complete documentation of the available JSON RPC APIs, please see the [JSON RPC API page](/JSON-RPC-API/). + +#### Additional methods and options + +- Available `trace_block` and `trace_transaction` RPC API congruent to the OpenEthereum API (including a 1000x performance improvement vs. go-ethereum's `trace_transaction` in some cases). + + _TODO:_ Talk more about this! And examples! +- Added `debug_removePendingTransaction` API method ([#203](https://github.com/etclabscore/core-geth/pull/203/files)) +- Comprehensive service discovery with OpenRPC through method `rpc.discover`. + +### Extended CLI + +- `--eth.protocols` configures `eth/x` protocol prioritization, eg. `65,64,63`. + +### EVMCv6 Support + +- EVMCv6 support allows use with external EVMs (including EWASM). +- See [Running Geth with an External VM](./core/evmc) for more information. + +### Remote Store for Ancient Chaindata + +- Remote freezer, store your `ancient` data on Amazon S3 or Storj. + - _TODO_: Talk more about this, provide examples. + +### Developer Features: Tools + +- A developer mode `--dev.pow` able to mock Proof-of-Work block schemas and production at representative Poisson intervals. + + `--dev.poisson` configures Poisson intervals for block emission +- Chain configuration acceptance of OpenEthereum and go-ethereum chain configuration files (and the extensibility to support _any_ chain configuration schema). +- At the code level, a 1:1 EIP/ECIP specification to implementation pattern; disentangling Ethereum Foundation :registered: hard fork opinions from code. This yields more readable code, more precise naming and conceptual representation, more testable code, and a massive step toward Ethereum as a generalizeable technology. +- `copydb` will default to a sane fallback value if no parameter is passed for the second `` argument. +- The `faucet` command supports an `--attach` option allowing the program to reference an already-running node instance + (assuming it has an available RPC API) instead of restricting the faucet to a dedicated light client. Likewise, a `--syncmode=[full|fast|light]` option is provided for networks where _LES_ support may be lacking. + +### Risk Management + +- [Public](https://ci.etccore.in/blue/organizations/jenkins/core-geth-regression/activity) chaindata [regression testing](https://github.com/etclabscore/core-geth/blob/master/Jenkinsfile) run at each push to `master`. + +### Extended _Improvement Proposal_ Support (EIP, ECIP, *IP) + +- Myriad additional ECIP support: + + ECBP1100 (aka MESS, an "artificial finality" gadget) + + ECIP1099 (DAG growth limit) + + ECIP1014 (defuse difficulty bomb), etc. :wink: + +- Out-of-the-box support for Ethereum Classic, EtherSocial, Social, and MIX networks. + Chain configs are selected as `./build/bin/geth --`. For a list of supported networks and their CLI options, use `./build/bin/geth --help`. + +## Divergent Design + +How CoreGeth is built differently than ethereum/go-ethereum. + +### Developer Features: Code + +One of CoreGeth's most significant divergences from ethereum/go-ethereum at the code level is a reimagining (read: _massive overhaul_) of the `ChainConfig` data type and its methods. + +At _ethereum/go-ethereum_ the `ChainConfig` makes protocol-facing feature activation decisions as follows: + +```go +blockNumber := big.NewInt(0) +config := params.MainnetChainConfig +if config.IsByzantium(blockNumber) { + // do a special thing for post-Byzantium chains +} +``` + +This, for the uninitiated developer, raises some questions: +- What's Byzantium? +- Which of the nine distinct Byzantium upgrades is this implementing? +- Does feature `Byzantium.X` depend on also having `Byzantium.Y` activated? + +The developers of ethereum/go-ethereum have made this architectural decision because ethereum/go-ethereum is _only designed +and intended_ to support one chain: _Ethereum_. From this perspective, configurability presents a risk rather than a desirable feature. + +While a hardcoded feature-group pattern (ie _hardfork upgrades_) in some ways mitigates a risk of "movable parts," and undesirable or unintended feature interactions, +it also presents a massive hurdle for extensibility. + +!!! seealso "A metaphor" + Consider the metaphor of the wiring the electrical circuits of a house. + + With ethereum/go-ethereum's design, the television, the kitchen lights, the garbage disposal, and the garage door are all controlled by the same switch. If you want to watch TV, + you also have to have the kitchen lights on, the garbage disposal running, and the garage door open. + + For an electrician whose _only concern_ is meeting the arbitrary specifications of an eccentric customer who _demands_ that their + house work in this very strange way (forever), hard-installing these devices on the same circuit makes sense. The electrician commits to only + serving one customer with this house, and the customer commits to their wiring preference. + + But, for anyone _else_ looking at this house, the design is absurd. Another home-owner may want to use a TV + and a garage door in their own designs, but maybe don't want them to be codependent. Building the feature of a garbage disposal as being inextricable from a TV -- + from the perspective of a technologist (or consumer products designer, or anyone interested in these technologies as generalizeable things, rather than details of an eccentric house) -- + this arbitrary feature-bundling is patently absurd. + + This is an Ethereum-as-technology perspective versus an Ethereum-as-network perspective, and reimagining a home where you can have the kitchen lights on + without also turning the TV on is one of the things CoreGeth does. + +This same code as above, in CoreGeth, would look as follows: + +```go +blockNumber := big.NewInt(0) +config := params.MainnetChainConfig +if config.IsEnabled(config.EIP658Transition, blockNumber) { + // do a special thing for post-EIP658 chains +} +``` + +!!! example "Interface Reference" + The complete interface pattern for supported feature methods + can be found here: https://github.com/etclabscore/core-geth/blob/master/params/types/ctypes/configurator_iface.go + +The implicit feature-group `Byzantium` is deconstructed into its composite features, using EIPs and ECIP specifications as conceptual delineations as well as naming patterns. + +This makes the implementation of Improvement Proposal specifications referencable and readily testable. You can look up the implementation of EIP658 and see directly how it modifies transaction encoding, without having to disambiguate its implementation from state trie cleaning, gas repricing, opcode additions, block reward changes, or difficulty adjustments. + You can test block reward modifications without _also_ having to test difficulty adjustments (... and state root differences, and ...). + +!!! hint "Configuration Data Types" + Not only does CoreGeth's interface pattern provide descriptive, articulate code; it also + allows for the support of _arbitrary configuration data types_; CoreGeth supports configuration via + ethereum/go-ethereum's `genesis` data structure (eg. `geth dumpgenesis genesis.json`) as well as OpenEthereum's JSON configuration schema. + Extending support for any other configuration schema is likewise possible. + +As should be obvious by now, this also allows selective feature adoption for configurations that don't want to bundle changes exactly like the Ethereum Foundation has. + For example, without this decomposition, Ethereum Classic would have had to accept and (re)implement the Difficulty Bomb _and_ reduce block rewards in order to adopt a change to the RLP encoding of transaction receipts change :exploding_head: + + +## Limitations + +Things ethereum/go-ethereum can or will do that CoreGeth won't, or doesn't by default. + +- A huge and diverse number of default pipeline-delivered build targets. + This is a defaults and configuration sanity challenge for CoreGeth. We're vastly outnumbered by ethereum/go-ethereum maintainers + and contributors, and ensuring proper delivery of a whole bunch of diverse artifacts is beyond our capacity. + With that said, just because CoreGeth doesn't provide artifacts for a given architecture or OS doesn't mean it can't. + If ethereum/go-ethereum can build and package for it, then with some elbow grease, CoreGeth can too. +- The `puppeth` CLI program has been [removed](https://github.com/etclabscore/core-geth/pull/270). This is a "wizard"-style interactive program that helps beginners + configure chain and network settings. +- Trim absolute file paths during build. As of a [somewhat-recent](TODO) Go version, `go build` provides a `-trim` flag + which reduces the size of the binaries and anonymizes the build environment. This was removed because stripping file paths + caused automatic service discovery features to break (they depend, in part, on source file path availability for build-time AST and runtime reflection). diff --git a/docs/developers/build-from-source.md b/docs/developers/build-from-source.md index 3de2f75917..b07fced4b4 100644 --- a/docs/developers/build-from-source.md +++ b/docs/developers/build-from-source.md @@ -1,6 +1,10 @@ +--- +title: Build from Source +--- + ## Dependencies -- Make sure your system has __Go__ installed. Version 1.15+ is recommended. https://golang.org/doc/install +- Make sure your system has __Go__ installed. Version __1.15.5+__ is recommended. https://golang.org/doc/install - Make sure your system has a C compiler installed. For example, with Linux Ubuntu: ```shell @@ -32,4 +36,4 @@ Or with all tools: ```shell $ docker build -t core-geth-alltools -f Dockerfile.alltools . -``` \ No newline at end of file +``` diff --git a/docs/developers/create-new-release.md b/docs/developers/create-new-release.md index c481732373..514c884c3d 100644 --- a/docs/developers/create-new-release.md +++ b/docs/developers/create-new-release.md @@ -1,9 +1,10 @@ --- hide: - toc # Hide table of contents +title: Publishing a Release --- -# Developers: How to make a release +# Developers: How to Make a Release - [ ] Decide what the new version should be. In this example, __`v1.11.16[-stable]`__ will be used. - [ ] `git checkout master` diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index e75fb7d987..d86eeef4dc 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -1,3 +1,10 @@ +--- +title: Installation +--- + +!!! tip "Build from Source" + Instructions to build from source can be found [here](/developers/build-from-source/). + ## Pre-built executable If you just want to download and run `geth` or any of the other tools here, this is the quickest and simplest way. diff --git a/docs/getting-started/run-cli.md b/docs/getting-started/run-cli.md index c4e53d3184..029622ea7a 100644 --- a/docs/getting-started/run-cli.md +++ b/docs/getting-started/run-cli.md @@ -1,3 +1,7 @@ +--- +title: Command Line Interface (CLI) +--- + ## Running `geth` !!! tip "Use for Ethereum mainnet" @@ -329,4 +333,4 @@ MISC OPTIONS: COPYRIGHT: Copyright 2013-2020 The core-geth and go-ethereum Authors -``` \ No newline at end of file +``` diff --git a/docs/index.md b/docs/index.md index 2dc496f845..6de355e7a5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,7 @@ --- hide: - navigation # Hide navigation +title: CoreGeth --- # CoreGeth: An Ethereum Protocol Provider diff --git a/ethclient/docsgen_test.go b/ethclient/docsgen_test.go new file mode 100644 index 0000000000..cd13feed1f --- /dev/null +++ b/ethclient/docsgen_test.go @@ -0,0 +1,341 @@ +package ethclient + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" + "sort" + "strings" + "testing" + "text/template" + + meta_schema "github.com/open-rpc/meta-schema" +) + +// The test in this file is only for use as a development tool. + +// TestRPCDiscover_BuildStatic puts the OpenRPC document in build/static/openrpc.json. +// This is intended to be run as a documentation development tool (as opposed to an actual _test_). +// NOTE that Go maps don't guarantee order, so the diff between runs can be noisy. +func TestRPCDiscover_BuildStatic(t *testing.T) { + if os.Getenv("COREGETH_GEN_OPENRPC_DOCS") == "" { + return + } + err := os.MkdirAll("../build/static", os.ModePerm) + if err != nil { + t.Fatal(err) + } + + backend, _ := newTestBackend(t) + client, _ := backend.Attach() + defer backend.Close() + defer client.Close() + + // Current workaround for https://github.com/open-rpc/meta-schema/issues/356. + res, err := backend.InprocDiscovery_DEVELOPMENTONLY().Discover() + if err != nil { + t.Fatal(err) + } + + // Should do it this way. + // res := &meta_schema.OpenrpcDocument{} + // err = client.Call(res, "rpc.discover") + // if err != nil { + // t.Fatal(err) + // } + + data, err := json.MarshalIndent(res, "", " ") + if err != nil { + t.Fatal(err) + } + err = ioutil.WriteFile("../build/static/openrpc.json", data, os.ModePerm) + if err != nil { + t.Fatal(err) + } + + if res.Methods == nil { + return + } + + tpl := template.New("openrpc_doc") + + trimNameSpecialChars := func(s string) string { + remove := []string{".", "*"} + for _, r := range remove { + s = strings.ReplaceAll(s, r, "") + } + return s + } + + contentDescriptorGenericName := func(cd *meta_schema.ContentDescriptorObject) (name string) { + defer func() { + name = fmt.Sprintf("<%s>", name) // make it generic-looking + }() + if cd.Description == nil { + return string(*cd.Name) + } + if cd.Name == nil { + return string(*cd.Description) + } + tr := trimNameSpecialChars(string(*cd.Description)) + if string(*cd.Name) == tr { + return string(*cd.Description) + } + return string(*cd.Name) + } + + tpl.Funcs(template.FuncMap{ + // tomap gives a plain map from a JSON representation of a given value. + // This is useful because the meta_schema data types, being generated, and conforming to a pretty + // complex data type in the first place, are not super fun to interact with directly. + "tomap": func(any interface{}) map[string]interface{} { + out := make(map[string]interface{}) + data, _ := json.Marshal(any) + json.Unmarshal(data, &out) + return out + }, + // asjson returns indented JSON. + "asjson": func(any interface{}, prefix, indent int) string { + by, _ := json.MarshalIndent(any, strings.Repeat(" ", prefix), strings.Repeat(" ", indent)) + return string(by) + }, + // bulletJSON handles transforming a JSON JSON schema into bullet points, which I think are more legible. + "bulletJSON": printBullet, + "sum": func(a, b int) int { return a + b }, + // trimNameSpecialChars removes characters that the app-specific content descriptor naming + // method will also remove, eg '*hexutil.Uint64' -> 'hexutilUint64'. + // These "special" characters were removed because of concerns about by-name arguments + // and the use of titles for keys. + "trimNameSpecialChars": trimNameSpecialChars, + // contentDescriptorTitle returns the name or description, in that order. + "contentDescriptorGenericName": contentDescriptorGenericName, + // methodFormatJSConsole is a pretty-printer that returns the JS console use example for a method. + "methodFormatJSConsole": func(m *meta_schema.MethodObject) string { + name := string(*m.Name) + formattedName := strings.Replace(name, "_", ".", 1) + getParamName := func(cd *meta_schema.ContentDescriptorObject) string { + if cd.Name != nil { + return string(*cd.Name) + } + return string(*cd.Description) + } + paramNames := func() (paramNames []string) { + if m.Params == nil { + return nil + } + for _, n := range *m.Params { + if n.ContentDescriptorObject == nil { + continue // Should never happen in our implementation; never uses refs. + } + paramNames = append(paramNames, getParamName(n.ContentDescriptorObject)) + } + return + }() + return fmt.Sprintf("%s(%s);", formattedName, strings.Join(paramNames, ",")) + }, + // methodFormatCURL is a pretty printer that returns the 'curl' method invocation example string. + "methodFormatCURL": func(m *meta_schema.MethodObject) string { + paramNames := "" + if m.Params != nil { + out := []string{} + for _, p := range *m.Params { + out = append(out, contentDescriptorGenericName(p.ContentDescriptorObject)) + } + paramNames = strings.Join(out, ", ") + } + + return fmt.Sprintf(`curl -X POST http://localhost:8545 --data '{"jsonrpc": "2.0", id": 42, "method": "%s", "params": [%s]}'`, *m.Name, paramNames) + }, + }) + + tpl, err = tpl.Parse(` +{{ define "schemaTpl" }} + ` + "```" + ` +{{ bulletJSON . 1 }} + ` + "```" + ` + +
View Raw + ` + "```" + ` + {{ asjson . 1 1 }} + ` + "```" + ` +
+{{ end }} + +{{ define "contentDescTpl" -}} +{{ $nameyDescription := trimNameSpecialChars .description }} +{{ if eq .name $nameyDescription }} +{{ .description }} {{ if .summary }}_{{ .summary }}_{{- end }} +{{- else -}} +{{ .name }} {{ .description }} {{ if .summary }}_{{ .summary }}_{{- end }} +{{- end }} + + + Required: {{ if .required }}✓ Yes{{ else }}No{{- end}} +{{ if .deprecated }} + Deprecated: :warning: Yes{{- end}} +{{ if (or (gt (len .schema) 1) .schema.properties) }} +=== "Schema" + + ` + "```" + ` Schema + {{ bulletJSON .schema 1 }} + ` + "```" + ` + +=== "Raw" + + ` + "```" + ` Raw + {{ asjson .schema 1 1 }} + ` + "```" + ` +{{ end }} +{{ end }} + +{{ define "methodTpl" }} +{{ $methodmap := tomap . }} +### {{ .Name }} + +{{ .Summary }} + +#### Params ({{ .Params | len }}) +{{ if gt (.Params | len) 0 }} +{{ if eq $methodmap.paramStructure "by-position" }}Parameters must be given _by position_.{{ else if eq $methodmap.paramStructure "by-name" }}Parameters must be given _by name_.{{ end }} +{{ range $index, $param := .Params }} +{{ $parammap := . | tomap }} +__{{ sum $index 1 }}:__ {{ template "contentDescTpl" $parammap }} +{{ end }} +{{ else }} +_None_ +{{- end}} + +#### Result + +{{ if .Result -}} +{{ $result := .Result | tomap }} +{{- if ne $result.name "Null" }} +{{ template "contentDescTpl" $result }} +{{- else -}} +_None_ +{{- end }} +{{- end }} + +#### Client Method Invocation Examples + +=== "Shell" + + ` + "```" + ` shell + {{ methodFormatCURL . }} + ` + "```" + ` + +=== "Javascript Console" + + ` + "```" + ` js + {{ methodFormatJSConsole . }} + ` + "```" + ` + +{{ $docs := .ExternalDocs | tomap }} +
Source code +

+{{ .Description }} +View on GitHub → +

+
+ +--- +{{- end }} + +| Entity | Version | +| --- | --- | +| Source | {{ .Info.Version }} | +| OpenRPC | {{ .Openrpc }} | + +--- + +{{ range .Methods }} +{{ template "methodTpl" . }} +{{ end }} +`) + if err != nil { + t.Fatal(err) + } + + moduleMethods := func() (grouped map[string][]meta_schema.MethodObject) { + if res.Methods == nil { + return + } + grouped = make(map[string][]meta_schema.MethodObject) + for _, m := range *res.Methods { + moduleName := strings.Split(string(*m.Name), "_")[0] + group, ok := grouped[moduleName] + if !ok { + group = []meta_schema.MethodObject{} + } + group = append(group, m) + grouped[moduleName] = group + } + return + }() + + _ = os.MkdirAll("../docs/JSON-RPC-API/modules", os.ModePerm) + + for module, group := range moduleMethods { + fname := fmt.Sprintf("../docs/JSON-RPC-API/modules/%s.md", module) + fi, err := os.OpenFile(fname, os.O_CREATE|os.O_RDWR, os.ModePerm) + if err != nil { + t.Fatal(err) + } + fi.Truncate(0) + + nDoc := &meta_schema.OpenrpcDocument{} + *nDoc = *res + nDoc.Methods = (*meta_schema.Methods)(&group) + err = tpl.Execute(fi, nDoc) + if err != nil { + t.Fatal(err) + } + fi.Sync() + fi.Close() + } +} + +// printBullet handles transforming a JSON JSON schema into bullet points, which I think are more legible. +func printBullet(any interface{}, depth int) (out string) { + defer func() { + out += "\n" + }() + switch typ := any.(type) { + case map[string]interface{}: + out += "\n" + ordered := []string{} + for k := range typ { + ordered = append(ordered, k) + } + sort.Slice(ordered, func(i, j int) bool { + return ordered[i] < ordered[j] + }) + for _, k := range ordered { + v := typ[k] + out += fmt.Sprintf("%s- %s: %s", strings.Repeat("\t", depth), k, printBullet(v, depth+1)) + } + case []interface{}: + + // Don't know why this isn't working. Doesn't fire. + // if c, ok := any.([]string); ok { + // return strings.Join(c, ",") + // } + + stringSet := []string{} + for _, vv := range typ { + if s, ok := vv.(string); ok { + stringSet = append(stringSet, s) + } + } + if len(stringSet) == len(typ) { + return strings.Join(stringSet, ", ") + } + + out += "\n" + for _, vv := range typ { + out += printBullet(vv, depth+1) + } + default: + return fmt.Sprintf("`%v`", any) + } + return +} diff --git a/mkdocs.yml b/mkdocs.yml index 133ac5082f..ac7598b7d4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -38,6 +38,9 @@ theme: - navigation.sections # - navigation.instant +extra_css: + - assets/css/extra.css + use_directory_urls: true plugins: @@ -62,29 +65,12 @@ markdown_extensions: - pymdownx.emoji - pymdownx.superfences - pymdownx.details + - pymdownx.tabbed - pymdownx.magiclink: repo_url_shortener: true repo_url_shorthand: true social_url_shorthand: true - pymdownx.tasklist: custom_checkbox: true - -# Page tree -nav: - - Home: index.md - - Getting Started: - - Installation: getting-started/installation.md - - CLI: getting-started/run-cli.md - - Core: - - All tools: core/alltools.md - - EVMC: core/evmc.md - - APIs: - - JSON-RPC: apis/jsonrpc-apis.md - - OpenRPC: apis/openrpc.md - - Developers: - - Build from source: developers/build-from-source.md - - Documentation: developers/documentation.md - - Versioning: developers/versioning.md - - New release: developers/create-new-release.md - - Tutorials: - - Setup private network: tutorials/private-network.md + - pymdownx.highlight: + linenums: true diff --git a/node/node.go b/node/node.go index ec68ffb3b4..26267fabf6 100644 --- a/node/node.go +++ b/node/node.go @@ -718,3 +718,10 @@ func GetAPIsByWhitelist(apis []rpc.API, modules []string, exposeAll bool) (regis } return registeredApis } + +// InprocDiscovery_DEVELOPMENTONLY is a development workaround method +// only, and should not be considered a stable part of the public interface for this receiver. +// Current workaround for https://github.com/open-rpc/meta-schema/issues/356. +func (n *Node) InprocDiscovery_DEVELOPMENTONLY() *go_openrpc_reflect.Document { + return n.inprocOpenRPC +}