# Client

#### On this page

* <mark style="color:blue;">ICTech</mark>[ <mark style="color:blue;">gRPC</mark>](#icplaza-grpc)
  * <mark style="color:blue;">ICTech</mark>[ <mark style="color:blue;">gRPC-Gateway (HTTP REST)</mark>](#icplaza-grpc-gateway-http-rest)
* [<mark style="color:blue;">Ethereum JSON-RPC</mark>](#ethereum-json-rpc)
* [<mark style="color:blue;">Ethereum Websocket</mark>](#ethereum-websocket)
* [<mark style="color:blue;">Tendermint Websocket</mark>](#tendermint-websocket)
  * [<mark style="color:blue;">List of Tendermint Events</mark>](#list-of-tendermint-events)
  * [<mark style="color:blue;">Example</mark>](#example)
* [<mark style="color:blue;">CLI</mark>](#cli)

Learn about all the available services for clients {synopsis}

The ICTech supports different clients in order to support ICTech and Ethereum transactions and queries:

|                                                                                                            | Description                                                                          | Default Port |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------ |
| ICTech [<mark style="color:blue;">**gRPC**</mark>](#icplaza-grpc)                                          | Query or send ICTech transactions using gRPC                                         | `9090`       |
| ICTech **REST (**[<mark style="color:blue;">**gRPC-Gateway**</mark>](#icplaza-grpc-gateway-http-rest)**)** | Query or send ICTech transactions using an HTTP RESTful API                          | `9091`       |
| **Ethereum** [<mark style="color:blue;">**JSON-RPC**</mark>](#ethereum-json-rpc)                           | Query Ethereum-formatted transactions and blocks or send Ethereum txs using JSON-RPC | `8545`       |
| **Ethereum** [<mark style="color:blue;">**Websocket**</mark>](#ethereum-websocket)                         | Subscribe to Ethereum logs and events emitted in smart contracts.                    | `8586`       |
| **Tendermint&#x20;**<mark style="color:blue;">**RPC**</mark>                                               | Subscribe to Ethereum logs and events emitted in smart contracts.                    | `26657`      |
| **Tendermint** [<mark style="color:blue;">**Websocket**</mark>](#tendermint-websocket)                     | Query transactions, blocks, consensus state, broadcast transactions, etc.            | `26657`      |
| **Command Line Interface (** [<mark style="color:blue;">**CLI**</mark> ](#cli)**)**                        | Query or send ICTech transactions using your Terminal or Console.                    | N/A          |

### ICTech  gRPC <mark style="color:blue;">#</mark> <a href="#icplaza-grpc" id="icplaza-grpc"></a>

ICTech exposes gRPC endpoints for all the integrated ICTech SDK modules. This makes it easier for wallets and block explorers to interact with the Proof-of-Stake logic and native ICTech transactions and queries.

#### ICTech gRPC-Gateway (HTTP REST) <mark style="color:blue;">#</mark> <a href="#icplaza-grpc-gateway-http-rest" id="icplaza-grpc-gateway-http-rest"></a>

[<mark style="color:blue;">gRPC-Gateway</mark>](https://grpc-ecosystem.github.io/grpc-gateway/) reads a gRPC service definition and generates a reverse-proxy server which translates RESTful JSON API into gRPC. With gRPC-Gateway, users can use REST to interact the ICTech gRPC service.

See the list of supported gRPC-Gateway API endpoints for the ICTech testnet [<mark style="color:blue;">here</mark>](https://api.icplaza.dev/).

### Ethereum JSON-RPC <mark style="color:blue;">#</mark> <a href="#ethereum-json-rpc" id="ethereum-json-rpc"></a>

ICTech supports most of the standard [<mark style="color:blue;">JSON-RPC API</mark>](https://ictech.gitbook.io/icplaza-docs/chain-dev/ethereum-json-rpc)s to connect with existing Ethereum-compatible web3 tooling.

::: tip Check out the list of supported JSON-RPC API \[endpoints] and [<mark style="color:blue;">namespaces</mark>](https://ictech.gitbook.io/icplaza-docs/ethereum-json-rpc#namespaces). :::

### Ethereum Websocket <mark style="color:blue;">#</mark> <a href="#ethereum-websocket" id="ethereum-websocket"></a>

Then, start a websocket subscription with [<mark style="color:blue;">`ws`</mark>](https://github.com/hashrocket/ws)

```bash
# connect to tendermint websocet at port 8546 as defined above
ws ws://localhost:8546/

# subscribe to new Ethereum-formatted block Headers
> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]}
< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1}
```

### Tendermint Websocket <mark style="color:blue;">#</mark> <a href="#tendermint-websocket" id="tendermint-websocket"></a>

Tendermint Core provides a Websocket connection to subscribe or unsubscribe to Tendermint ABCI events.

::: tip For more info about the how to subscribe to events, please refer to the official [<mark style="color:blue;">Tendermint documentation</mark>](https://docs.tendermint.com/v0.34/tendermint-core/subscription.html). :::

```json
{
    "jsonrpc": "2.0",
    "method": "subscribe",
    "id": "0",
    "params": {
        "query": "tm.event='<event_value>' AND eventType.eventAttribute='<attribute_value>'"
    }
}
```

#### List of Tendermint Events <mark style="color:blue;">#</mark> <a href="#list-of-tendermint-events" id="list-of-tendermint-events"></a>

The main events you can subscribe to are:

* `NewBlock`: Contains `events` triggered during `BeginBlock` and `EndBlock`.
* `Tx`: Contains `events` triggered during `DeliverTx` (i.e. transaction processing).
* `ValidatorSetUpdates`: Contains validator set updates for the block.

::: tip

👉 The list of events types and values for each ICTech SDK module can be found in the \[Modules Specification]section. Check the `Events` page to obtain the event list of each supported module on ICTech. :::

List of all Tendermint event keys:

|                                                      | Event Type       | Categories  |
| ---------------------------------------------------- | ---------------- | ----------- |
| Subscribe to a specific event                        | `"tm.event"`     | `block`     |
| Subscribe to a specific transaction                  | `"tx.hash"`      | `block`     |
| Subscribe to transactions at a specific block height | `"tx.height"`    | `block`     |
| Index `BeginBlock` and `Endblock` events             | `"block.height"` | `block`     |
| Subscribe to ABCI `BeginBlock` events                | `"begin_block"`  | `block`     |
| Subscribe to ABCI `EndBlock` events                  | `"end_block"`    | `consensus` |

Below is a list of values that you can use to subscribe for the `tm.event` type:

|                        | Event Value             | Categories  |
| ---------------------- | ----------------------- | ----------- |
| New block              | `"NewBlock"`            | `block`     |
| New block header       | `"NewBlockHeader"`      | `block`     |
| New Byzantine Evidence | `"NewEvidence"`         | `block`     |
| New transaction        | `"Tx"`                  | `block`     |
| Validator set updated  | `"ValidatorSetUpdates"` | `block`     |
| Block sync status      | `"BlockSyncStatus"`     | `consensus` |
| lock                   | `"Lock"`                | `consensus` |
| New consensus round    | `"NewRound"`            | `consensus` |
| Polka                  | `"Polka"`               | `consensus` |
| Relock                 | `"Relock"`              | `consensus` |
| State sync status      | `"StateSyncStatus"`     | `consensus` |
| Timeout propose        | `"TimeoutPropose"`      | `consensus` |
| Timeout wait           | `"TimeoutWait"`         | `consensus` |
| Unlock                 | `"Unlock"`              | `consensus` |
| Block is valid         | `"ValidBlock"`          | `consensus` |
| Consensus vote         | `"Vote"`                | `consensus` |

#### Example <mark style="color:blue;">#</mark> <a href="#example" id="example"></a>

```bash
ws ws://localhost:26657/websocket
> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='ValidatorSetUpdates'"], "id": 1 }
```

Example response:

```json
{
    "jsonrpc": "2.0",
    "id": 0,
    "result": {
        "query": "tm.event='ValidatorSetUpdates'",
        "data": {
            "type": "tendermint/event/ValidatorSetUpdates",
            "value": {
              "validator_updates": [
                {
                  "address": "09EAD022FD25DE3A02E64B0FE9610B1417183EE4",
                  "pub_key": {
                    "type": "tendermint/PubKeyEd25519",
                    "value": "ww0z4WaZ0Xg+YI10w43wTWbBmM3dpVza4mmSQYsd0ck="
                  },
                  "voting_power": "10",
                  "proposer_priority": "0"
                }
              ]
            }
        }
    }
}
```

### CLI <mark style="color:blue;">#</mark> <a href="#cli" id="cli"></a>

Users can use the ICTech binary to interact directly with an ICTech node though the CLI.

::: tip 👉 To use the CLI, you will need to provide a Tendermint RPC address for the `--node` flag. Look for a publicly available addresses for testnet and mainnet in the [<mark style="color:blue;">Quick Connect</mark>](https://ictech.gitbook.io/icplaza-docs/chain-dev/broken-reference) page. :::

* **Transactions**: ICTech `tx`

  The list of available commands, as of `v3.0.0`, are:

  ```bash
  Available Commands:
    authz               Authorization transactions subcommands
    bank                Bank transaction subcommands
    broadcast           Broadcast transactions generated offline
    crisis              Crisis transactions subcommands
    decode              Decode a binary encoded transaction string
    distribution        Distribution transactions subcommands
    encode              Encode transactions generated offline
    erc20               erc20 subcommands
    evidence            Evidence transaction subcommands
    evm                 evm transactions subcommands
    feegrant            Feegrant transactions subcommands
    gov                 Governance transactions subcommands
    ibc                 IBC transaction subcommands
    ibc-transfer        IBC fungible token transfer transaction subcommands
    multisign           Generate multisig signatures for transactions generated offline
    multisign-batch     Assemble multisig transactions in batch from batch signatures
    sign                Sign a transaction generated offline
    sign-batch          Sign transaction batch files
    slashing            Slashing transaction subcommands
    staking             Staking transaction subcommands
    validate-signatures validate transactions signatures
    vesting             Vesting transaction subcommands
  ```
* **Queries**: ICTech `query`

  The list of available commands, as of `v3.0.0`, are:

  ```bash
  Available Commands:
    account                  Query for account by address
    auth                     Querying commands for the auth module
    authz                    Querying commands for the authz module
    bank                     Querying commands for the bank module
    block                    Get verified data for a the block at given height
    claims                   Querying commands for the claims module
    distribution             Querying commands for the distribution module
    epochs                   Querying commands for the epochs module
    erc20                    Querying commands for the erc20 module
    evidence                 Query for evidence by hash or for all (paginated) submitted evidence
    evm                      Querying commands for the evm module
    feegrant                 Querying commands for the feegrant module
    feemarket                Querying commands for the fee market module
    gov                      Querying commands for the governance module
    ibc                      Querying commands for the IBC module
    ibc-transfer             IBC fungible token transfer query subcommands
    incentives               Querying commands for the incentives module
    inflation                Querying commands for the inflation module
    params                   Querying commands for the params module
    recovery                 Querying commands for the recovery module
    slashing                 Querying commands for the slashing module
    staking                  Querying commands for the staking module
    tendermint-validator-set Get the full tendermint validator set at given height
    tx                       Query for a transaction by hash, "<addr>/<seq>" combination or comma-separated signatures in a committed block
    txs                      Query for paginated transactions that match a set of events
    upgrade                  Querying commands for the upgrade module
    vesting                  Querying commands for the vesting module
  ```

::: tip **Note:** When querying Ethereum transactions versus ICTech transactions, the transaction hashes are different. When querying Ethereum transactions, users need to use event query. Here’s an example with the CLI:

```bash
curl -X GET "http://localhost:26657/tx_search?query=ethereum_tx.ethereumTxHash%3D0x8d43464891fac6c113e809e14dff1a3e608eae124d629799e42ca0e36562d9d7&prove=false&page=1&per_page=30&order_by=asc" -H "accept: application/json"
```

:::

[<mark style="color:blue;">← Quick Connect</mark> ](https://ictech.gitbook.io/icplaza-docs/chain-dev/broken-reference)

[<mark style="color:blue;">Guides →</mark>](https://ictech.gitbook.io/icplaza-docs/chain-dev/guides)
