README.md 1.81 KiB
Newer Older
Maciej Hirsz's avatar
Maciej Hirsz committed
# Substrate API Sidecar

Small service intended to run next to Substrate, exposing a limited set of endpoints over HTTP with meaningful responses.
Maciej Hirsz's avatar
Maciej Hirsz committed

### Installation

```
Maciej Hirsz's avatar
Maciej Hirsz committed
yarn
Maciej Hirsz's avatar
Maciej Hirsz committed
```

### Running

```
Maciej Hirsz's avatar
Maciej Hirsz committed
yarn start
Maciej Hirsz's avatar
Maciej Hirsz committed
```

Maciej Hirsz's avatar
Maciej Hirsz committed
### Available paths

+ `/block` fetch latest finalized block details.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/block/NUMBER` fetch block details at block height `NUMBER`.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/balance/ADDRESS` fetch balances for `ADDRESS` at latest finalized block.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/balance/ADDRESS/NUMBER` fetch balances for `ADDRESS` at block height `NUMBER`.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/payout/ADDRESS` fetch payout info for `ADDRESS` at latest finalized block.

+ `/payout/ADDRESS/NUMBER` fetch payout info for `ADDRESS` at block height `NUMBER`.

Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/metadata` fetch chain metadata at latest finalized block.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `/metadata/NUMBER` fetch chain metadata at block height `NUMBER`.
+ `/tx/` submit a signed transaction, excepts a string with hex-encoded signed transaction in a json POST body:
    ```
    curl localhost:8080/tx/ -X POST --data '{"tx": "0x..."}' -H 'Content-Type: application/json'
    ```
    Expected result is a json with transaction hash:
    ```
    {
        "hash": "..."
    }
    ```

Maciej Hirsz's avatar
Maciej Hirsz committed
### Configuration

Following ENV variables can be set:

Maciej Hirsz's avatar
Maciej Hirsz committed
+ `BIND_HOST`: address on which the server will be listening, defaults to `127.0.0.1`.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `BIND_PORT`: port on which the server will be listening, defaults to `8080`.
Maciej Hirsz's avatar
Maciej Hirsz committed
+ `NODE_WS_URL`: WebSocket URL to which the RPC proxy will attempt to connect to, defaults to `ws://127.0.0.1:9944`.

### Chain compatibility

Sidecar should be compatible with any [Substrate](https://substrate.dev/) based chain, given constraints:

+ The chain ought to use FRAME and the `balances` pallet.
+ The chain is being finalized (by running `grandpa`).
+ If the chain is running on custom Node binaries, the JSON-RPC API should be backwards compatible with the default Substrate Node.