BitcoinElixir.Electrum (bitcoin_elixir v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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.

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

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

Types

request()

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

server()

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

Functions

batch(requests, opts)

@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(atom)

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

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

request(method, params, opts)

@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.