Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions content/md/en/docs/build/remote-procedure-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,17 @@ The information returned by these calls can be useful for testing purposes with

## Endpoints

When you start a Substrate node locally, there are two endpoints available by default:
When you start a Substrate node locally, there is one endpoint available by default:

- HTTP endpoint: `http://localhost:9933/`
- WebSocket endpoint: `ws://localhost:9944/`
- HTTP & WebSocket endpoint: `ws://localhost:9944/`

Most of the Substrate front-end libraries and tools use the WebSocket endpoint to interact with the blockchain.
For example, if you use the Polkadot-JS application to connect to a local node or a public chain, your are typically connecting to the WebSocket endpoint.
Most of the Substrate front-end libraries and tools use the endpoint to interact with the blockchain.
For example, if you use the Polkadot-JS application to connect to a local node or a public chain, your are typically connecting to the HTTP & WebSocket endpoint.
WebSocket connections allow for bidirectional communication between the front-end application and the backend node responding to requests.
However, you can also call RPC methods individually without keeping an open communication channel by connecting to the HTTP endpoint using `curl` commands.
However, you can also call RPC methods individually without keeping an open communication channel by connecting to the endpoint using `curl` commands.
For example, you can use curl commands to get system information or subscribe to a chain to receive notification when there are specific types of changes to the block state.

To call RPC methods using the HTTP endpoint:
To call RPC methods using the endpoint:

1. Open a terminal shell and change to the root directory for the Substrate node template.

Expand All @@ -85,7 +84,7 @@ To call RPC methods using the HTTP endpoint:
3. Connect to the local node and call the `rpc_methods` endpoint by running the following command:

```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods"}' http://localhost:9933/
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods"}' http://localhost:9944/
```

This command returns a list of the JSON-RPC methods exposed for the local node.
Expand All @@ -95,7 +94,7 @@ To call RPC methods using the HTTP endpoint:
For example, you can run the following command to get version information about the local node:

```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' http://localhost:9933/
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' http://localhost:9944/
```

In most cases, connecting to the RPC endpoint directly returns JSON-formatted results.
Expand All @@ -118,7 +117,7 @@ This is how RPC endpoints know where to look.
To get metadata for a local node, you can run the following command:

```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata"}' http://localhost:9933/
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata"}' http://localhost:9944/
```

This command returns the metadata in hex-encoded bytes rather than a human-readable format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ To start the first node:
--chain ./customSpecRaw.json \
--port 30333 \
--rpc-port 9945 \
--rpc-port 9933 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--rpc-methods Unsafe \
Expand Down Expand Up @@ -474,7 +473,6 @@ To add a second validator to the private network:
--chain ./customSpecRaw.json \
--port 30334 \
--rpc-port 9946 \
--rpc-port 9934 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--rpc-methods Unsafe \
Expand Down Expand Up @@ -553,7 +551,6 @@ To add a second validator to the private network:
--chain ./customSpecRaw.json \
--port 30334 \
--rpc-port 9946 \
--rpc-port 9934 \
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
--validator \
--rpc-methods Unsafe \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ To start the blockchain:
--alice \
--port 30333 \
--rpc-port 9945 \
--rpc-port 9933 \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator
Expand All @@ -91,8 +90,7 @@ Before moving on, have a look at how the following options are used to start the
| `--chain local` | Specifies the chain specification to use. Valid predefined chain specifications include `local`, `development`, and `staging`. |
| `--alice` | Adds the predefined keys for the `alice` account to the node's keystore. With this setting, the `alice` account is used for block production and finalization. |
| `--port 30333` | Specifies the port to listen on for peer-to-peer (`p2p`) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account. |
| `--rpc-port 9945` | Specifies the port to listen on for incoming WebSocket traffic. The default port is `9944`. This tutorial uses a custom web socket port number (`9945`). |
| `--rpc-port 9933` | Specifies the port to listen on for incoming RPC traffic. The default port is `9933`. |
| `--rpc-port 9945` | Specifies the port to listen on for incoming WebSocket and RPC traffic. The default port is `9944`. This tutorial uses a custom web socket port number (`9945`). |
| `--node-key <key>` | Specifies the Ed25519 secret key to use for `libp2p` networking. You should only use this option for development and testing. |
| `--telemetry-url` | Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use. |
| `--validator` | Specifies that this node participates in block production and finalization for the network. |
Expand Down Expand Up @@ -123,8 +121,7 @@ For example, you should see output similar to this:
2022-08-16 15:29:56 💻 CPU architecture: x86_64
2022-08-16 15:29:56 📦 Highest known block at #0
2022-08-16 15:29:56 〽️ Prometheus exporter started at 127.0.0.1:9615
2022-08-16 15:29:56 Running JSON-RPC HTTP server: addr=127.0.0.1:9933, allowed origins=Some(["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"])
2022-08-16 15:29:56 Running JSON-RPC WS server: addr=127.0.0.1:9945, allowed origins=Some(["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"])
2022-08-16 15:29:56 Running JSON-RPC server: addr=127.0.0.1:9945, allowed origins=Some(["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"])
2022-08-16 15:29:56 creating instance on iface 192.168.1.125
2022-08-16 15:30:01 💤 Idle (0 peers), best: #0 (0x2cdc…a07f), finalized #0 (0x2cdc…a07f), ⬇ 0 ⬆ 0
...
Expand Down Expand Up @@ -170,15 +167,14 @@ To add a node to the running blockchain:
--bob \
--port 30334 \
--rpc-port 9946 \
--rpc-port 9934 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
```

Note the following differences between this command and the previous one:

- Because the two nodes are running on the same physical computer, you must specify different values for the `--base-path`, `--port`, `--rpc-port`, and `--rpc-port` options.
- Because the two nodes are running on the same physical computer, you must specify different values for the `--base-path`, `--port`, and `--rpc-port` options.

- This command includes the `--bootnodes` option and specifies a single boot node, the node started by `alice`.

Expand Down