# The web3_ methods (Web3)

The `web3_` namespace: what software the node runs, and a Keccak-256 hash computed by the node.

```ts
import { Effect } from "effect";
import { FetchHttpClient } from "effect/http";
import { Transport } from "@ethect/core";
import { Web3 } from "@ethect/core/rpc";

const client = await Web3.clientVersion().pipe(
  Effect.provide(Transport.http("http://127.0.0.1:8545")),
  Effect.provide(FetchHttpClient.layer),
  Effect.runPromise,
);
// "anvil/v1.9.0"
```

A method returns an
[`Effect<…, Method.Error, Transport>`](https://ethect.dev/rpc/method/#calling-a-method) of the decoded
result. The name is the wire name without its prefix: `web3_clientVersion` is
`Web3.clientVersion`.

## Methods

| Method | JSON-RPC | Returns | Description |
| --- | --- | --- | --- |
| [`clientVersion`](#clientversion) | `web3_clientVersion` | `string` | The name and version of the node's client. |
| [`sha3`](#sha3) | `web3_sha3` | `Hash` | The Keccak-256 hash of the given bytes, computed by the node. |

## clientVersion

Returns the name and version of the node's client.

```ts
import { Effect } from "effect";
import { Web3 } from "@ethect/core/rpc";

const isAnvil = Web3.clientVersion().pipe(
  Effect.map((version) => version.startsWith("anvil/")), // true
);
```

- **JSON-RPC:** `web3_clientVersion`
- **Parameters:** none.
- **Returns:** `string`. The format is the client's own: anvil 1.9 answers `"anvil/v1.9.0"`.

## sha3

Returns the Keccak-256 hash of the given bytes, computed by the node.

```ts
import { Hex } from "@ethect/core";
import { Web3 } from "@ethect/core/rpc";

// the bytes of the text "hello"
const hash = Web3.sha3(Hex.fromUtf8("hello"));
// "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
```

- **JSON-RPC:** `web3_sha3`
- **Parameters:** `data` ([`Hex.Hex`](https://ethect.dev/reference/primitives/hex/)), the bytes to hash.
- **Returns:** [`Hash`](https://ethect.dev/reference/primitives/hash/).
- The data is hashed as bytes, not as text. `Web3.sha3("0x")` is the hash of no bytes at all,
  `"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"`.
- anvil refuses hex with an odd number of digits, such as `"0x1"`, with an `RpcError` of reason
  `InvalidParams`.

## Behavior

- **No request needed for a hash.** [`Hash.keccak256`](https://ethect.dev/reference/primitives/hash/) computes
  the same hash locally. `Web3.sha3` costs a round trip to the node for the same result.
