# AnvilNode.placeMulticall3

Puts the code of Multicall3 on an anvil chain, where every chain has it. Reads that are merged
are then one plain `eth_call`, as on a real chain.

## Usage

```ts
import { Effect } from "effect";
import { type Address, Call, Erc20 } from "@ethect/core";
import { AnvilNode } from "@ethect/core/testing";

/** In a test: two reads that leave as one request, which a counter of requests can hold. */
const position = (address: Address.Address, user: Address.Address) =>
  Effect.gen(function* () {
    yield* AnvilNode.placeMulticall3();
    const token = Erc20.at(address);
    return yield* Call.all({ symbol: token.symbol(), balance: token.balanceOf(user) });
    // one eth_call, to 0xcA11bde05977b3631167028862bE2a173976CA11
  });
```

A fresh anvil has no contract at all. Reads are merged there all the same: the code of
Multicall3 is placed for the length of each `eth_call`, by a state override. That is a first
request that Multicall3 does not answer, then one with the override, where a real chain takes
one. A test that asserts "one `eth_call`" puts Multicall3 there first.

It acts on the node of the [`Transport`](https://ethect.dev/reference/transport/) in context: an anvil started
with [`AnvilNode.layer`](https://ethect.dev/reference/testing/anvil-node/#layer), or any other.

## Returns

`Effect<void, Transport.Error, Transport>`

Nothing. When it ends, the address holds the runtime code of Multicall3.

## Parameters

### at (optional)

- **Type:** [`Address.Address`](https://ethect.dev/reference/primitives/address/)
- **Default:** `0xcA11bde05977b3631167028862bE2a173976CA11`

Where to put the code. Another address is for a program that names its aggregator, with
`multicall` of [`Call.batching`](https://ethect.dev/reference/call/batching/#parameters).

## Behavior

- **It deploys nothing.** The code is written at the address: no transaction, no block, and
  no nonce is used.
- **It lasts as long as the chain.** A node per test starts without it.
- **It is the code the library places by itself.** Multicall3 compiled from its source, the
  same bytes a state override carries on a chain that has none.

## Errors

| Error | When |
| --- | --- |
| [`RpcError`](https://ethect.dev/reference/errors/rpc-error/) | the node refused: one that is not anvil has no `anvil_setCode` |
| [`TransportError`](https://ethect.dev/reference/errors/transport-error/) | the node could not be reached |

## Under the hood

One request to the node of the `Transport` in context.

- **your node** `anvil_setCode(at, the runtime code of Multicall3)`
