# `BitcoinElixir.Electrum`
[🔗](https://github.com/cashlet-labs/bitcoin-elixir/blob/v0.1.0/lib/bitcoin_elixir/electrum.ex#L1)

A client for the Electrum Cash protocol, served by Fulcrum and other
Electrum servers. Use it to look up addresses (by scripthash), transactions
and the chain tip.

`request/3` and `batch/2` open one connection, send the requests, close it,
and try the next server on failure. For live notifications, start a
`BitcoinElixir.Electrum.Connection` instead.

    servers = BitcoinElixir.Electrum.default_servers(:mainnet)
    {:ok, %{"height" => tip}} = BitcoinElixir.Electrum.request("blockchain.headers.subscribe", [], servers: servers)

A server is `{host, port, :ssl | :tcp}`. TLS certificates are verified
against the system's CA store.

# `request`

```elixir
@type request() :: {String.t(), list()}
```

# `server`

```elixir
@type server() :: {String.t(), :inet.port_number(), :ssl | :tcp}
```

# `batch`

```elixir
@spec batch([request()], keyword()) :: {:ok, [term()]} | {:error, term()}
```

Send several requests on one connection; results come back in order. If any
request fails with a server error, the whole batch returns that error
(`{:error, {:rpc, error}}`) rather than trying another server, because the
answer would be the same.

# `default_servers`

```elixir
@spec default_servers(:mainnet | :chipnet) :: [server()]
```

Public servers checked on 22 Nov 2026. Run your own Fulcrum for production.

# `request`

```elixir
@spec request(String.t(), list(), keyword()) :: {:ok, term()} | {:error, term()}
```

Send one request. Options: `:servers` (required; tried in order) and
`:timeout` in milliseconds per server.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
