[DOCS] massive documentation update (#20229)
This PR: - reorganizes all documentation pages so they live in the right category - removes lots of legacy docs - contains many improvements to active documentation pages Geth user documentation is now spread across five major categories: - Install and Build: installation and compile instructions - Using Geth: this is for pages about general geth usage. - For dApp Developers: this is for programming guides and functionality specific to dapp development. All the dev guides for mobile framework and Go APIs live here. - JSON-RPC APIs: this has its own section because there is now a sub-page for every name space. I have also added an overview text that explains how to set up the API servers. - For Geth Developers: this is for geth contributors
This commit is contained in:
@ -1,145 +0,0 @@
|
||||
---
|
||||
title: eth_call
|
||||
---
|
||||
|
||||
Executes a new message call immediately, without creating a transaction on the block chain. The `eth_call` method can be used to query internal contract state, to execute validations coded into a contract or even to test what the effect of a transaction would be without running it live.
|
||||
|
||||
## Parameters
|
||||
|
||||
The method takes 3 parameters: an unsigned transaction object to execute in read-only mode; the block number to execute the call against; and an optional state override-set to allow executing the call against a modified chain state.
|
||||
|
||||
#### 1. `Object` - Transaction call object
|
||||
|
||||
The *transaction call object* is mandatory and contains all the necessary parameters to execute a read-only EVM contract method.
|
||||
|
||||
| Field | Type | Bytes | Optional | Description |
|
||||
|:---:|:---:|:---:|:---:|:---|
|
||||
| `from` | `Address` | 20 | Yes | Address the transaction is simulated to have been sent from. Defaults to first account in the local keystore or the `0x00..0` address if no local accounts are available. |
|
||||
| `to` | `Address` | 20 | No | Address the transaction is sent to. |
|
||||
| `gas` | `Quantity` | <8 | Yes | Maximum gas allowance for the code execution to avoid infinite loops. Defaults to `2^63` or whatever value the node operator specified via `--rpc.gascap`. |
|
||||
| `gasPrice` | `Quantity` | <32 | Yes | Number of `wei` to simulate paying for each unit of gas during execution. Defaults to `1 gwei`. |
|
||||
| `value` | `Quantity` | <32 | Yes | Amount of `wei` to simulate sending along with the transaction. Defaults to `0`. |
|
||||
| `data` | `Binary` | any | Yes | Binary data to send to the target contract. Generally the 4 byte hash of the method signature followed by the ABI encoded parameters. For details please see the [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI). |
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"from": "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3",
|
||||
"to": "0xebe8efa441b9302a0d7eaecc277c09d20d684540",
|
||||
"gas": "0x1bd7c",
|
||||
"data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628",
|
||||
}
|
||||
```
|
||||
|
||||
#### 2. `Quantity | Tag` - Block number or the string `latest` or `pending`
|
||||
|
||||
The *block number* is mandatory and defines the context (state) against which the specified transaction should be executed. It is not possible to execute calls against reorged blocks; or blocks older than 128 (unless the node is an archive node).
|
||||
|
||||
#### 3. `Object` - State override set
|
||||
|
||||
The *state override set* is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call. Each address maps to an object containing:
|
||||
|
||||
| Field | Type | Bytes | Optional | Description |
|
||||
|:---:|:---:|:---:|:---:|:---|
|
||||
| `balance` | `Quantity` | <32 | Yes | Fake balance to set for the account before executing the call. |
|
||||
| `nonce` | `Quantity` | <8 | Yes | Fake nonce to set for the account before executing the call. |
|
||||
| `code` | `Binary` | any | Yes | Fake EVM bytecode to inject into the account before executing the call. |
|
||||
| `state` | `Object` | any | Yes | Fake key-value mapping to override **all** slots in the account storage before executing the call. |
|
||||
| `stateDiff` | `Object` | any | Yes | Fake key-value mapping to override **individual** slots in the account storage before executing the call. |
|
||||
|
||||
The goal of the *state override set* is manyfold:
|
||||
|
||||
* It can be used by DApps to reduce the amount of contract code needed to be deployed on chain. Code that simply returns internal state or does pre-defined validations can be kept off chain and fed to the node on-demand.
|
||||
* It can be used for smart contract analysis by extending the code deployed on chain with custom methods and invoking them. This avoids having to download and reconstruct the entire state in a sandbox to run custom code against.
|
||||
* It can be used to debug smart contracts in an already deployed large suite of contracts by selectively overriding some code or state and seeing how execution changes. Specialized tooling will probably be necessary.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3": {
|
||||
"balance": "0xde0b6b3a7640000"
|
||||
},
|
||||
"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {
|
||||
"code": "0x...",
|
||||
"state": {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
The method returns a single `Binary` consisting the return value of the executed contract call.
|
||||
|
||||
## Simple example
|
||||
|
||||
With a synced Rinkeby node with RPC exposed on localhost (`geth --rinkeby --rpc`) we can make a call against the [Checkpoint Oracle](https://rinkeby.etherscan.io/address/0xebe8efa441b9302a0d7eaecc277c09d20d684540) to retrieve the list of administrators:
|
||||
|
||||
```
|
||||
$ curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x45848dfc"},"latest"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
|
||||
```
|
||||
|
||||
And the result is an Ethereum ABI encoded list of accounts:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"result": "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000d9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f300000000000000000000000078d1ad571a1a09d60d9bbf25894b44e4c8859595000000000000000000000000286834935f4a8cfb4ff4c77d5770c2775ae2b0e7000000000000000000000000b86e2b0ab5a4b1373e40c51a7c712c70ba2f9f8e"
|
||||
}
|
||||
```
|
||||
|
||||
Just for the sake of completeness, decoded the response is:
|
||||
|
||||
```
|
||||
0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3,
|
||||
0x78d1ad571a1a09d60d9bbf25894b44e4c8859595,
|
||||
0x286834935f4a8cfb4ff4c77d5770c2775ae2b0e7,
|
||||
0xb86e2b0ab5a4b1373e40c51a7c712c70ba2f9f8e
|
||||
```
|
||||
|
||||
## Override example
|
||||
|
||||
The above *simple example* showed how to call a method already exposed by an on-chain smart contract. What if we want to access some data not exposed by it?
|
||||
|
||||
We can gut out the [original](https://github.com/ethereum/go-ethereum/blob/master/contracts/checkpointoracle/contract/oracle.sol) checkpoint oracle contract with one that retains the same fields (to retain the same storage layout), but one that includes a different method set:
|
||||
|
||||
```
|
||||
pragma solidity ^0.5.10;
|
||||
|
||||
contract CheckpointOracle {
|
||||
mapping(address => bool) admins;
|
||||
address[] adminList;
|
||||
uint64 sectionIndex;
|
||||
uint height;
|
||||
bytes32 hash;
|
||||
uint sectionSize;
|
||||
uint processConfirms;
|
||||
uint threshold;
|
||||
|
||||
function VotingThreshold() public view returns (uint) {
|
||||
return threshold;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With a synced Rinkeby node with RPC exposed on localhost (`geth --rinkeby --rpc`) we can make a call against the live [Checkpoint Oracle](https://rinkeby.etherscan.io/address/0xebe8efa441b9302a0d7eaecc277c09d20d684540), but override its byte code with our own version that has an accessor for the voting threshold field:
|
||||
|
||||
```
|
||||
$ curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x0be5b6ba"}, "latest", {"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {"code":"0x6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336045565b60408051918252519081900360200190f35b6007549056fea265627a7a723058206f26bd0433456354d8d1228d8fe524678a8aeeb0594851395bdbd35efc2a65f164736f6c634300050a0032"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
|
||||
```
|
||||
|
||||
And the result is the Ethereum ABI encoded threshold number:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"result": "0x0000000000000000000000000000000000000000000000000000000000000002"
|
||||
}
|
||||
```
|
||||
|
||||
Just for the sake of completeness, decoded the response is: `2`.
|
226
docs/_rpc/ns-admin.md
Normal file
226
docs/_rpc/ns-admin.md
Normal file
@ -0,0 +1,226 @@
|
||||
---
|
||||
title: admin Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
The `admin` API gives you access to several non-standard RPC methods, which will allow you to have
|
||||
a fine grained control over your Geth instance, including but not limited to network peer and RPC
|
||||
endpoint management.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### admin_addPeer
|
||||
|
||||
The `addPeer` administrative method requests adding a new remote node to the list of tracked static
|
||||
nodes. The node will try to maintain connectivity to these nodes at all times, reconnecting every
|
||||
once in a while if the remote connection goes down.
|
||||
|
||||
The method accepts a single argument, the [`enode`](https://github.com/ethereum/wiki/wiki/enode-url-format)
|
||||
URL of the remote peer to start tracking and returns a `BOOL` indicating whether the peer was accepted
|
||||
for tracking or some error occurred.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|------------------------------------------------|
|
||||
| Go | `admin.AddPeer(url string) (bool, error)` |
|
||||
| Console | `admin.addPeer(url)` |
|
||||
| RPC | `{"method": "admin_addPeer", "params": [url]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.addPeer("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303")
|
||||
true
|
||||
```
|
||||
|
||||
### admin_datadir
|
||||
|
||||
The `datadir` administrative property can be queried for the absolute path the running Geth node
|
||||
currently uses to store all its databases.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------|
|
||||
| Go | `admin.Datadir() (string, error`) |
|
||||
| Console | `admin.datadir` |
|
||||
| RPC | `{"method": "admin_datadir"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.datadir
|
||||
"/home/john/.ethereum"
|
||||
```
|
||||
|
||||
### admin_nodeInfo
|
||||
|
||||
The `nodeInfo` administrative property can be queried for all the information known about the running
|
||||
Geth node at the networking granularity. These include general information about the node itself as a
|
||||
participant of the [ÐΞVp2p](https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol) P2P
|
||||
overlay protocol, as well as specialized information added by each of the running application protocols
|
||||
(e.g. `eth`, `les`, `shh`, `bzz`).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------|
|
||||
| Go | `admin.NodeInfo() (*p2p.NodeInfo, error`) |
|
||||
| Console | `admin.nodeInfo` |
|
||||
| RPC | `{"method": "admin_nodeInfo"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.nodeInfo
|
||||
{
|
||||
enode: "enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@[::]:30303",
|
||||
id: "44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d",
|
||||
ip: "::",
|
||||
listenAddr: "[::]:30303",
|
||||
name: "Geth/v1.5.0-unstable/linux/go1.6",
|
||||
ports: {
|
||||
discovery: 30303,
|
||||
listener: 30303
|
||||
},
|
||||
protocols: {
|
||||
eth: {
|
||||
difficulty: 17334254859343145000,
|
||||
genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
||||
head: "0xb83f73fbe6220c111136aefd27b160bf4a34085c65ba89f24246b3162257c36a",
|
||||
network: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### admin_peers
|
||||
|
||||
The `peers` administrative property can be queried for all the information known about the connected
|
||||
remote nodes at the networking granularity. These include general information about the nodes themselves
|
||||
as participants of the [ÐΞVp2p](https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol)
|
||||
P2P overlay protocol, as well as specialized information added by each of the running application
|
||||
protocols (e.g. `eth`, `les`, `shh`, `bzz`).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|------------------------------------------|
|
||||
| Go | `admin.Peers() ([]*p2p.PeerInfo, error`) |
|
||||
| Console | `admin.peers` |
|
||||
| RPC | `{"method": "admin_peers"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.peers
|
||||
[{
|
||||
caps: ["eth/61", "eth/62", "eth/63"],
|
||||
id: "08a6b39263470c78d3e4f58e3c997cd2e7af623afce64656cfc56480babcea7a9138f3d09d7b9879344c2d2e457679e3655d4b56eaff5fd4fd7f147bdb045124",
|
||||
name: "Geth/v1.5.0-unstable/linux/go1.5.1",
|
||||
network: {
|
||||
localAddress: "192.168.0.104:51068",
|
||||
remoteAddress: "71.62.31.72:30303"
|
||||
},
|
||||
protocols: {
|
||||
eth: {
|
||||
difficulty: 17334052235346465000,
|
||||
head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
|
||||
version: 63
|
||||
}
|
||||
}
|
||||
}, /* ... */ {
|
||||
caps: ["eth/61", "eth/62", "eth/63"],
|
||||
id: "fcad9f6d3faf89a0908a11ddae9d4be3a1039108263b06c96171eb3b0f3ba85a7095a03bb65198c35a04829032d198759edfca9b63a8b69dc47a205d94fce7cc",
|
||||
name: "Geth/v1.3.5-506c9277/linux/go1.4.2",
|
||||
network: {
|
||||
localAddress: "192.168.0.104:55968",
|
||||
remoteAddress: "121.196.232.205:30303"
|
||||
},
|
||||
protocols: {
|
||||
eth: {
|
||||
difficulty: 17335165914080772000,
|
||||
head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
|
||||
version: 63
|
||||
}
|
||||
}
|
||||
}]
|
||||
```
|
||||
|
||||
### admin_startRPC
|
||||
|
||||
The `startRPC` administrative method starts an HTTP based [JSON RPC](http://www.jsonrpc.org/specification)
|
||||
API webserver to handle client requests. All the parameters are optional:
|
||||
|
||||
* `host`: network interface to open the listener socket on (defaults to `"localhost"`)
|
||||
* `port`: network port to open the listener socket on (defaults to `8545`)
|
||||
* `cors`: [cross-origin resource sharing](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) header to use (defaults to `""`)
|
||||
* `apis`: API modules to offer over this interface (defaults to `"eth,net,web3"`)
|
||||
|
||||
The method returns a boolean flag specifying whether the HTTP RPC listener was opened or not. Please note, only one HTTP endpoint is allowed to be active at any time.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------------------------------------------------------|
|
||||
| Go | `admin.StartRPC(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)` |
|
||||
| Console | `admin.startRPC(host, port, cors, apis)` |
|
||||
| RPC | `{"method": "admin_startRPC", "params": [host, port, cors, apis]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.startRPC("127.0.0.1", 8545)
|
||||
true
|
||||
```
|
||||
|
||||
### admin_startWS
|
||||
|
||||
The `startWS` administrative method starts an WebSocket based [JSON RPC](http://www.jsonrpc.org/specification)
|
||||
API webserver to handle client requests. All the parameters are optional:
|
||||
|
||||
* `host`: network interface to open the listener socket on (defaults to `"localhost"`)
|
||||
* `port`: network port to open the listener socket on (defaults to `8546`)
|
||||
* `cors`: [cross-origin resource sharing](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) header to use (defaults to `""`)
|
||||
* `apis`: API modules to offer over this interface (defaults to `"eth,net,web3"`)
|
||||
|
||||
The method returns a boolean flag specifying whether the WebSocket RPC listener was opened or not. Please note, only one WebSocket endpoint is allowed to be active at any time.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------------------------------------------------------|
|
||||
| Go | `admin.StartWS(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)` |
|
||||
| Console | `admin.startWS(host, port, cors, apis)` |
|
||||
| RPC | `{"method": "admin_startWS", "params": [host, port, cors, apis]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.startWS("127.0.0.1", 8546)
|
||||
true
|
||||
```
|
||||
|
||||
### admin_stopRPC
|
||||
|
||||
The `stopRPC` administrative method closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------|
|
||||
| Go | `admin.StopRPC() (bool, error`) |
|
||||
| Console | `admin.stopRPC()` |
|
||||
| RPC | `{"method": "admin_stopRPC"` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.stopRPC()
|
||||
true
|
||||
```
|
||||
|
||||
### admin_stopWS
|
||||
|
||||
The `stopWS` administrative method closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|--------------------------------|
|
||||
| Go | `admin.StopWS() (bool, error`) |
|
||||
| Console | `admin.stopWS()` |
|
||||
| RPC | `{"method": "admin_stopWS"` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> admin.stopWS()
|
||||
true
|
||||
```
|
564
docs/_rpc/ns-debug.md
Normal file
564
docs/_rpc/ns-debug.md
Normal file
@ -0,0 +1,564 @@
|
||||
---
|
||||
title: debug Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
The `debug` API gives you access to several non-standard RPC methods, which will allow you
|
||||
to inspect, debug and set certain debugging flags during runtime.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### debug_backtraceAt
|
||||
|
||||
Sets the logging backtrace location. When a backtrace location
|
||||
is set and a log message is emitted at that location, the stack
|
||||
of the goroutine executing the log statement will be printed to stderr.
|
||||
|
||||
The location is specified as `<filename>:<line>`.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Console | `debug.backtraceAt(string)` |
|
||||
| RPC | `{"method": "debug_backtraceAt", "params": [string]}` |
|
||||
|
||||
Example:
|
||||
|
||||
``` javascript
|
||||
> debug.backtraceAt("server.go:443")
|
||||
```
|
||||
|
||||
### debug_blockProfile
|
||||
|
||||
Turns on block profiling for the given duration and writes
|
||||
profile data to disk. 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 using
|
||||
`debug_writeBlockProfile`.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------------------|
|
||||
| Console | `debug.blockProfile(file, seconds)` |
|
||||
| RPC | `{"method": "debug_blockProfile", "params": [string, number]}` |
|
||||
|
||||
### debug_cpuProfile
|
||||
|
||||
Turns on CPU profiling for the given duration and writes
|
||||
profile data to disk.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|--------------------------------------------------------------|
|
||||
| Console | `debug.cpuProfile(file, seconds)` |
|
||||
| RPC | `{"method": "debug_cpuProfile", "params": [string, number]}` |
|
||||
|
||||
### debug_dumpBlock
|
||||
|
||||
Retrieves the state that corresponds to the block number and returns a list of accounts (including
|
||||
storage and code).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Go | `debug.DumpBlock(number uint64) (state.World, error)` |
|
||||
| Console | `debug.traceBlockByHash(number, [options])` |
|
||||
| RPC | `{"method": "debug_dumpBlock", "params": [number]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> debug.dumpBlock(10)
|
||||
{
|
||||
fff7ac99c8e4feb60c9750054bdc14ce1857f181: {
|
||||
balance: "49358640978154672",
|
||||
code: "",
|
||||
codeHash: "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
nonce: 2,
|
||||
root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
storage: {}
|
||||
},
|
||||
fffbca3a38c3c5fcb3adbb8e63c04c3e629aafce: {
|
||||
balance: "3460945928",
|
||||
code: "",
|
||||
codeHash: "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
nonce: 657,
|
||||
root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
storage: {}
|
||||
}
|
||||
},
|
||||
root: "19f4ed94e188dd9c7eb04226bd240fa6b449401a6c656d6d2816a87ccaf206f1"
|
||||
}
|
||||
```
|
||||
|
||||
### debug_gcStats
|
||||
|
||||
Returns GC statistics.
|
||||
|
||||
See https://golang.org/pkg/runtime/debug/#GCStats for information about
|
||||
the fields of the returned object.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.gcStats()` |
|
||||
| RPC | `{"method": "debug_gcStats", "params": []}` |
|
||||
|
||||
### debug_getBlockRlp
|
||||
|
||||
Retrieves and returns the RLP encoded block by number.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Go | `debug.GetBlockRlp(number uint64) (string, error)` |
|
||||
| Console | `debug.getBlockRlp(number, [options])` |
|
||||
| RPC | `{"method": "debug_getBlockRlp", "params": [number]}` |
|
||||
|
||||
References: [RLP](https://github.com/ethereum/wiki/wiki/RLP)
|
||||
|
||||
### debug_goTrace
|
||||
|
||||
Turns on Go runtime tracing for the given duration and writes
|
||||
trace data to disk.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------------------|
|
||||
| Console | `debug.goTrace(file, seconds)` |
|
||||
| RPC | `{"method": "debug_goTrace", "params": [string, number]}` |
|
||||
|
||||
### debug_memStats
|
||||
|
||||
Returns detailed runtime memory statistics.
|
||||
|
||||
See https://golang.org/pkg/runtime/#MemStats for information about
|
||||
the fields of the returned object.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.memStats()` |
|
||||
| RPC | `{"method": "debug_memStats", "params": []}` |
|
||||
|
||||
### debug_seedHash
|
||||
|
||||
Fetches and retrieves the seed hash of the block by number
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------|
|
||||
| Go | `debug.SeedHash(number uint64) (string, error)` |
|
||||
| Console | `debug.seedHash(number, [options])` |
|
||||
| RPC | `{"method": "debug_seedHash", "params": [number]}` |
|
||||
|
||||
### debug_setHead
|
||||
|
||||
Sets the current head of the local chain by block number. **Note**, this is a
|
||||
destructive action and may severely damage your chain. Use with *extreme* caution.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Go | `debug.SetHead(number uint64)` |
|
||||
| Console | `debug.setHead(number)` |
|
||||
| RPC | `{"method": "debug_setHead", "params": [number]}` |
|
||||
|
||||
References:
|
||||
[Ethash](https://github.com/ethereum/wiki/wiki/Mining#the-algorithm)
|
||||
|
||||
### debug_setBlockProfileRate
|
||||
|
||||
Sets the rate (in samples/sec) of goroutine block profile
|
||||
data collection. A non-zero rate enables block profiling,
|
||||
setting it to zero stops the profile. Collected profile data
|
||||
can be written using `debug_writeBlockProfile`.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------------------|
|
||||
| Console | `debug.setBlockProfileRate(rate)` |
|
||||
| RPC | `{"method": "debug_setBlockProfileRate", "params": [number]}` |
|
||||
|
||||
### debug_stacks
|
||||
|
||||
Returns a printed representation of the stacks of all goroutines.
|
||||
Note that the web3 wrapper for this method takes care of the printing
|
||||
and does not return the string.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.stacks()` |
|
||||
| RPC | `{"method": "debug_stacks", "params": []}` |
|
||||
|
||||
### debug_startCPUProfile
|
||||
|
||||
Turns on CPU profiling indefinitely, writing to the given file.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------------------|
|
||||
| Console | `debug.startCPUProfile(file)` |
|
||||
| RPC | `{"method": "debug_startCPUProfile", "params": [string]}` |
|
||||
|
||||
### debug_startGoTrace
|
||||
|
||||
Starts writing a Go runtime trace to the given file.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|--------------------------------------------------------|
|
||||
| Console | `debug.startGoTrace(file)` |
|
||||
| RPC | `{"method": "debug_startGoTrace", "params": [string]}` |
|
||||
|
||||
### debug_stopCPUProfile
|
||||
|
||||
Stops an ongoing CPU profile.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------|
|
||||
| Console | `debug.stopCPUProfile()` |
|
||||
| RPC | `{"method": "debug_stopCPUProfile", "params": []}` |
|
||||
|
||||
### debug_stopGoTrace
|
||||
|
||||
Stops writing the Go runtime trace.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.startGoTrace(file)` |
|
||||
| RPC | `{"method": "debug_stopGoTrace", "params": []}` |
|
||||
|
||||
### debug_traceBlock
|
||||
|
||||
The `traceBlock` method will return a full stack trace of all invoked opcodes of all transaction
|
||||
that were included included in this block. **Note**, the parent of this block must be present or
|
||||
it will fail.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|--------------------------------------------------------------------------|
|
||||
| Go | `debug.TraceBlock(blockRlp []byte, config. *vm.Config) BlockTraceResult` |
|
||||
| Console | `debug.traceBlock(tblockRlp, [options])` |
|
||||
| RPC | `{"method": "debug_traceBlock", "params": [blockRlp, {}]}` |
|
||||
|
||||
References:
|
||||
[RLP](https://github.com/ethereum/wiki/wiki/RLP)
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> debug.traceBlock("0xblock_rlp")
|
||||
{
|
||||
gas: 85301,
|
||||
returnValue: "",
|
||||
structLogs: [{
|
||||
depth: 1,
|
||||
error: "",
|
||||
gas: 162106,
|
||||
gasCost: 3,
|
||||
memory: null,
|
||||
op: "PUSH1",
|
||||
pc: 0,
|
||||
stack: [],
|
||||
storage: {}
|
||||
},
|
||||
/* snip */
|
||||
{
|
||||
depth: 1,
|
||||
error: "",
|
||||
gas: 100000,
|
||||
gasCost: 0,
|
||||
memory: ["0000000000000000000000000000000000000000000000000000000000000006", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000060"],
|
||||
op: "STOP",
|
||||
pc: 120,
|
||||
stack: ["00000000000000000000000000000000000000000000000000000000d67cbec9"],
|
||||
storage: {
|
||||
0000000000000000000000000000000000000000000000000000000000000004: "8241fa522772837f0d05511f20caa6da1d5a3209000000000000000400000001",
|
||||
0000000000000000000000000000000000000000000000000000000000000006: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||
f652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f: "00000000000000000000000002e816afc1b5c0f39852131959d946eb3b07b5ad"
|
||||
}
|
||||
}]
|
||||
```
|
||||
|
||||
### debug_traceBlockByNumber
|
||||
|
||||
Similar to [debug_traceBlock](#debug_traceblock), `traceBlockByNumber` accepts a block number and will replay the
|
||||
block that is already present in the database.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|--------------------------------------------------------------------------------|
|
||||
| Go | `debug.TraceBlockByNumber(number uint64, config. *vm.Config) BlockTraceResult` |
|
||||
| Console | `debug.traceBlockByNumber(number, [options])` |
|
||||
| RPC | `{"method": "debug_traceBlockByNumber", "params": [number, {}]}` |
|
||||
|
||||
References:
|
||||
[RLP](https://github.com/ethereum/wiki/wiki/RLP)
|
||||
|
||||
### debug_traceBlockByHash
|
||||
|
||||
Similar to [debug_traceBlock](#debug_traceblock), `traceBlockByHash` accepts a block hash and will replay the
|
||||
block that is already present in the database.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------------------------------------|
|
||||
| Go | `debug.TraceBlockByHash(hash common.Hash, config. *vm.Config) BlockTraceResult` |
|
||||
| Console | `debug.traceBlockByHash(hash, [options])` |
|
||||
| RPC | `{"method": "debug_traceBlockByHash", "params": [hash {}]}` |
|
||||
|
||||
References:
|
||||
[RLP](https://github.com/ethereum/wiki/wiki/RLP)
|
||||
|
||||
### debug_traceBlockFromFile
|
||||
|
||||
Similar to [debug_traceBlock](#debug_traceblock), `traceBlockFromFile` accepts a file containing the RLP of the block.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------------------------------------|
|
||||
| Go | `debug.TraceBlockFromFile(fileName string, config. *vm.Config) BlockTraceResult` |
|
||||
| Console | `debug.traceBlockFromFile(fileName, [options])` |
|
||||
| RPC | `{"method": "debug_traceBlockFromFile", "params": [fileName, {}]}` |
|
||||
|
||||
References:
|
||||
[RLP](https://github.com/ethereum/wiki/wiki/RLP)
|
||||
|
||||
### debug_standardTraceBlockToFile
|
||||
|
||||
|
||||
When JS-based tracing (see below) was first implemented, the intended usecase was to enable long-running tracers that could stream results back via a subscription channel.
|
||||
This method works a bit differently. (For full details, see [PR](https://github.com/ethereum/go-ethereum/pull/17914))
|
||||
|
||||
- It streams output to disk during the execution, to not blow up the memory usage on the node
|
||||
- It uses `jsonl` as output format (to allow streaming)
|
||||
- Uses a cross-client standardized output, so called 'standard json'
|
||||
* Uses `op` for string-representation of opcode, instead of `op`/`opName` for numeric/string, and other simlar small differences.
|
||||
* has `refund`
|
||||
* Represents memory as a contiguous chunk of data, as opposed to a list of `32`-byte segments like `debug_traceTransaction`
|
||||
|
||||
This means that this method is only 'useful' for callers who control the node -- at least sufficiently to be able to read the artefacts from the filesystem after the fact.
|
||||
|
||||
The method can be used to dump a certain transaction out of a given block:
|
||||
```
|
||||
> debug.standardTraceBlockToFile("0x0bbe9f1484668a2bf159c63f0cf556ed8c8282f99e3ffdb03ad2175a863bca63", {txHash:"0x4049f61ffbb0747bb88dc1c85dd6686ebf225a3c10c282c45a8e0c644739f7e9", disableMemory:true})
|
||||
["/tmp/block_0x0bbe9f14-14-0x4049f61f-099048234"]
|
||||
```
|
||||
Or all txs from a block:
|
||||
```
|
||||
> debug.standardTraceBlockToFile("0x0bbe9f1484668a2bf159c63f0cf556ed8c8282f99e3ffdb03ad2175a863bca63", {disableMemory:true})
|
||||
["/tmp/block_0x0bbe9f14-0-0xb4502ea7-409046657", "/tmp/block_0x0bbe9f14-1-0xe839be8f-954614764", "/tmp/block_0x0bbe9f14-2-0xc6e2052f-542255195", "/tmp/block_0x0bbe9f14-3-0x01b7f3fe-209673214", "/tmp/block_0x0bbe9f14-4-0x0f290422-320999749", "/tmp/block_0x0bbe9f14-5-0x2dc0fb80-844117472", "/tmp/block_0x0bbe9f14-6-0x35542da1-256306111", "/tmp/block_0x0bbe9f14-7-0x3e199a08-086370834", "/tmp/block_0x0bbe9f14-8-0x87778b88-194603593", "/tmp/block_0x0bbe9f14-9-0xbcb081ba-629580052", "/tmp/block_0x0bbe9f14-10-0xc254381a-578605923", "/tmp/block_0x0bbe9f14-11-0xcc434d58-405931366", "/tmp/block_0x0bbe9f14-12-0xce61967d-874423181", "/tmp/block_0x0bbe9f14-13-0x05a20b35-267153288", "/tmp/block_0x0bbe9f14-14-0x4049f61f-606653767", "/tmp/block_0x0bbe9f14-15-0x46d473d2-614457338", "/tmp/block_0x0bbe9f14-16-0x35cf5500-411906321", "/tmp/block_0x0bbe9f14-17-0x79222961-278569788", "/tmp/block_0x0bbe9f14-18-0xad84e7b1-095032683", "/tmp/block_0x0bbe9f14-19-0x4bd48260-019097038", "/tmp/block_0x0bbe9f14-20-0x1517411d-292624085", "/tmp/block_0x0bbe9f14-21-0x6857e350-971385904", "/tmp/block_0x0bbe9f14-22-0xbe3ae2ca-236639695"]
|
||||
|
||||
```
|
||||
Files are created in a temp-location, with the naming standard `block_<blockhash:4>-<txindex>-<txhash:4>-<random suffix>`. Each opcode immediately streams to file, with no in-geth buffering aside from whatever buffering the os normally does.
|
||||
|
||||
On the server side, it also adds some more info when regenerating historical state, namely, the reexec-number if `required historical state is not avaiable` is encountered, so a user can experiment with increasing that setting. It also prints out the remaining block until it reaches target:
|
||||
|
||||
```
|
||||
INFO [10-15|13:48:25.263] Regenerating historical state block=2385959 target=2386012 remaining=53 elapsed=3m30.990537767s
|
||||
INFO [10-15|13:48:33.342] Regenerating historical state block=2386012 target=2386012 remaining=0 elapsed=3m39.070073163s
|
||||
INFO [10-15|13:48:33.343] Historical state regenerated block=2386012 elapsed=3m39.070454362s nodes=10.03mB preimages=652.08kB
|
||||
INFO [10-15|13:48:33.352] Wrote trace file=/tmp/block_0x14490c57-0-0xfbbd6d91-715824834
|
||||
INFO [10-15|13:48:33.352] Wrote trace file=/tmp/block_0x14490c57-1-0x71076194-187462969
|
||||
INFO [10-15|13:48:34.421] Wrote trace file=/tmp/block_0x14490c57-2-0x3f4263fe-056924484
|
||||
```
|
||||
|
||||
The `options` is as follows:
|
||||
```
|
||||
type StdTraceConfig struct {
|
||||
*vm.LogConfig
|
||||
Reexec *uint64
|
||||
TxHash *common.Hash
|
||||
}
|
||||
```
|
||||
|
||||
### debug_standardTraceBadBlockToFile
|
||||
|
||||
This method is similar to `debug_standardTraceBlockToFile`, but can be used to obtain info about a block which has been _rejected_ as invalid (for some reason).
|
||||
|
||||
|
||||
### debug_traceTransaction
|
||||
|
||||
**OBS** In most scenarios, `debug.standardTraceBlockToFile` is better suited for tracing!
|
||||
|
||||
The `traceTransaction` debugging method will attempt to run the transaction in the exact same manner
|
||||
as it was executed on the network. It will replay any transaction that may have been executed prior
|
||||
to this one before it will finally attempt to execute the transaction that corresponds to the given
|
||||
hash.
|
||||
|
||||
In addition to the hash of the transaction you may give it a secondary *optional* argument, which
|
||||
specifies the options for this specific call. The possible options are:
|
||||
|
||||
* `disableStorage`: `BOOL`. Setting this to true will disable storage capture (default = false).
|
||||
* `disableMemory`: `BOOL`. Setting this to true will disable memory capture (default = false).
|
||||
* `disableStack`: `BOOL`. Setting this to true will disable stack capture (default = false).
|
||||
* `tracer`: `STRING`. Setting this will enable JavaScript-based transaction tracing, described below. If set, the previous four arguments will be ignored.
|
||||
* `timeout`: `STRING`. Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described [here](https://golang.org/pkg/time/#ParseDuration).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------------------------------------------------|
|
||||
| Go | `debug.TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ExecutionResurt, error)` |
|
||||
| Console | `debug.traceTransaction(txHash, [options])` |
|
||||
| RPC | `{"method": "debug_traceTransaction", "params": [txHash, {}]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> debug.traceTransaction("0x2059dd53ecac9827faad14d364f9e04b1d5fe5b506e3acc886eff7a6f88a696a")
|
||||
{
|
||||
gas: 85301,
|
||||
returnValue: "",
|
||||
structLogs: [{
|
||||
depth: 1,
|
||||
error: "",
|
||||
gas: 162106,
|
||||
gasCost: 3,
|
||||
memory: null,
|
||||
op: "PUSH1",
|
||||
pc: 0,
|
||||
stack: [],
|
||||
storage: {}
|
||||
},
|
||||
/* snip */
|
||||
{
|
||||
depth: 1,
|
||||
error: "",
|
||||
gas: 100000,
|
||||
gasCost: 0,
|
||||
memory: ["0000000000000000000000000000000000000000000000000000000000000006", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000060"],
|
||||
op: "STOP",
|
||||
pc: 120,
|
||||
stack: ["00000000000000000000000000000000000000000000000000000000d67cbec9"],
|
||||
storage: {
|
||||
0000000000000000000000000000000000000000000000000000000000000004: "8241fa522772837f0d05511f20caa6da1d5a3209000000000000000400000001",
|
||||
0000000000000000000000000000000000000000000000000000000000000006: "0000000000000000000000000000000000000000000000000000000000000001",
|
||||
f652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f: "00000000000000000000000002e816afc1b5c0f39852131959d946eb3b07b5ad"
|
||||
}
|
||||
}]
|
||||
```
|
||||
|
||||
|
||||
#### JavaScript-based tracing
|
||||
Specifying the `tracer` option in the second argument enables JavaScript-based tracing. In this mode, `tracer` is interpreted as a JavaScript expression that is expected to evaluate to an object with (at least) two methods, named `step` and `result`.
|
||||
|
||||
`step`is a function that takes two arguments, log and db, and is called for each step of the EVM, or when an error occurs, as the specified transaction is traced.
|
||||
|
||||
`log` has the following fields:
|
||||
|
||||
- `pc`: Number, the current program counter
|
||||
- `op`: Object, an OpCode object representing the current opcode
|
||||
- `gas`: Number, the amount of gas remaining
|
||||
- `gasPrice`: Number, the cost in wei of each unit of gas
|
||||
- `memory`: Object, a structure representing the contract's memory space
|
||||
- `stack`: array[big.Int], the EVM execution stack
|
||||
- `depth`: The execution depth
|
||||
- `account`: The address of the account executing the current operation
|
||||
- `err`: If an error occured, information about the error
|
||||
|
||||
If `err` is non-null, all other fields should be ignored.
|
||||
|
||||
For efficiency, the same `log` object is reused on each execution step, updated with current values; make sure to copy values you want to preserve beyond the current call. For instance, this step function will not work:
|
||||
|
||||
function(log) {
|
||||
this.logs.append(log);
|
||||
}
|
||||
|
||||
But this step function will:
|
||||
|
||||
function(log) {
|
||||
this.logs.append({gas: log.gas, pc: log.pc, ...});
|
||||
}
|
||||
|
||||
`log.op` has the following methods:
|
||||
|
||||
- `isPush()` - returns true iff the opcode is a PUSHn
|
||||
- `toString()` - returns the string representation of the opcode
|
||||
- `toNumber()` - returns the opcode's number
|
||||
|
||||
`log.memory` has the following methods:
|
||||
|
||||
- `slice(start, stop)` - returns the specified segment of memory as a byte slice
|
||||
- `length()` - returns the length of the memory
|
||||
|
||||
`log.stack` has the following methods:
|
||||
|
||||
- `peek(idx)` - returns the idx-th element from the top of the stack (0 is the topmost element) as a big.Int
|
||||
- `length()` - returns the number of elements in the stack
|
||||
|
||||
`db` has the following methods:
|
||||
|
||||
- `getBalance(address)` - returns a `big.Int` with the specified account's balance
|
||||
- `getNonce(address)` - returns a Number with the specified account's nonce
|
||||
- `getCode(address)` - returns a byte slice with the code for the specified account
|
||||
- `getState(address, hash)` - returns the state value for the specified account and the specified hash
|
||||
- `exists(address)` - returns true if the specified address exists
|
||||
|
||||
The second function, 'result', takes no arguments, and is expected to return a JSON-serializable value to return to the RPC caller.
|
||||
|
||||
If the step function throws an exception or executes an illegal operation at any point, it will not be called on any further VM steps, and the error will be returned to the caller.
|
||||
|
||||
Note that several values are Golang big.Int objects, not JavaScript numbers or JS bigints. As such, they have the same interface as described in the godocs. Their default serialization to JSON is as a Javascript number; to serialize large numbers accurately call `.String()` on them. For convenience, `big.NewInt(x)` is provided, and will convert a uint to a Go BigInt.
|
||||
|
||||
Usage example, returns the top element of the stack at each CALL opcode only:
|
||||
|
||||
debug.traceTransaction(txhash, {tracer: '{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == "CALL") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}'});
|
||||
|
||||
### debug_verbosity
|
||||
|
||||
Sets the logging verbosity ceiling. Log messages with level
|
||||
up to and including the given level will be printed.
|
||||
|
||||
The verbosity of individual packages and source files
|
||||
can be raised using `debug_vmodule`.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.verbosity(level)` |
|
||||
| RPC | `{"method": "debug_vmodule", "params": [number]}` |
|
||||
|
||||
### debug_vmodule
|
||||
|
||||
Sets the logging verbosity pattern.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|---------------------------------------------------|
|
||||
| Console | `debug.vmodule(string)` |
|
||||
| RPC | `{"method": "debug_vmodule", "params": [string]}` |
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
If you want to see messages from a particular Go package (directory)
|
||||
and all subdirectories, use:
|
||||
|
||||
``` javascript
|
||||
> debug.vmodule("eth/*=6")
|
||||
```
|
||||
|
||||
If you want to restrict messages to a particular package (e.g. p2p)
|
||||
but exclude subdirectories, use:
|
||||
|
||||
``` javascript
|
||||
> debug.vmodule("p2p=6")
|
||||
```
|
||||
|
||||
If you want to see log messages from a particular source file, use
|
||||
|
||||
``` javascript
|
||||
> debug.vmodule("server.go=6")
|
||||
```
|
||||
|
||||
You can compose these basic patterns. If you want to see all
|
||||
output from peer.go in a package below eth (eth/peer.go,
|
||||
eth/downloader/peer.go) as well as output from package p2p
|
||||
at level <= 5, use:
|
||||
|
||||
``` javascript
|
||||
debug.vmodule("eth/*/peer.go=6,p2p=5")
|
||||
```
|
||||
|
||||
### debug_writeBlockProfile
|
||||
|
||||
Writes a goroutine blocking profile to the given file.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------------|
|
||||
| Console | `debug.writeBlockProfile(file)` |
|
||||
| RPC | `{"method": "debug_writeBlockProfile", "params": [string]}` |
|
||||
|
||||
### debug_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 using the `--memprofilerate`
|
||||
flag.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------------|
|
||||
| Console | `debug.writeMemProfile(file string)` |
|
||||
| RPC | `{"method": "debug_writeBlockProfile", "params": [string]}` |
|
186
docs/_rpc/ns-eth.md
Normal file
186
docs/_rpc/ns-eth.md
Normal file
@ -0,0 +1,186 @@
|
||||
---
|
||||
title: eth Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
Geth provides several extensions to the standard "eth" JSON-RPC namespace.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### eth_subscribe, eth_unsubscribe
|
||||
|
||||
These methods are used for real-time events through subscriptions. See the [subscription
|
||||
documentation](./pubsub) for more information.
|
||||
|
||||
### eth_call
|
||||
|
||||
Executes a new message call immediately, without creating a transaction on the block
|
||||
chain. The `eth_call` method can be used to query internal contract state, to execute
|
||||
validations coded into a contract or even to test what the effect of a transaction would
|
||||
be without running it live.
|
||||
|
||||
#### Parameters
|
||||
|
||||
The method takes 3 parameters: an unsigned transaction object to execute in read-only
|
||||
mode; the block number to execute the call against; and an optional state override-set to
|
||||
allow executing the call against a modified chain state.
|
||||
|
||||
##### 1. `Object` - Transaction call object
|
||||
|
||||
The *transaction call object* is mandatory and contains all the necessary parameters to
|
||||
execute a read-only EVM contract method.
|
||||
|
||||
| Field | Type | Bytes | Optional | Description |
|
||||
|:-----------|:-----------|:------|:---------|:------------|
|
||||
| `from` | `Address` | 20 | Yes | Address the transaction is simulated to have been sent from. Defaults to first account in the local keystore or the `0x00..0` address if no local accounts are available. |
|
||||
| `to` | `Address` | 20 | No | Address the transaction is sent to. |
|
||||
| `gas` | `Quantity` | <8 | Yes | Maximum gas allowance for the code execution to avoid infinite loops. Defaults to `2^63` or whatever value the node operator specified via `--rpc.gascap`. |
|
||||
| `gasPrice` | `Quantity` | <32 | Yes | Number of `wei` to simulate paying for each unit of gas during execution. Defaults to `1 gwei`. |
|
||||
| `value` | `Quantity` | <32 | Yes | Amount of `wei` to simulate sending along with the transaction. Defaults to `0`. |
|
||||
| `data` | `Binary` | any | Yes | Binary data to send to the target contract. Generally the 4 byte hash of the method signature followed by the ABI encoded parameters. For details please see the [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI). |
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"from": "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3",
|
||||
"to": "0xebe8efa441b9302a0d7eaecc277c09d20d684540",
|
||||
"gas": "0x1bd7c",
|
||||
"data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628",
|
||||
}
|
||||
```
|
||||
|
||||
##### 2. `Quantity | Tag` - Block number or the string `latest` or `pending`
|
||||
|
||||
The *block number* is mandatory and defines the context (state) against which the
|
||||
specified transaction should be executed. It is not possible to execute calls against
|
||||
reorged blocks; or blocks older than 128 (unless the node is an archive node).
|
||||
|
||||
##### 3. `Object` - State override set
|
||||
|
||||
The *state override set* is an optional address-to-state mapping, where each entry
|
||||
specifies some state to be ephemerally overridden prior to executing the call. Each
|
||||
address maps to an object containing:
|
||||
|
||||
| Field | Type | Bytes | Optional | Description |
|
||||
|:------------|:-----------|:------|:---------|:------------|
|
||||
| `balance` | `Quantity` | <32 | Yes | Fake balance to set for the account before executing the call. |
|
||||
| `nonce` | `Quantity` | <8 | Yes | Fake nonce to set for the account before executing the call. |
|
||||
| `code` | `Binary` | any | Yes | Fake EVM bytecode to inject into the account before executing the call. |
|
||||
| `state` | `Object` | any | Yes | Fake key-value mapping to override **all** slots in the account storage before executing the call. |
|
||||
| `stateDiff` | `Object` | any | Yes | Fake key-value mapping to override **individual** slots in the account storage before executing the call. |
|
||||
|
||||
The goal of the *state override set* is manyfold:
|
||||
|
||||
* It can be used by DApps to reduce the amount of contract code needed to be deployed on
|
||||
chain. Code that simply returns internal state or does pre-defined validations can be
|
||||
kept off chain and fed to the node on-demand.
|
||||
* It can be used for smart contract analysis by extending the code deployed on chain with
|
||||
custom methods and invoking them. This avoids having to download and reconstruct the
|
||||
entire state in a sandbox to run custom code against.
|
||||
* It can be used to debug smart contracts in an already deployed large suite of contracts
|
||||
by selectively overriding some code or state and seeing how execution changes.
|
||||
Specialized tooling will probably be necessary.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3": {
|
||||
"balance": "0xde0b6b3a7640000"
|
||||
},
|
||||
"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {
|
||||
"code": "0x...",
|
||||
"state": {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Return Values
|
||||
|
||||
The method returns a single `Binary` consisting the return value of the executed contract
|
||||
call.
|
||||
|
||||
#### Simple example
|
||||
|
||||
With a synced Rinkeby node with RPC exposed on localhost (`geth --rinkeby --rpc`) we can
|
||||
make a call against the [Checkpoint
|
||||
Oracle](https://rinkeby.etherscan.io/address/0xebe8efa441b9302a0d7eaecc277c09d20d684540)
|
||||
to retrieve the list of administrators:
|
||||
|
||||
```
|
||||
$ curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x45848dfc"},"latest"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
|
||||
```
|
||||
|
||||
And the result is an Ethereum ABI encoded list of accounts:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"result": "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000d9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f300000000000000000000000078d1ad571a1a09d60d9bbf25894b44e4c8859595000000000000000000000000286834935f4a8cfb4ff4c77d5770c2775ae2b0e7000000000000000000000000b86e2b0ab5a4b1373e40c51a7c712c70ba2f9f8e"
|
||||
}
|
||||
```
|
||||
|
||||
Just for the sake of completeness, decoded the response is:
|
||||
|
||||
```
|
||||
0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3,
|
||||
0x78d1ad571a1a09d60d9bbf25894b44e4c8859595,
|
||||
0x286834935f4a8cfb4ff4c77d5770c2775ae2b0e7,
|
||||
0xb86e2b0ab5a4b1373e40c51a7c712c70ba2f9f8e
|
||||
```
|
||||
|
||||
#### Override example
|
||||
|
||||
The above *simple example* showed how to call a method already exposed by an on-chain
|
||||
smart contract. What if we want to access some data not exposed by it?
|
||||
|
||||
We can gut out the
|
||||
[original](https://github.com/ethereum/go-ethereum/blob/master/contracts/checkpointoracle/contract/oracle.sol)
|
||||
checkpoint oracle contract with one that retains the same fields (to retain the same
|
||||
storage layout), but one that includes a different method set:
|
||||
|
||||
```
|
||||
pragma solidity ^0.5.10;
|
||||
|
||||
contract CheckpointOracle {
|
||||
mapping(address => bool) admins;
|
||||
address[] adminList;
|
||||
uint64 sectionIndex;
|
||||
uint height;
|
||||
bytes32 hash;
|
||||
uint sectionSize;
|
||||
uint processConfirms;
|
||||
uint threshold;
|
||||
|
||||
function VotingThreshold() public view returns (uint) {
|
||||
return threshold;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With a synced Rinkeby node with RPC exposed on localhost (`geth --rinkeby --rpc`) we can
|
||||
make a call against the live [Checkpoint
|
||||
Oracle](https://rinkeby.etherscan.io/address/0xebe8efa441b9302a0d7eaecc277c09d20d684540),
|
||||
but override its byte code with our own version that has an accessor for the voting
|
||||
threshold field:
|
||||
|
||||
```
|
||||
$ curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x0be5b6ba"}, "latest", {"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {"code":"0x6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336045565b60408051918252519081900360200190f35b6007549056fea265627a7a723058206f26bd0433456354d8d1228d8fe524678a8aeeb0594851395bdbd35efc2a65f164736f6c634300050a0032"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
|
||||
```
|
||||
|
||||
And the result is the Ethereum ABI encoded threshold number:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"result": "0x0000000000000000000000000000000000000000000000000000000000000002"
|
||||
}
|
||||
```
|
||||
|
||||
Just for the sake of completeness, decoded the response is: `2`.
|
72
docs/_rpc/ns-miner.md
Normal file
72
docs/_rpc/ns-miner.md
Normal file
@ -0,0 +1,72 @@
|
||||
---
|
||||
title: miner Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
The `miner` API allows you to remote control the node's mining operation and set various
|
||||
mining specific settings.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### miner_getHashrate
|
||||
|
||||
Get your hashrate in H/s (Hash operations per second).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------------|
|
||||
| Console | `miner.getHashrate()` |
|
||||
| RPC | `{"method": "miner_getHashrate", "params": []}` |
|
||||
|
||||
### miner_setExtra
|
||||
|
||||
Sets the extra data a miner can include when miner blocks. This is capped at
|
||||
32 bytes.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------|
|
||||
| Go | `miner.setExtra(extra string) (bool, error)` |
|
||||
| Console | `miner.setExtra(string)` |
|
||||
| RPC | `{"method": "miner_setExtra", "params": [string]}` |
|
||||
|
||||
### miner_setGasPrice
|
||||
|
||||
Sets the minimal accepted gas price when mining transactions. Any transactions that are
|
||||
below this limit are excluded from the mining process.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Go | `miner.setGasPrice(number *rpc.HexNumber) bool` |
|
||||
| Console | `miner.setGasPrice(number)` |
|
||||
| RPC | `{"method": "miner_setGasPrice", "params": [number]}` |
|
||||
|
||||
### miner_start
|
||||
|
||||
Start the CPU mining process with the given number of threads and generate a new DAG
|
||||
if need be.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------------|
|
||||
| Go | `miner.Start(threads *rpc.HexNumber) (bool, error)` |
|
||||
| Console | `miner.start(number)` |
|
||||
| RPC | `{"method": "miner_start", "params": [number]}` |
|
||||
|
||||
### miner_stop
|
||||
|
||||
Stop the CPU mining operation.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------|
|
||||
| Go | `miner.Stop() bool` |
|
||||
| Console | `miner.stop()` |
|
||||
| RPC | `{"method": "miner_stop", "params": []}` |
|
||||
|
||||
### miner_setEtherbase
|
||||
|
||||
Sets the etherbase, where mining rewards will go.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------------|
|
||||
| Go | `miner.SetEtherbase(common.Address) bool` |
|
||||
| Console | `miner.setEtherbase(address)` |
|
||||
| RPC | `{"method": "miner_setEtherbase", "params": [address]}` |
|
187
docs/_rpc/ns-personal.md
Normal file
187
docs/_rpc/ns-personal.md
Normal file
@ -0,0 +1,187 @@
|
||||
---
|
||||
title: personal Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
The personal API manages private keys in the key store.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### personal_importRawKey
|
||||
|
||||
Imports the given unencrypted private key (hex string) into the key store,
|
||||
encrypting it with the passphrase.
|
||||
|
||||
Returns the address of the new account.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| ----------------------------------------------------------------- |
|
||||
| Console | `personal.importRawKey(keydata, passphrase)` |
|
||||
| RPC | `{"method": "personal_importRawKey", "params": [string, string]}` |
|
||||
|
||||
### personal_listAccounts
|
||||
|
||||
Returns all the Ethereum account addresses of all keys
|
||||
in the key store.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| --------------------------------------------------- |
|
||||
| Console | `personal.listAccounts` |
|
||||
| RPC | `{"method": "personal_listAccounts", "params": []}` |
|
||||
|
||||
#### Example
|
||||
|
||||
``` javascript
|
||||
> personal.listAccounts
|
||||
["0x5e97870f263700f46aa00d967821199b9bc5a120", "0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc"]
|
||||
```
|
||||
|
||||
### personal_lockAccount
|
||||
|
||||
Removes the private key with given address from memory.
|
||||
The account can no longer be used to send transactions.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| -------------------------------------------------------- |
|
||||
| Console | `personal.lockAccount(address)` |
|
||||
| RPC | `{"method": "personal_lockAccount", "params": [string]}` |
|
||||
|
||||
### personal_newAccount
|
||||
|
||||
Generates a new private key and stores it in the key store directory.
|
||||
The key file is encrypted with the given passphrase.
|
||||
Returns the address of the new account.
|
||||
|
||||
At the geth console, `newAccount` will prompt for a passphrase when
|
||||
it is not supplied as the argument.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| --------------------------------------------------- |
|
||||
| Console | `personal.newAccount()` |
|
||||
| RPC | `{"method": "personal_newAccount", "params": [string]}` |
|
||||
|
||||
#### Example
|
||||
|
||||
``` javascript
|
||||
> personal.newAccount()
|
||||
Passphrase:
|
||||
Repeat passphrase:
|
||||
"0x5e97870f263700f46aa00d967821199b9bc5a120"
|
||||
```
|
||||
|
||||
The passphrase can also be supplied as a string.
|
||||
|
||||
``` javascript
|
||||
> personal.newAccount("h4ck3r")
|
||||
"0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc"
|
||||
```
|
||||
|
||||
### personal_unlockAccount
|
||||
|
||||
Decrypts the key with the given address from the key store.
|
||||
|
||||
Both passphrase and unlock duration are optional when using the JavaScript console.
|
||||
If the passphrase is not supplied as an argument, the console will prompt for
|
||||
the passphrase interactively.
|
||||
|
||||
The unencrypted key will be held in memory until the unlock duration expires.
|
||||
If the unlock duration defaults to 300 seconds. An explicit duration
|
||||
of zero seconds unlocks the key until geth exits.
|
||||
|
||||
The account can be used with `eth_sign` and `eth_sendTransaction` while it is unlocked.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| -------------------------------------------------------------------------- |
|
||||
| Console | `personal.unlockAccount(address, passphrase, duration)` |
|
||||
| RPC | `{"method": "personal_unlockAccount", "params": [string, string, number]}` |
|
||||
|
||||
#### Examples
|
||||
|
||||
``` javascript
|
||||
> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120")
|
||||
Unlock account 0x5e97870f263700f46aa00d967821199b9bc5a120
|
||||
Passphrase:
|
||||
true
|
||||
```
|
||||
|
||||
Supplying the passphrase and unlock duration as arguments:
|
||||
|
||||
``` javascript
|
||||
> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120", "foo", 30)
|
||||
true
|
||||
```
|
||||
|
||||
If you want to type in the passphrase and stil override the default unlock duration,
|
||||
pass `null` as the passphrase.
|
||||
|
||||
```
|
||||
> personal.unlockAccount("0x5e97870f263700f46aa00d967821199b9bc5a120", null, 30)
|
||||
Unlock account 0x5e97870f263700f46aa00d967821199b9bc5a120
|
||||
Passphrase:
|
||||
true
|
||||
```
|
||||
|
||||
### personal_sendTransaction
|
||||
|
||||
Validate the given passphrase and submit transaction.
|
||||
|
||||
The transaction is the same argument as for `eth_sendTransaction` and contains the `from` address. If the passphrase can be used to decrypt the private key belogging to `tx.from` the transaction is verified, signed and send onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :--------| -----------------------------------------------------------------|
|
||||
| Console | `personal.sendTransaction(tx, passphrase)` |
|
||||
| RPC | `{"method": "personal_sendTransaction", "params": [tx, string]}` |
|
||||
|
||||
*Note, prior to Geth 1.5, please use `personal_signAndSendTransaction` as that was the
|
||||
original introductory name and only later renamed to the current final version.*
|
||||
|
||||
#### Examples
|
||||
|
||||
``` javascript
|
||||
> var tx = {from: "0x391694e7e0b0cce554cb130d723a9d27458f9298", to: "0xafa3f8684e54059998bc3a7b0d2b0da075154d66", value: web3.toWei(1.23, "ether")}
|
||||
undefined
|
||||
> personal.sendTransaction(tx, "passphrase")
|
||||
0x8474441674cdd47b35b875fd1a530b800b51a5264b9975fb21129eeb8c18582f
|
||||
```
|
||||
|
||||
### personal_sign
|
||||
|
||||
The sign method calculates an Ethereum specific signature with:
|
||||
`sign(keccack256("\x19Ethereum Signed Message:\n" + len(message) + message)))`.
|
||||
|
||||
By adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.
|
||||
|
||||
See ecRecover to verify the signature.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Console | `personal.sign(message, account, [password])` |
|
||||
| RPC | `{"method": "personal_sign", "params": [message, account, password]}` |
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
``` javascript
|
||||
> personal.sign("0xdeadbeaf", "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "")
|
||||
"0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
|
||||
```
|
||||
|
||||
### personal_ecRecover
|
||||
|
||||
`ecRecover` returns the address associated with the private key that was used to calculate the signature in `personal_sign`.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------|
|
||||
| Console | `personal.ecRecover(message, signature)` |
|
||||
| RPC | `{"method": "personal_ecRecover", "params": [message, signature]}` |
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
``` javascript
|
||||
> personal.sign("0xdeadbeaf", "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "")
|
||||
"0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
|
||||
> personal.ecRecover("0xdeadbeaf", "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b")
|
||||
"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83"
|
||||
```
|
228
docs/_rpc/ns-txpool.md
Normal file
228
docs/_rpc/ns-txpool.md
Normal file
@ -0,0 +1,228 @@
|
||||
---
|
||||
title: txpool Namespace
|
||||
sort_key: C
|
||||
---
|
||||
|
||||
The `txpool` API gives you access to several non-standard RPC methods to inspect the contents of the
|
||||
transaction pool containing all the currently pending transactions as well as the ones queued for
|
||||
future processing.
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
### txpool_content
|
||||
|
||||
The `content` inspection property can be queried to list the exact details of all the transactions
|
||||
currently pending for inclusion in the next block(s), as well as the ones that are being scheduled
|
||||
for future execution only.
|
||||
|
||||
The result is an object with two fields `pending` and `queued`. Each of these fields are associative
|
||||
arrays, in which each entry maps an origin-address to a batch of scheduled transactions. These batches
|
||||
themselves are maps associating nonces with actual transactions.
|
||||
|
||||
Please note, there may be multiple transactions associated with the same account and nonce. This can
|
||||
happen if the user broadcast mutliple ones with varying gas allowances (or even complerely different
|
||||
transactions).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-------------------------------------------------------------------------|
|
||||
| Go | `txpool.Content() (map[string]map[string]map[string][]*RPCTransaction)` |
|
||||
| Console | `txpool.content` |
|
||||
| RPC | `{"method": "txpool_content"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> txpool.content
|
||||
{
|
||||
pending: {
|
||||
0x0216d5032f356960cd3749c31ab34eeff21b3395: {
|
||||
806: [{
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x0216d5032f356960cd3749c31ab34eeff21b3395",
|
||||
gas: "0x5208",
|
||||
gasPrice: "0xba43b7400",
|
||||
hash: "0xaf953a2d01f55cfe080c0c94150a60105e8ac3d51153058a1f03dd239dd08586",
|
||||
input: "0x",
|
||||
nonce: "0x326",
|
||||
to: "0x7f69a91a3cf4be60020fb58b893b7cbb65376db8",
|
||||
transactionIndex: null,
|
||||
value: "0x19a99f0cf456000"
|
||||
}]
|
||||
},
|
||||
0x24d407e5a0b506e1cb2fae163100b5de01f5193c: {
|
||||
34: [{
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x24d407e5a0b506e1cb2fae163100b5de01f5193c",
|
||||
gas: "0x44c72",
|
||||
gasPrice: "0x4a817c800",
|
||||
hash: "0xb5b8b853af32226755a65ba0602f7ed0e8be2211516153b75e9ed640a7d359fe",
|
||||
input: "0xb61d27f600000000000000000000000024d407e5a0b506e1cb2fae163100b5de01f5193c00000000000000000000000000000000000000000000000053444835ec580000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
nonce: "0x22",
|
||||
to: "0x7320785200f74861b69c49e4ab32399a71b34f1a",
|
||||
transactionIndex: null,
|
||||
value: "0x0"
|
||||
}]
|
||||
}
|
||||
},
|
||||
queued: {
|
||||
0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c: {
|
||||
3: [{
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c",
|
||||
gas: "0x15f90",
|
||||
gasPrice: "0x4a817c800",
|
||||
hash: "0x57b30c59fc39a50e1cba90e3099286dfa5aaf60294a629240b5bbec6e2e66576",
|
||||
input: "0x",
|
||||
nonce: "0x3",
|
||||
to: "0x346fb27de7e7370008f5da379f74dd49f5f2f80f",
|
||||
transactionIndex: null,
|
||||
value: "0x1f161421c8e0000"
|
||||
}]
|
||||
},
|
||||
0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a: {
|
||||
2: [{
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
|
||||
gas: "0x15f90",
|
||||
gasPrice: "0xba43b7400",
|
||||
hash: "0x3a3c0698552eec2455ed3190eac3996feccc806970a4a056106deaf6ceb1e5e3",
|
||||
input: "0x",
|
||||
nonce: "0x2",
|
||||
to: "0x24a461f25ee6a318bdef7f33de634a67bb67ac9d",
|
||||
transactionIndex: null,
|
||||
value: "0xebec21ee1da40000"
|
||||
}],
|
||||
6: [{
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
|
||||
gas: "0x15f90",
|
||||
gasPrice: "0x4a817c800",
|
||||
hash: "0xbbcd1e45eae3b859203a04be7d6e1d7b03b222ec1d66dfcc8011dd39794b147e",
|
||||
input: "0x",
|
||||
nonce: "0x6",
|
||||
to: "0x6368f3f8c2b42435d6c136757382e4a59436a681",
|
||||
transactionIndex: null,
|
||||
value: "0xf9a951af55470000"
|
||||
}, {
|
||||
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
blockNumber: null,
|
||||
from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
|
||||
gas: "0x15f90",
|
||||
gasPrice: "0x4a817c800",
|
||||
hash: "0x60803251d43f072904dc3a2d6a084701cd35b4985790baaf8a8f76696041b272",
|
||||
input: "0x",
|
||||
nonce: "0x6",
|
||||
to: "0x8db7b4e0ecb095fbd01dffa62010801296a9ac78",
|
||||
transactionIndex: null,
|
||||
value: "0xebe866f5f0a06000"
|
||||
}],
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### txpool_inspect
|
||||
|
||||
The `inspect` inspection property can be queried to list a textual summary of all the transactions
|
||||
currently pending for inclusion in the next block(s), as well as the ones that are being scheduled
|
||||
for future execution only. This is a method specifically tailored to developers to quickly see the
|
||||
transactions in the pool and find any potential issues.
|
||||
|
||||
The result is an object with two fields `pending` and `queued`. Each of these fields are associative
|
||||
arrays, in which each entry maps an origin-address to a batch of scheduled transactions. These batches
|
||||
themselves are maps associating nonces with transactions summary strings.
|
||||
|
||||
Please note, there may be multiple transactions associated with the same account and nonce. This can
|
||||
happen if the user broadcast mutliple ones with varying gas allowances (or even complerely different
|
||||
transactions).
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|----------------------------------------------------------------|
|
||||
| Go | `txpool.Inspect() (map[string]map[string]map[string][]string)` |
|
||||
| Console | `txpool.inspect` |
|
||||
| RPC | `{"method": "txpool_inspect"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> txpool.inspect
|
||||
{
|
||||
pending: {
|
||||
0x26588a9301b0428d95e6fc3a5024fce8bec12d51: {
|
||||
31813: ["0x3375ee30428b2a71c428afa5e89e427905f95f7e: 0 wei + 500000 × 20000000000 gas"]
|
||||
},
|
||||
0x2a65aca4d5fc5b5c859090a6c34d164135398226: {
|
||||
563662: ["0x958c1fa64b34db746925c6f8a3dd81128e40355e: 1051546810000000000 wei + 90000 × 20000000000 gas"],
|
||||
563663: ["0x77517b1491a0299a44d668473411676f94e97e34: 1051190740000000000 wei + 90000 × 20000000000 gas"],
|
||||
563664: ["0x3e2a7fe169c8f8eee251bb00d9fb6d304ce07d3a: 1050828950000000000 wei + 90000 × 20000000000 gas"],
|
||||
563665: ["0xaf6c4695da477f8c663ea2d8b768ad82cb6a8522: 1050544770000000000 wei + 90000 × 20000000000 gas"],
|
||||
563666: ["0x139b148094c50f4d20b01caf21b85edb711574db: 1048598530000000000 wei + 90000 × 20000000000 gas"],
|
||||
563667: ["0x48b3bd66770b0d1eecefce090dafee36257538ae: 1048367260000000000 wei + 90000 × 20000000000 gas"],
|
||||
563668: ["0x468569500925d53e06dd0993014ad166fd7dd381: 1048126690000000000 wei + 90000 × 20000000000 gas"],
|
||||
563669: ["0x3dcb4c90477a4b8ff7190b79b524773cbe3be661: 1047965690000000000 wei + 90000 × 20000000000 gas"],
|
||||
563670: ["0x6dfef5bc94b031407ffe71ae8076ca0fbf190963: 1047859050000000000 wei + 90000 × 20000000000 gas"]
|
||||
},
|
||||
0x9174e688d7de157c5c0583df424eaab2676ac162: {
|
||||
3: ["0xbb9bc244d798123fde783fcc1c72d3bb8c189413: 30000000000000000000 wei + 85000 × 21000000000 gas"]
|
||||
},
|
||||
0xb18f9d01323e150096650ab989cfecd39d757aec: {
|
||||
777: ["0xcd79c72690750f079ae6ab6ccd7e7aedc03c7720: 0 wei + 1000000 × 20000000000 gas"]
|
||||
},
|
||||
0xb2916c870cf66967b6510b76c07e9d13a5d23514: {
|
||||
2: ["0x576f25199d60982a8f31a8dff4da8acb982e6aba: 26000000000000000000 wei + 90000 × 20000000000 gas"]
|
||||
},
|
||||
0xbc0ca4f217e052753614d6b019948824d0d8688b: {
|
||||
0: ["0x2910543af39aba0cd09dbb2d50200b3e800a63d2: 1000000000000000000 wei + 50000 × 1171602790622 gas"]
|
||||
},
|
||||
0xea674fdde714fd979de3edf0f56aa9716b898ec8: {
|
||||
70148: ["0xe39c55ead9f997f7fa20ebe40fb4649943d7db66: 1000767667434026200 wei + 90000 × 20000000000 gas"]
|
||||
}
|
||||
},
|
||||
queued: {
|
||||
0x0f6000de1578619320aba5e392706b131fb1de6f: {
|
||||
6: ["0x8383534d0bcd0186d326c993031311c0ac0d9b2d: 9000000000000000000 wei + 21000 × 20000000000 gas"]
|
||||
},
|
||||
0x5b30608c678e1ac464a8994c3b33e5cdf3497112: {
|
||||
6: ["0x9773547e27f8303c87089dc42d9288aa2b9d8f06: 50000000000000000000 wei + 90000 × 50000000000 gas"]
|
||||
},
|
||||
0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c: {
|
||||
3: ["0x346fb27de7e7370008f5da379f74dd49f5f2f80f: 140000000000000000 wei + 90000 × 20000000000 gas"]
|
||||
},
|
||||
0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a: {
|
||||
2: ["0x24a461f25ee6a318bdef7f33de634a67bb67ac9d: 17000000000000000000 wei + 90000 × 50000000000 gas"],
|
||||
6: ["0x6368f3f8c2b42435d6c136757382e4a59436a681: 17990000000000000000 wei + 90000 × 20000000000 gas", "0x8db7b4e0ecb095fbd01dffa62010801296a9ac78: 16998950000000000000 wei + 90000 × 20000000000 gas"],
|
||||
7: ["0x6368f3f8c2b42435d6c136757382e4a59436a681: 17900000000000000000 wei + 90000 × 20000000000 gas"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### txpool_status
|
||||
|
||||
The `status` inspection property can be queried for the number of transactions currently pending for
|
||||
inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
|
||||
|
||||
The result is an object with two fields `pending` and `queued`, each of which is a counter representing
|
||||
the number of transactions in that particular state.
|
||||
|
||||
| Client | Method invocation |
|
||||
|:--------|-----------------------------------------------|
|
||||
| Go | `txpool.Status() (map[string]*rpc.HexNumber)` |
|
||||
| Console | `txpool.status` |
|
||||
| RPC | `{"method": "txpool_status"}` |
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
> txpool.status
|
||||
{
|
||||
pending: 10,
|
||||
queued: 7
|
||||
}
|
||||
```
|
168
docs/_rpc/pubsub.md
Normal file
168
docs/_rpc/pubsub.md
Normal file
@ -0,0 +1,168 @@
|
||||
---
|
||||
title: Real-time Events
|
||||
sort_key: B
|
||||
---
|
||||
|
||||
Geth v1.4 and later support publish / subscribe using JSON-RPC notifications. This allows
|
||||
clients to wait for events instead of polling for them.
|
||||
|
||||
It works by subscribing to particular events. The node will return a subscription id. For
|
||||
each event that matches the subscription a notification with relevant data is send
|
||||
together with the subscription id.
|
||||
|
||||
Example:
|
||||
|
||||
// create subscription
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]}
|
||||
<< {"jsonrpc":"2.0","id":1,"result":"0xcd0c3e8af590364c09d0fa6a1210faf5"}
|
||||
|
||||
// incoming notifications
|
||||
<< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0xcd0c3e8af590364c09d0fa6a1210faf5","result":{"difficulty":"0xd9263f42a87",<...>, "uncles":[]}}}
|
||||
<< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0xcd0c3e8af590364c09d0fa6a1210faf5","result":{"difficulty":"0xd90b1a7ad02", <...>, "uncles":["0x80aacd1ea4c9da32efd8c2cc9ab38f8f70578fcd46a1a4ed73f82f3e0957f936"]}}}
|
||||
|
||||
// cancel subscription
|
||||
>> {"id": 1, "method": "eth_unsubscribe", "params": ["0xcd0c3e8af590364c09d0fa6a1210faf5"]}
|
||||
<< {"jsonrpc":"2.0","id":1,"result":true}
|
||||
|
||||
### Considerations
|
||||
|
||||
1. notifications are send for current events and not for past events. If your use case
|
||||
requires you not to miss any notifications than subscriptions are probably not the best
|
||||
option.
|
||||
2. subscriptions require a full duplex connection. Geth offers such connections in the
|
||||
form of WebSocket and IPC (enabled by default).
|
||||
3. subscriptions are coupled to a connection. If the connection is closed all
|
||||
subscriptions that are created over this connection are removed.
|
||||
4. notifications are stored in an internal buffer and sent from this buffer to the client.
|
||||
If the client is unable to keep up and the number of buffered notifications reaches a
|
||||
limit (currently 10k) the connection is closed. Keep in mind that subscribing to some
|
||||
events can cause a flood of notifications, e.g. listening for all logs/blocks when the
|
||||
node starts to synchronize.
|
||||
|
||||
## Create subscription
|
||||
|
||||
Subscriptions are creates with a regular RPC call with `eth_subscribe` as method and the
|
||||
subscription name as first parameter. If successful it returns the subscription id.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. subscription name
|
||||
2. optional arguments
|
||||
|
||||
### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {"includeTransactions": true}]}
|
||||
<< {"id": 1, "jsonrpc": "2.0", "result": "0x9cef478923ff08bf67fde6c64013158d"}
|
||||
|
||||
## Cancel subscription
|
||||
|
||||
Subscriptions are cancelled with a regular RPC call with `eth_unsubscribe` as method and
|
||||
the subscription id as first parameter. It returns a bool indicating if the subscription
|
||||
was cancelled successful.
|
||||
|
||||
### Parameters
|
||||
1. subscription id
|
||||
|
||||
### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_unsubscribe", "params": ["0x9cef478923ff08bf67fde6c64013158d"]}
|
||||
<< {"jsonrpc":"2.0","id":1,"result":true}
|
||||
|
||||
## Supported Subscriptions
|
||||
|
||||
### newHeads
|
||||
|
||||
Fires a notification each time a new header is appended to the chain, including chain reorganizations. Users can use the bloom filter to determine if the block contains logs that are interested to them.
|
||||
|
||||
In case of a chain reorganization the subscription will emit all new headers for the new
|
||||
chain. Therefore the subscription can emit multiple headers on the same height.
|
||||
|
||||
#### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}
|
||||
<< {"jsonrpc":"2.0","id":2,"result":"0x9ce59a13059e417087c02d3236a0b1cc"}
|
||||
|
||||
<< {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_subscription",
|
||||
"params": {
|
||||
"result": {
|
||||
"difficulty": "0x15d9223a23aa",
|
||||
"extraData": "0xd983010305844765746887676f312e342e328777696e646f7773",
|
||||
"gasLimit": "0x47e7c4",
|
||||
"gasUsed": "0x38658",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"miner": "0xf8b483dba2c3b7176a3da549ad41a48bb3121069",
|
||||
"nonce": "0x084149998194cc5f",
|
||||
"number": "0x1348c9",
|
||||
"parentHash": "0x7736fab79e05dc611604d22470dadad26f56fe494421b5b333de816ce1f25701",
|
||||
"receiptRoot": "0x2fab35823ad00c7bb388595cb46652fe7886e00660a01e867824d3dceb1c8d36",
|
||||
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"stateRoot": "0xb3346685172db67de536d8765c43c31009d0eb3bd9c501c9be3229203f15f378",
|
||||
"timestamp": "0x56ffeff8",
|
||||
"transactionsRoot": "0x0167ffa60e3ebc0b080cdb95f7c0087dd6c0e61413140e39d94d3468d7c9689f"
|
||||
},
|
||||
"subscription": "0x9ce59a13059e417087c02d3236a0b1cc"
|
||||
}
|
||||
}
|
||||
|
||||
### logs
|
||||
|
||||
Returns logs that are included in new imported blocks and match the given filter criteria.
|
||||
|
||||
In case of a chain reorganization previous sent logs that are on the old chain will be resend with the `removed` property set to true. Logs from transactions that ended up in the new chain are emitted. Therefore a subscription can emit logs for the same transaction multiple times.
|
||||
|
||||
#### Parameters
|
||||
|
||||
1. `object` with the following (optional) fields
|
||||
- **address**, either an address or an array of addresses. Only logs that are created from these addresses are returned (optional)
|
||||
- **topics**, only logs which match the specified topics (optional)
|
||||
|
||||
|
||||
#### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["logs", {"address": "0x8320fe7702b96808f7bbc0d4a888ed1468216cfd", "topics": ["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"]}]}
|
||||
<< {"jsonrpc":"2.0","id":2,"result":"0x4a8a4c0517381924f9838102c5a4dcb7"}
|
||||
|
||||
<< {"jsonrpc":"2.0","method":"eth_subscription","params": {"subscription":"0x4a8a4c0517381924f9838102c5a4dcb7","result":{"address":"0x8320fe7702b96808f7bbc0d4a888ed1468216cfd","blockHash":"0x61cdb2a09ab99abf791d474f20c2ea89bf8de2923a2d42bb49944c8c993cbf04","blockNumber":"0x29e87","data":"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003","logIndex":"0x0","topics":["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"],"transactionHash":"0xe044554a0a55067caafd07f8020ab9f2af60bdfe337e395ecd84b4877a3d1ab4","transactionIndex":"0x0"}}}
|
||||
|
||||
### newPendingTransactions
|
||||
|
||||
Returns the hash for all transactions that are added to the pending state and are signed with a key that is available in the node.
|
||||
|
||||
When a transaction that was previously part of the canonical chain isn't part of the new canonical chain after a reogranization its again emitted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
|
||||
<< {"jsonrpc":"2.0","id":2,"result":"0xc3b33aa549fb9a60e95d21862596617c"}
|
||||
<< {
|
||||
"jsonrpc":"2.0",
|
||||
"method":"eth_subscription",
|
||||
"params":{
|
||||
"subscription":"0xc3b33aa549fb9a60e95d21862596617c",
|
||||
"result":"0xd6fdc5cc41a9959e922f30cb772a9aef46f4daea279307bc5f7024edc4ccd7fa"
|
||||
}
|
||||
}
|
||||
|
||||
### syncing
|
||||
|
||||
Indicates when the node starts or stops synchronizing. The result can either be a boolean
|
||||
indicating that the synchronization has started (true), finished (false) or an object with
|
||||
various progress indicators.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
>> {"id": 1, "method": "eth_subscribe", "params": ["syncing"]}
|
||||
<< {"jsonrpc":"2.0","id":2,"result":"0xe2ffeb2703bcf602d42922385829ce96"}
|
||||
|
||||
<< {"subscription":"0xe2ffeb2703bcf602d42922385829ce96","result":{"syncing":true,"status":{"startingBlock":674427,"currentBlock":67400,"highestBlock":674432,"pulledStates":0,"knownStates":0}}}}
|
||||
|
84
docs/_rpc/server.md
Normal file
84
docs/_rpc/server.md
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
title: JSON-RPC Server
|
||||
sort_key: A
|
||||
---
|
||||
|
||||
Geth supports all standard web3 JSON-RPC APIs. You can find documentation for
|
||||
these APIs on the [Ethereum Wiki JSON-RPC page](web3-rpc).
|
||||
|
||||
JSON-RPC is provided on multiple transports. Geth supports JSON-RPC over HTTP,
|
||||
WebSocket and Unix Domain Sockets. Transports must be enabled through
|
||||
command-line flags.
|
||||
|
||||
Ethereum JSON-RPC APIs use a name-space system. RPC methods are grouped into
|
||||
several categories depending on their purpose. All method names are composed of
|
||||
the namespace, an underscore, and the actual method name within the namespace.
|
||||
For example, the `eth_call` method resides in the `eth` namespace.
|
||||
|
||||
Access to RPC methods can be enabled on a per-namespace basis. Find
|
||||
documentation for individual namespaces in the sidebar.
|
||||
|
||||
### HTTP Server
|
||||
|
||||
To enable the HTTP server, use the `--rpc` flag.
|
||||
|
||||
geth --rpc
|
||||
|
||||
By default, geth accepts connections from the loopback interface (127.0.0.1).
|
||||
The default listening port is 8545. You can customize address and port using the
|
||||
`--rpcport` and `--rpcaddr` flags.
|
||||
|
||||
geth --rpc --rpcport 3334
|
||||
|
||||
JSON-RPC method namespaces must be whitelisted in order to be available through
|
||||
the HTTP server. The default whitelist allows access to the "eth" and "shh"
|
||||
namespaces. To enable access to other APIs like account management ("personal")
|
||||
and debugging ("debug"), they must be configured via the `--rpcapi` flag. We do
|
||||
not recommend enabling such APIs over HTTP, however, since access to these
|
||||
methods increases the attack surface.
|
||||
|
||||
geth --rpc --rpcapi personal,eth,net,web3b
|
||||
|
||||
Since the HTTP server is reachable from any local application, additional
|
||||
protection is built into the server to prevent misuse of the API from web pages.
|
||||
If you want enable access to the API from a web page, you must configure the
|
||||
server to accept Cross-Origin requests with the `--rpccorsdomain` flag.
|
||||
|
||||
Example: if you want to use [Remix](remix) with geth, allow requests from the
|
||||
remix domain.
|
||||
|
||||
geth --rpc --rpccorsdomain https://remix.ethereum.org
|
||||
|
||||
Use `--rpccorsdomain '*'` to enable access from any origin.
|
||||
|
||||
### WebSocket Server
|
||||
|
||||
Configuration of the WebSocket endpoint is similar to the HTTP transport. To
|
||||
enable WebSocket access, use `--ws` flag. The default WebSocket port is 8546.
|
||||
The `--wsaddr`, `--wsport` and `--wsapi` flags can be used to customize settings
|
||||
for the WebSocket server.
|
||||
|
||||
geth --ws --wsport 3334 --wsapi eth,net,web3
|
||||
|
||||
Cross-Origin request protection also applies to the WebSocket server. Use the
|
||||
`--wsorigins` flag to allow access to the server from web pages:
|
||||
|
||||
geth --ws --wsorigins http://myapp.example.com
|
||||
|
||||
As with `--rpccorsdomain`, using `--wsorigins '*'` allows access from any origin.
|
||||
|
||||
### IPC Server
|
||||
|
||||
JSON-RPC APIs are also provided on a UNIX domain socket. This server is enabled
|
||||
by default and has access to all JSON-RPC namespaces.
|
||||
|
||||
The listening socket is placed into the data directory by default. On Linux, the
|
||||
default location of the geth socket is
|
||||
|
||||
~/.ethereum/geth.ipc
|
||||
|
||||
You can configure the location of the socket using the `--ipcpath` flag. IPC can
|
||||
be disabled using the `--ipcdisable` flag.
|
||||
|
||||
[web3-rpc]: https://github.com/ethereum/wiki/wiki/JSON-RPC
|
||||
[remix]: https://remix.ethereum.org
|
Reference in New Issue
Block a user