Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Reorganised API docs (#1441)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadelineMurray authored May 14, 2019
1 parent 22ea4d9 commit be69db8
Show file tree
Hide file tree
Showing 35 changed files with 227 additions and 216 deletions.
2 changes: 1 addition & 1 deletion docs/Configuring-Pantheon/Network-vs-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Network wide settings are specified in the genesis file. Examples include `diff
networks and the [consensus mechanism](../Consensus-Protocols/Overview-Consensus.md).

Node settings are specified on the command line or in the [node configuration file](Using-Configuration-File.md).
For example, the [JSON-RPC API methods to enable](../Reference/JSON-RPC-API-Methods.md) or the
For example, the [JSON-RPC API methods to enable](../Reference/Pantheon-API-Methods.md) or the
[data directory](../Reference/Pantheon-CLI-Syntax.md#data-path) for the node.
2 changes: 1 addition & 1 deletion docs/Configuring-Pantheon/Networking/Configuring-Ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The default is `30303`.

## JSON-RPC API

To enable access to the [JSON-RPC API](../../JSON-RPC-API/JSON-RPC-API.md), open the HTTP JSON-RPC and WebSockets JSON-RPC ports to the intended users
To enable access to the [JSON-RPC API](../../Pantheon-API/JSON-RPC-API.md), open the HTTP JSON-RPC and WebSockets JSON-RPC ports to the intended users
of the JSON-RPC API on TCP.

The [`--rpc-http-port`](../../Reference/Pantheon-CLI-Syntax.md#rpc-http-port) and [`--rpc-ws-port`](../../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port)
Expand Down
12 changes: 6 additions & 6 deletions docs/Configuring-Pantheon/Networking/Managing-Peers.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ To configure a network of static nodes:

1. Start Pantheon with discovery disabled using [`--discovery-enabled=false`](../../Reference/Pantheon-CLI-Syntax.md#discovery-enabled).

To modify the static peers at run time, use the [`admin_addPeer`](../../Reference/JSON-RPC-API-Methods.md#admin_addpeer)
and [`admin_removePeer`](../../Reference/JSON-RPC-API-Methods.md#admin_removepeer) JSON-RPC API methods.
To modify the static peers at run time, use the [`admin_addPeer`](../../Reference/Pantheon-API-Methods.md#admin_addpeer)
and [`admin_removePeer`](../../Reference/Pantheon-API-Methods.md#admin_removepeer) JSON-RPC API methods.

!!! note
Runtime modifications of static nodes are not persisted between runs. The `static-nodes.json` file
Expand All @@ -42,7 +42,7 @@ and [`admin_removePeer`](../../Reference/JSON-RPC-API-Methods.md#admin_removepee
use [Permissioning](../../Permissions/Permissioning-Overview.md).

!!! caution
If the added peer does not appear in the peer list (returned by [`admin_peers`](../../Reference/JSON-RPC-API-Methods.md#admin_peers)),
If the added peer does not appear in the peer list (returned by [`admin_peers`](../../Reference/Pantheon-API-Methods.md#admin_peers)),
check the supplied [enode URL](../Node-Keys.md#enode-url) is correct, the node is running, the node is listening for
TCP connections on the endpoint, and has not reached the [maximum number of peers](#limiting-peers).

Expand All @@ -66,9 +66,9 @@ and contain a JSON array of [enode URLs](../Node-Keys.md#enode-url).

JSON-RPC API methods to monitor peer connections include:

* [`net_peerCount`](../../Reference/JSON-RPC-API-Methods.md#net_peercount)
* [`admin_peers`](../../Reference/JSON-RPC-API-Methods.md#admin_peers)
* [`debug_metrics`](../../Reference/JSON-RPC-API-Methods.md#debug_metrics)
* [`net_peerCount`](../../Reference/Pantheon-API-Methods.md#net_peercount)
* [`admin_peers`](../../Reference/Pantheon-API-Methods.md#admin_peers)
* [`debug_metrics`](../../Reference/Pantheon-API-Methods.md#debug_metrics)

## Node Connections

Expand Down
2 changes: 1 addition & 1 deletion docs/Configuring-Pantheon/Node-Keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Specified by the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) an
The enode URL is:
`enode://c35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f@127.0.0.1:30303`

The enode is displayed when starting a Pantheon node and can be obtained using the [`net_enode`](../Reference/JSON-RPC-API-Methods.md#net_enode)
The enode is displayed when starting a Pantheon node and can be obtained using the [`net_enode`](../Reference/Pantheon-API-Methods.md#net_enode)
JSON-RPC API method.

## Specifying a Custom Node Private Key File
Expand Down
6 changes: 3 additions & 3 deletions docs/Consensus-Protocols/Clique.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ or [`--rpc-ws-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-api) option and i

The JSON-RPC methods to add or remove signers are:

* [clique_propose](../Reference/JSON-RPC-API-Methods.md#clique_propose)
* [clique_getSigners](../Reference/JSON-RPC-API-Methods.md#clique_getsigners)
* [clique_discard](../Reference/JSON-RPC-API-Methods.md#clique_discard)
* [clique_propose](../Reference/Pantheon-API-Methods.md#clique_propose)
* [clique_getSigners](../Reference/Pantheon-API-Methods.md#clique_getsigners)
* [clique_discard](../Reference/Pantheon-API-Methods.md#clique_discard)

To propose adding a signer, call `clique_propose` specifying the address of the proposed signer and `true`.
!!! example "JSON-RPC clique_propose Request Example"
Expand Down
6 changes: 3 additions & 3 deletions docs/Consensus-Protocols/IBFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ or [`--rpc-ws-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-api) option and i

The JSON-RPC methods to add or remove validators are:

* [ibft_getPendingVotes](../Reference/JSON-RPC-API-Methods.md#ibft_getPendingVotes)
* [ibft_proposeValidatorVote](../Reference/JSON-RPC-API-Methods.md#ibft_proposeValidatorVote)
* [ibft_discardValidatorVote](../Reference/JSON-RPC-API-Methods.md#ibft_discardValidatorVote)
* [ibft_getPendingVotes](../Reference/Pantheon-API-Methods.md#ibft_getPendingVotes)
* [ibft_proposeValidatorVote](../Reference/Pantheon-API-Methods.md#ibft_proposeValidatorVote)
* [ibft_discardValidatorVote](../Reference/Pantheon-API-Methods.md#ibft_discardValidatorVote)

To propose adding a validator, call `ibft_proposeValidatorVote` specifying the address of the node to be added and `true`.
!!! example "JSON-RPC ibft_proposeValidatorVote Request Example"
Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-Started/Run-Docker-Image.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Where `myprivacypublickeyfile` is the file containing the public key and `path`

## Credentials Files

Specify a [credentials file](../JSON-RPC-API/Authentication.md#credentials-file) for JSON-RPC API [authentication](../JSON-RPC-API/Authentication.md).
Specify a [credentials file](../Pantheon-API/Authentication.md#credentials-file) for JSON-RPC API [authentication](../Pantheon-API/Authentication.md).

To run Pantheon specifying a credentials file for HTTP JSON-RPC:
```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-Started/Starting-Pantheon.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using the [`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file) o
## Confirm Node is Running

If you have started Pantheon with the [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled) option, use [cURL](https://curl.haxx.se/) to
call [JSON-RPC API methods](../Reference/JSON-RPC-API-Methods.md) to confirm the node is running.
call [JSON-RPC API methods](../Reference/Pantheon-API-Methods.md) to confirm the node is running.

!!!example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Authentication and Authorization
# Authentication and Authorization for JSON-RPC

Authentication identifies a user based on a username and password. Authorization verifies whether the user has
access to the JSON-RPC method they are requesting.

Pantheon uses the username and password to authenticate users and [JWT tokens](https://jwt.io/introduction/) to authorize JSON-RPC API requests.
Pantheon uses the username and password to authenticate users and [JWT tokens](https://jwt.io/introduction/) to authorize JSON-RPC requests.

!!! important
Authenticated requests must be made over HTTPS. HTTPS is encrypted which prevents eavesdropping on the connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ unformatted data (byte arrays, account addresses, hashes, and bytecode arrays).
RPC is the remote procedure call protocol (RFC 1831). The protocol is stateless and transport agnostic in that the concepts
can be used within the same process, over sockets, over HTTP, or in various message passing environments.

The Reference documentation includes the [JSON-RPC API Methods](../Reference/JSON-RPC-API-Methods.md)
and [JSON-RPC API Objects](../Reference/JSON-RPC-API-Objects.md)
The Reference documentation includes the [JSON-RPC API Methods](../Reference/Pantheon-API-Methods.md)
and [JSON-RPC API Objects](../Reference/Pantheon-API-Objects.md)
42 changes: 42 additions & 0 deletions docs/Pantheon-API/Pantheon-API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
description: Pantheon API
<!--- END of page meta data -->

Access the [Pantheon API](../Reference/Pantheon-API-Methods.md) using:

* [JSON-RPC over HTTP or WebSockets](Using-JSON-RPC-API.md)
* [RPC Pub/Sub over WebSockets](RPC-PubSub.md)
* GraphQL RPC over HTTP

Information applying to JSON-RPC, RPC Pub/Sub, and GraphQL is included below.

## Host Whitelist

To prevent DNS rebinding, incoming HTTP requests, WebSockets connections, and GraphQL requests are only accepted from hostnames
specified using the [`--host-whitelist`](../Reference/Pantheon-CLI-Syntax.md#host-whitelist) option.
By default, `localhost` and `127.0.0.1` are accepted.

If your application publishes RPC ports, specify the hostnames when starting Pantheon.

!!! example
```bash
pantheon --host-whitelist=example.com
```

Specify * for `--host-whitelist` to effectively disable host protection.

!!! caution
Specifying * for `--host-whitelist` is not recommended for production code.

## Not Supported by Pantheon

### Account Management

Account management relies on private key management in the client which is not implemented by Pantheon.

Use [`eth_sendRawTransaction`](../Reference/Pantheon-API-Methods.md#eth_sendrawtransaction) to send signed transactions; `eth_sendTransaction` is not implemented.

Use third-party wallets for [account management](../Using-Pantheon/Account-Management.md).

### Protocols

Pantheon does not implement the Whisper and Swarm protocols.
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
description: Using RPC Pub/Sub with Pantheon Web Socket API
description: Using RPC Pub/Sub with WebSockets
<!--- END of page meta data -->

# RPC Pub/Sub
# RPC Pub/Sub over WebSockets

## Introduction

Use the RPC Pub/Sub API to wait for events instead of polling for them. For example, a Dapp can subscribe to logs to be notified when a specific event has occurred.
Use RPC Pub/Sub over WebSockets to wait for events instead of polling for them. For example, a Dapp can
subscribe to logs to be notified when a specific event has occurred.

The RPC Pub/Sub methods are:
Methods specific to RPC Pub/Sub are:

* `eth_subscribe` - create a subscription for specific events.
* `eth_unsubscribe` - cancel a subscription.

!!!important
Unlike other [JSON RPC-API methods](../Reference/JSON-RPC-API-Methods.md),
Unlike other [Pantheon API methods](../Reference/Pantheon-API-Methods.md),
the RPC Pub/Sub methods cannot be called over HTTP. Use the [`--rpc-ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled) option to enable
the WebSockets JSON-RPC service.

### Using RPC Pub/Sub

The RPC Pub/Sub API is supported on [WebSockets](../JSON-RPC-API/Using-JSON-RPC-API.md#http-and-websocket-requests).
The RPC Pub/Sub API is supported on [WebSockets](../Pantheon-API/Using-JSON-RPC-API.md#http-and-websocket-requests).

Use `eth_subscribe` to create subscriptions. Once subscribed, notifications are published by the API using `eth_subscription`.

Expand Down Expand Up @@ -69,8 +70,8 @@ Use the `newHeads` parameter with `eth_subscribe` to be notified each time a blo
If a chain reorganization occurs, the subscription publishes notifications for blocks in the new chain.
This means the subscription can publish notifications for multiple blocks at the same height on the blockchain.

The new headers notification returns [block objects](../Reference/JSON-RPC-API-Objects.md#block-object). The
second parameter is optional. If specified, whole [transaction objects](../Reference/JSON-RPC-API-Objects.md#transaction-object)
The new headers notification returns [block objects](../Reference/Pantheon-API-Objects.md#block-object). The
second parameter is optional. If specified, whole [transaction objects](../Reference/Pantheon-API-Objects.md#transaction-object)
are included in the notifications. Otherwise, the transaction hashes are included.

!!!example
Expand Down Expand Up @@ -151,19 +152,19 @@ are included in the notifications. Otherwise, the transaction hashes are include

### Logs

Use the `logs` parameter with `eth_subscribe` to be notified of [logs](Events-and-Logs.md) included in new blocks. You can
Use the `logs` parameter with `eth_subscribe` to be notified of [logs](../Using-Pantheon/Events-and-Logs.md) included in new blocks. You can
specify a filter object to receive notifications only for logs matching your filter.

Logs subscriptions have an filter object parameter with the following fields:

- `address` - (optional) Either an address or an array of addresses. Returns only logs created from these addresses.
- `topics` - (optional) Returns only logs that match the [specified topics](Events-and-Logs.md#topic-filters).
- `topics` - (optional) Returns only logs that match the [specified topics](../Using-Pantheon/Events-and-Logs.md#topic-filters).

If a chain reorganization occurs, the subscription publishes notifications for logs from the old chain
with the `removed` property in the [log object](../Reference/JSON-RPC-API-Objects.md#log-object) set to `true`.
with the `removed` property in the [log object](../Reference/Pantheon-API-Objects.md#log-object) set to `true`.
This means the subscription can publish notifications for multiple logs for the same transaction.

The logs subscription returns [log objects](../Reference/JSON-RPC-API-Objects.md#log-object).
The logs subscription returns [log objects](../Reference/Pantheon-API-Objects.md#log-object).

!!!example
To subscribe to all logs notifications:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
description: How to use Pantheon JSON-RPC API
description: How to access the Pantheon API using JSON-RPC
<!--- END of page meta data -->

# Using the JSON-RPC API

## Postman

Use the button to import our collection of examples to [Postman](https://www.getpostman.com/).

[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/c765d7d22b055c42a510)

## Endpoint Host and Port

The placeholder
`<JSON-RPC-http-endpoint:port>` and `<JSON-RPC-ws-endpoint:port>` represents an endpoint (IP address and port)
of the JSON-RPC service of a Pantheon node for HTTP and WebSocket requests.
# JSON-RPC over HTTP and WebSockets

To enable JSON-RPC over HTTP or WebSockets, use the [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled)
and [`--rpc-ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled) options.

## RPC Host

Use the [--rpc-http-host](../Reference/Pantheon-CLI-Syntax.md#rpc-http-host) and [--rpc-ws-host](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-host)
options to specify the host on which the JSON-RPC listens. The default host is 127.0.0.1 for HTTP and WebSockets.

Expand All @@ -27,6 +17,8 @@ Set the host to `0.0.0.0` to allow remote connections.
Setting the host to 0.0.0.0 exposes the RPC connection on your node to any remote connection. In a
production environment, ensure you use a firewall to avoid exposing your node to the internet.

## RPC Port

Use the [--rpc-http-port](../Reference/Pantheon-CLI-Syntax.md#rpc-http-port) and [--rpc-ws-port](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port)
options to specify the port on which the JSON-RPC listens. The default ports are:

Expand All @@ -35,6 +27,13 @@ options to specify the port on which the JSON-RPC listens. The default ports are

Ports must be [exposed appropriately](../Configuring-Pantheon/Networking/Managing-Peers.md#port-configuration).

## Postman

Use the button to import our collection of examples to [Postman](https://www.getpostman.com/).

[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/c765d7d22b055c42a510)


## Geth Console

The geth console is a REPL (Read, Evaluate, & Print Loop) Javascript console. Use JSON-RPC APIs supported by geth and
Expand All @@ -51,31 +50,13 @@ To use the geth console with Pantheon:
geth attach http://localhost:8545
```

Use the geth console to call [JSON-RPC API methods](../Reference/JSON-RPC-API-Methods.md) that geth and Pantheon share.
Use the geth console to call [JSON-RPC API methods](../Reference/Pantheon-API-Methods.md) that geth and Pantheon share.

!!! example
```bash
eth.syncing
```

## Host Whitelist

To prevent DNS rebinding, incoming HTTP requests and WebSockets connections are only accepted from hostnames
specified using the [`--host-whitelist`](../Reference/Pantheon-CLI-Syntax.md#host-whitelist) option.
By default, `localhost` and `127.0.0.1` are accepted.

If your application publishes RPC ports, specify the hostnames when starting Pantheon.

!!! example
```bash
pantheon --host-whitelist=example.com
```

Specify * for `--host-whitelist` to effectively disable host protection.

!!! caution
Specifying * for `--host-whitelist` is not recommended for production code.

## JSON-RPC Authentication

[Authentication](Authentication.md) is disabled by default.
Expand Down Expand Up @@ -122,25 +103,12 @@ options to enable the `ADMIN`, `CLIQUE`, `DEBUG`, `EEA`, `IBFT`, `MINER`, `PERM`

When you make requests that might have different results depending on the block accessed,
the block parameter specifies the block.
Several methods, such as [eth_getTransactionByBlockNumberAndIndex](../Reference/JSON-RPC-API-Methods.md#eth_gettransactionbyblocknumberandindex), have a block parameter.
Several methods, such as [eth_getTransactionByBlockNumberAndIndex](../Reference/Pantheon-API-Methods.md#eth_gettransactionbyblocknumberandindex), have a block parameter.

The block parameter can have the following values:

* `blockNumber` : `quantity` - Block number. Can be specified in hexadecimal or decimal. 0 represents the genesis block.
* `earliest` : `tag` - Earliest (genesis) block.
* `latest` : `tag` - Last block mined.
* `pending` : `tag` - Last block mined plus pending transactions. Use only with [eth_getTransactionCount](../Reference/JSON-RPC-API-Methods.md#eth_gettransactioncount).

## Not Supported by Pantheon

### Account Management

Account management relies on private key management in the client which is not implemented by Pantheon.

Use [`eth_sendRawTransaction`](../Reference/JSON-RPC-API-Methods.md#eth_sendrawtransaction) to send signed transactions; `eth_sendTransaction` is not implemented.

Use third-party wallets for [account management](../Using-Pantheon/Account-Management.md).

### Protocols
* `pending` : `tag` - Last block mined plus pending transactions. Use only with [eth_getTransactionCount](../Reference/Pantheon-API-Methods.md#eth_gettransactioncount).

Pantheon does not implement the Whisper and Swarm protocols.
Loading

0 comments on commit be69db8

Please sign in to comment.