# Utilities

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

Look up the name, coin type, content hash, duration, fuse, role and error helpers that @ensforge/sdk exports besides its actions.

Source: https://ensforge.com/docs/reference/sdk/utilities

Helpers exported from `@ensforge/sdk` (and the same from `@ensforge/sdk/effect`).

## Name [#name]

### `Name.dnsDecode` [#namednsdecode]

Name from its DNS wire-format encoding, as returned by ENSv2 registries and the Universal
Resolver. The labels are returned as stored, without normalizing them.

```ts
function dnsDecode(data: Hex): string
```

```ts title="Decoding a canonical name"
import { Name } from "@ensforge/sdk"

Name.dnsDecode(Name.dnsEncode("nick.eth")) // "nick.eth"
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the bytes are not a DNS-encoded name, or a label contains a dot.

### `Name.dnsEncode` [#namednsencode]

DNS wire-format encoding of a name, as the Universal Resolver and ENSv2 registries expect.

```ts
function dnsEncode(name: string): Hex
```

```ts title="Encoding a name for a resolver call"
import { Name } from "@ensforge/sdk"

const dnsName = Name.dnsEncode("alice.eth")
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the name cannot be normalized.

### `Name.fromLabelhash` [#namefromlabelhash]

Encoded label for a labelhash whose plain label is unknown: `[af2c…]`.

```ts
function fromLabelhash(hash: Hex): string
```

```ts title="Showing an unknown label"
import { Name } from "@ensforge/sdk"

const label = Name.fromLabelhash(Name.labelhash("alice"))
```

### `Name.getParent` [#namegetparent]

Parent of a name, or `null` for top-level names and the root.

```ts
function getParent(name: string): string | null
```

```ts title="Finding the parent"
import { Name } from "@ensforge/sdk"

Name.getParent("sub.alice.eth") // "alice.eth"
Name.getParent("eth")           // null
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the name cannot be normalized.

### `Name.isValid` [#nameisvalid]

Whether `name` normalizes without error. It may still differ from its normalized form.

```ts
function isValid(name: string): boolean
```

```ts title="Validating user input"
import { Name } from "@ensforge/sdk"

Name.isValid("alice.eth") // true
Name.isValid("bad name")  // false
```

### `Name.labelhash` [#namelabelhash]

Keccak-256 hash of one label, normalizing it first. Encoded labels return their hash.

```ts
function labelhash(label: string): Hex
```

```ts title="Hashing a label"
import { Name } from "@ensforge/sdk"

const hash = Name.labelhash("alice")
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the label is empty, contains a dot or cannot be normalized.

### `Name.namehash` [#namenamehash]

ENS node (EIP-137 namehash) of a name, normalizing it first.

```ts
function namehash(name: string): Hex
```

```ts title="Computing a node"
import { Name } from "@ensforge/sdk"

const node = Name.namehash("alice.eth")
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the name cannot be normalized.

### `Name.normalize` [#namenormalize]

Normalizes an ENS name (ENSIP-15).

```ts
function normalize(name: string): string
```

- `""` is the root name and is returned as-is.
- Uses viem's ENSIP-15 normalizer (ENSIP-15 rejects alternative full stops such as `。`).
- Encoded labels such as `[af2c…]` (64 hex digits) are kept, so names from indexers round-trip.

```ts title="Normalizing user input"
import { Name } from "@ensforge/sdk"

Name.normalize("Nick.ETH") // "nick.eth"
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when a label cannot be normalized.

### `Name.parse` [#nameparse]

Splits a name into its labels, TLD and parent after normalizing it.

```ts
function parse(name: string): Parsed
```

```ts title="Parsing a subname"
import { Name } from "@ensforge/sdk"

Name.parse("pay.nick.eth")
// { labels: ["pay", "nick", "eth"], label: "pay", tld: "eth", parent: "nick.eth", is2ld: false, isSubname: true }
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the name cannot be normalized.

### `Name.toTokenId` [#nametotokenid]

ENSv1 `.eth` registrar token ID of a second-level name: the labelhash of its first label as a
number. ENSv2 token IDs change over time; read them with `name.getTokenId`.

```ts
function toTokenId(name: string): bigint
```

```ts title="Finding an ENSv1 token ID"
import { Name } from "@ensforge/sdk"

const tokenId = Name.toTokenId("alice.eth")
```

Errors:

- `InvalidInputError` ([`INVALID_NAME`](/docs/reference/errors/INVALID_NAME)) when the name cannot be normalized.

### `Name.Parsed` [#nameparsed]

Parts of a name.

```ts
type Parsed
```

| Field | Type | Description |
| --- | --- | --- |
| `labels` | `readonly string[]` | Normalized labels, leftmost first. |
| `label` | `string` | Leftmost label, e.g. `nick` for `nick.eth`. Empty for the root name. |
| `tld` | `string` | Top-level domain, e.g. `eth`. Empty for the root name. |
| `parent` | `string \| null` | Parent name, or `null` for top-level names and the root. |
| `is2ld` | `boolean` | Whether the name is a second-level name such as `nick.eth`. |
| `isSubname` | `boolean` | Whether the name has two or more levels below its TLD, such as `pay.nick.eth`. |

## CoinType [#cointype]

### `CoinType.decodeAddress` [#cointypedecodeaddress]

Decodes the bytes of an ENS address record into a display address, or `null` when empty (or the
zero address, for EVM coins).

```ts
function decodeAddress(coinType: bigint, data: Hex): string | null
```

```ts title="Decoding an address record"
import { CoinType } from "@ensforge/sdk"

const shown = CoinType.decodeAddress(CoinType.from("eth"), data)
```

Errors:

- `InvalidInputError` ([`INVALID_COIN_TYPE`](/docs/reference/errors/INVALID_COIN_TYPE)) when no codec exists for the coin.
- `InvalidInputError` ([`INVALID_ADDRESS`](/docs/reference/errors/INVALID_ADDRESS)) when the bytes are not an address of the coin.

### `CoinType.encodeAddress` [#cointypeencodeaddress]

Encodes an address as the bytes stored in an ENS address record.

```ts
function encodeAddress(coinType: bigint, address: string): Hex
```

EVM addresses are stored as 20 raw bytes for any EVM coin type, including chains the codec
library does not list. Other coins use `@ensdomains/address-encoder`.

```ts title="Encoding an address record"
import { CoinType } from "@ensforge/sdk"

const bytes = CoinType.encodeAddress(CoinType.from("eth"), address)
```

Errors:

- `InvalidInputError` ([`INVALID_ADDRESS`](/docs/reference/errors/INVALID_ADDRESS)) when the address is invalid for the coin.

### `CoinType.from` [#cointypefrom]

Resolves any coin input to its numeric coin type.

```ts
function from(input: Input): bigint
```

```ts title="Coin types"
import { CoinType } from "@ensforge/sdk"

CoinType.from("btc")             // 0n
CoinType.from({ chainId: 8453 }) // 2147492101n (Base)
```

Errors:

- `InvalidInputError` ([`INVALID_COIN_TYPE`](/docs/reference/errors/INVALID_COIN_TYPE)) for unknown symbols or negative values.

### `CoinType.fromChainId` [#cointypefromchainid]

ENSIP-11 coin type of an EVM chain. Ethereum mainnet is `60`.

```ts
function fromChainId(chainId: number): bigint
```

```ts title="Coin type of a chain"
import { CoinType } from "@ensforge/sdk"

CoinType.fromChainId(8453) // 2147492101n (Base)
```

Errors:

- `InvalidInputError` ([`INVALID_COIN_TYPE`](/docs/reference/errors/INVALID_COIN_TYPE)) when `chainId` is not a valid chain ID.

### `CoinType.isEvm` [#cointypeisevm]

Whether a coin type is an EVM chain (Ethereum mainnet or ENSIP-11).

```ts
function isEvm(coinType: bigint): boolean
```

```ts title="Telling EVM coins apart"
import { CoinType } from "@ensforge/sdk"

CoinType.isEvm(CoinType.from("eth")) // true
CoinType.isEvm(CoinType.from("btc")) // false
```

### `CoinType.toChainId` [#cointypetochainid]

EVM chain ID of a coin type, or `null` for non-EVM coins.

```ts
function toChainId(coinType: bigint): number | null
```

```ts title="Recovering a chain ID"
import { CoinType } from "@ensforge/sdk"

CoinType.toChainId(2147492101n) // 8453
```

### `CoinType.toSymbol` [#cointypetosymbol]

Symbol of a coin type, such as `btc`, or `null` when unknown.

```ts
function toSymbol(coinType: bigint): string | null
```

```ts title="Naming a coin type"
import { CoinType } from "@ensforge/sdk"

CoinType.toSymbol(0n) // "btc"
```

### `CoinType.Input` [#cointypeinput]

What identifies a coin: a symbol (`"btc"`), an EVM chain (`{ chainId: 8453 }`) or a numeric
coin type.

```ts
type Input = string | bigint | { readonly chainId: number };
```

## ContentHash [#contenthash]

### `ContentHash.decode` [#contenthashdecode]

Decodes the bytes of an ENS `contenthash` record, or returns `null` when empty.

```ts
function decode(data: Hex): Decoded | null
```

```ts title="Decoding a content hash"
import { ContentHash } from "@ensforge/sdk"

const decoded = ContentHash.decode(data)
decoded?.uri // "ipfs://…"
```

Errors:

- `InvalidInputError` ([`INVALID_CONTENT_HASH`](/docs/reference/errors/INVALID_CONTENT_HASH)) when the bytes are malformed or use an unsupported codec.

### `ContentHash.encode` [#contenthashencode]

Encodes a content URI as the bytes stored in an ENS `contenthash` record (ENSIP-7).

```ts
function encode(uri: string): Hex
```

```ts title="Encoding an IPFS link"
import { ContentHash } from "@ensforge/sdk"

ContentHash.encode("ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi")
```

Errors:

- `InvalidInputError` ([`INVALID_CONTENT_HASH`](/docs/reference/errors/INVALID_CONTENT_HASH)) for unsupported schemes or values.

### `ContentHash.toGatewayUrl` [#contenthashtogatewayurl]

HTTP URL for a content URI through a gateway: `ipfs://` and `ipns://` through `gateways.ipfs`,
`ar://` through `gateways.arweave` and `bzz://` through `gateways.swarm`. Unset gateways are the
public defaults (`https://ipfs.io`, `https://arweave.net`, `https://api.gateway.ethswarm.org`).
URIs without a gateway (`onion://`, `sia://`, anything else) are returned as-is.

```ts
function toGatewayUrl(uri: string, gateways?: Gateways | undefined): string
```

```ts title="Using the client's gateways"
import { ContentHash } from "@ensforge/sdk"

const contentHash = await ens.record.getContentHash({ name: "vitalik.eth" })
const url = contentHash && ContentHash.toGatewayUrl(contentHash.uri, ens.config.gateways)
```

### `ContentHash.Decoded` [#contenthashdecoded]

A decoded content hash.

```ts
type Decoded
```

| Field | Type | Description |
| --- | --- | --- |
| `protocol` | `Protocol` |  |
| `value` | `string` | The identifier without scheme, e.g. a CID. |
| `uri` | `string` | `protocol://value`. |

### `ContentHash.Protocol` [#contenthashprotocol]

URI scheme of a supported content hash, e.g. `ipfs` in `ipfs://bafy…`.

```ts
type Protocol = keyof typeof schemes;
```

## Duration [#duration]

### `Duration.days` [#durationdays]

`n` days in seconds.

```ts
function days(n: number | bigint): bigint
```

```ts title="Extending by a month"
import { Duration } from "@ensforge/sdk"

await ens.registration.renew({ names: "alice.eth", duration: Duration.days(30) })
```

Errors:

- `InvalidInputError` ([`INVALID_DURATION`](/docs/reference/errors/INVALID_DURATION)) for negative or fractional values.

### `Duration.years` [#durationyears]

`n` 365-day years in seconds, as ENS registrars count them.

```ts
function years(n: number | bigint): bigint
```

```ts title="A one-year registration"
import { Duration } from "@ensforge/sdk"

await ens.registration.register({ names: "alice.eth", duration: Duration.years(1) })
```

Errors:

- `InvalidInputError` ([`INVALID_DURATION`](/docs/reference/errors/INVALID_DURATION)) for negative or fractional values.

## Fuse [#fuse]

### `Fuse.decode` [#fusedecode]

Every fuse in `mask`, by name.

```ts
function decode(mask: number): Decoded
```

```ts title="Reading a fuse mask"
import { Fuse } from "@ensforge/sdk"

const { cannotUnwrap, cannotTransfer } = Fuse.decode(Fuse.from(["cannotUnwrap"]))
```

### `Fuse.from` [#fusefrom]

Fuse mask with every fuse in `names` burned.

```ts
function from(names: readonly Name[]): number
```

```ts title="Building a fuse mask"
import { Fuse } from "@ensforge/sdk"

const mask = Fuse.from(["cannotUnwrap", "cannotSetResolver"])
```

Errors:

- `InvalidInputError` ([`INVALID_RECORD_VALUE`](/docs/reference/errors/INVALID_RECORD_VALUE)) for unknown fuse names.

### `Fuse.has` [#fusehas]

Whether `name` is burned in `mask`.

```ts
function has(mask: number, name: Name): boolean
```

```ts title="Checking one fuse"
import { Fuse } from "@ensforge/sdk"

const locked = Fuse.has(Fuse.from(["cannotUnwrap"]), "cannotUnwrap")
```

### `Fuse.Decoded` [#fusedecoded]

Every fuse with whether it is burned.

```ts
type Decoded = { readonly [name in Name]: boolean };
```

### `Fuse.Name` [#fusename]

An ENSv1 NameWrapper fuse name.

```ts
type Name = keyof typeof fuses;
```

## Role [#role]

### `Role.admin` [#roleadmin]

Admin role that grants and revokes `name`, e.g. `setResolver` → `setResolverAdmin`.

```ts
function admin<const name extends Name>(name: name): `${name}Admin`
```

```ts title="Granting a role with its admin"
import { Role } from "@ensforge/sdk"

const bitmap = Role.from(["setText", Role.admin("setText")])
```

### `Role.from` [#rolefrom]

Bitmap with every role in `names` set.

```ts
function from(names: readonly Name[]): bigint
```

```ts title="Building a bitmap"
import { Role } from "@ensforge/sdk"

Role.from(["setText", "setAddr"])
```

Errors:

- `InvalidInputError` ([`INVALID_ROLES`](/docs/reference/errors/INVALID_ROLES)) for unknown role names.

### `Role.has` [#rolehas]

Whether `bitmap` has every role in `names`.

```ts
function has(bitmap: bigint, names: Name | readonly Name[]): boolean
```

```ts title="Checking roles"
import { Role } from "@ensforge/sdk"

const bitmap = Role.from(["setText", "setAddr"])
Role.has(bitmap, "setText")                // true
Role.has(bitmap, ["setText", "setAddr"])  // true
```

Errors:

- `InvalidInputError` ([`INVALID_ROLES`](/docs/reference/errors/INVALID_ROLES)) for unknown role names.

### `Role.registry` [#roleregistry]

Registry role bits from contracts-v2 v1.0.1 (`canTransfer` is `1n << 28n`).

```ts
const registry: typeof Roles.registry
```

```ts title="Reading a registry role"
import { Role } from "@ensforge/sdk"

const canRenew = Role.registry.renew
```

### `Role.resolver` [#roleresolver]

PermissionedResolver role bits from contracts-v2 v1.0.1.

```ts
const resolver: typeof Roles.resolver
```

```ts title="Reading a resolver role"
import { Role } from "@ensforge/sdk"

const canSetText = Role.resolver.setText
```

### `Role.toNames` [#roletonames]

Names of the roles set in `bitmap` for a registry or resolver.

```ts
function toNames(bitmap: bigint, target: Target): readonly Name[]
```

```ts title="Listing roles"
import { Role } from "@ensforge/sdk"

Role.toNames(Role.from(["setText"]), "resolver") // ["setText"]
```

### `Role.Name` [#rolename]

A registry or resolver role name.

```ts
type Name = keyof typeof registry | keyof typeof resolver;
```

### `Role.Target` [#roletarget]

Which contract a role bitmap belongs to. Registry and resolver roles share bit positions.

```ts
type Target = "registry" | "resolver";
```

## Errors [#errors]

### `Errors.describe` [#errorsdescribe]

Turns any thrown value into a title, message and suggested action that are safe to show users.

```ts
function describe<error extends EnsforgeError = AnyError>(value: unknown, options: DescribeOptions<error> = {}): Description
```

Use in UI error handlers instead of showing `error.message`, which is written for developers.

- Accepts any value; non-ensforge errors go through `Errors.fromCause` first.
- Packages that extend ensforge, such as `@ensforge/hca`, add copy for their own codes; a code
  without copy gets the generic [`UNEXPECTED`](/docs/reference/errors/UNEXPECTED) copy.
- Override copy per code with `messages`, for example to translate.

```ts title="Showing an error toast"
import { Errors } from "@ensforge/sdk"

try {
  await ens.record.set({ name: "alice.eth", texts: { url: "https://alice.dev" } })
} catch (error) {
  const { title, message, action } = Errors.describe(error)
  toast({ title, description: action === undefined ? message : `${message} ${action}` })
}
```

```ts title="Translating one code"
import { Errors } from "@ensforge/sdk"

Errors.describe(error, {
  messages: { NAME_NOT_AVAILABLE: (e) => ({ title: "Nombre no disponible", message: `${e.context.name} ya está registrado.` }) },
})
```

### `Errors.fromCause` [#errorsfromcause]

Translates any thrown value into an ensforge error and adds `context`.

```ts
function fromCause(cause: unknown, context?: EnsforgeError.Context): EnsforgeError
```

Use when calling viem directly next to ensforge actions, to get the same error classes, codes
and `Errors.describe` messages. Every ensforge action already does this.

- ensforge errors are returned as-is, with `context` merged in.
- viem errors are matched along their `cause` chain; contract reverts are decoded against every
  ENS contract error, unwrapping `ResolverError` and the mainnet `ResolutionError`.
- Anything else becomes `InternalError` ([`UNEXPECTED`](/docs/reference/errors/UNEXPECTED)) with the original as `cause`.

```ts title="Translating a viem error"
import { Errors } from "@ensforge/sdk"

try {
  await walletClient.writeContract(request)
} catch (cause) {
  const error = Errors.fromCause(cause, { operation: "custom.write" })
  toast(Errors.describe(error).title)
}
```

### `Errors.hasCode` [#errorshascode]

Returns a type guard that matches ensforge errors with one of `codes`.

```ts
function hasCode<const codes extends readonly Code[]>(...codes: codes)
```

```ts title="Branching on a code"
import { Errors } from "@ensforge/sdk"

if (Errors.hasCode("NAME_NOT_AVAILABLE", "NAME_RESERVED")(error)) suggestAlternatives()
```

### `Errors.is` [#errorsis]

Whether `value` is an ensforge error. Uses a brand instead of `instanceof`, so it also works
when two copies of `@ensforge/sdk` are installed.

```ts
function is(value: unknown): value is AnyError
```

### `Errors.setConfig` [#errorssetconfig]

Changes global error settings, e.g. to point `docsUrl` at a self-hosted docs mirror.

```ts
function setConfig(config: Partial<Config>): void
```

### `Errors.AnyError` [#errorsanyerror]

Every error class ensforge throws.

```ts
type AnyError = | Classes.CommitmentError | Classes.ConfigError | Classes.ContractRevertError | Classes.DnsError | Classes.GatewayError | Classes.IndexerError | Classes.InsufficientFundsError | Classes.InternalError | Classes.InvalidInputError | Classes.MigrationError | Classes.NameStateError | Classes.NetworkError | Classes.NotFoundError | Classes.PlanError | Classes.TransactionError | Classes.UnauthorizedError | Classes.UnsupportedError | Classes.UserRejectedError | Classes.WalletError;
```

### `Errors.Code` [#errorscode]

Every error code. Codes are stable: renaming or removing one is a breaking change.

```ts
type Code = AnyError["code"];
```

### `Errors.CommonError` [#errorscommonerror]

Errors every action can fail with, besides the ones its `@throws` documents: a misconfigured
client or a contract missing on the chain (`ConfigError`, [`CONTRACT_NOT_DEPLOYED`](/docs/reference/errors/CONTRACT_NOT_DEPLOYED)), a failing RPC (`NetworkError`), a contract call
reverting with an error ensforge does not map (`ContractRevertError`), and anything ensforge
could not translate (`InternalError` [`UNEXPECTED`](/docs/reference/errors/UNEXPECTED)).

```ts
type CommonError = | Classes.ConfigError | Classes.ContractRevertError | Classes.InternalError | Classes.NetworkError;
```

### `Errors.Config` [#errorsconfig]

Global error settings.

```ts
type Config
```

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `docsOrigin` (required) | `string` |  | Origin of the documentation site used in `docsUrl`. @default "https://ensforge.com" |

### `Errors.DescribeOptions` [#errorsdescribeoptions]

Options for `describe`. `error` is the union of error classes whose codes `messages`
may override: every sdk error by default; add a package's class to override its codes too,
e.g. `DescribeOptions<Errors.AnyError | HcaError>`.

```ts
type DescribeOptions<error extends EnsforgeError = AnyError>
```

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `messages` | `{ readonly [code in EnsforgeError["code"]]?: ( EnsforgeError: EnsforgeError extends { readonly code: infer codes } ? code extends codes ? EnsforgeError : never : never, ) => Partial<Copy>; }` |  | Replacement copy by code, e.g. translations. Missing fields fall back to the English copy. |

### `Errors.Description` [#errorsdescription]

User-facing description of an error.

```ts
type Description = Copy & { /** A code of `Errors.Code`, or of a package that extends ensforge (e.g. `HcaError`). */ readonly code: Code | (string & {}); readonly retryable: boolean; /** `info`: expected outcome; `warning`: temporary, retry later; `error`: needs attention. */ readonly severity: "info" | "warning" | "error"; };
```

| Field | Type | Description |
| --- | --- | --- |
| `title` | `string` |  |
| `message` | `string` |  |
| `action` (optional) | `string` |  |
| `code` | `Code \| (string & {})` | A code of `Errors.Code`, or of a package that extends ensforge (e.g. `HcaError`). |
| `retryable` | `boolean` |  |
| `severity` | `"info" \| "warning" \| "error"` | `info`: expected outcome; `warning`: temporary, retry later; `error`: needs attention. |

### `Errors.ErrorOf` [#errorserrorof]

The error class that can carry `code`, e.g. `ErrorOf<"MISSING_ROLES">` is `UnauthorizedError`.

```ts
type ErrorOf<code extends Code> = AnyError extends infer error ? error extends { readonly code: infer codes } ? code extends codes ? error : never : never : never;
```

### `Errors.WriteError` [#errorswriteerror]

Errors every write can fail with, besides the ones its `@throws` documents: `CommonError` and
the errors of signing and sending, also on `.prepare`, `.simulate`, `.estimateGas` and the
`…Sync` form.

```ts
type WriteError = | CommonError | Classes.InsufficientFundsError | Classes.TransactionError | Classes.UnsupportedError | Classes.UserRejectedError | Classes.WalletError;
```

- `WalletError`, or `ConfigError` ([`WALLET_NOT_CONFIGURED`](/docs/reference/errors/WALLET_NOT_CONFIGURED)), when the wallet cannot sign.
- `UserRejectedError` when the wallet's user declines.
- `InsufficientFundsError` ([`INSUFFICIENT_ETH`](/docs/reference/errors/INSUFFICIENT_ETH)) when the account cannot pay for gas or the
  ETH the call sends.
- `UnsupportedError` ([`WALLET_BATCH_UNSUPPORTED`](/docs/reference/errors/WALLET_BATCH_UNSUPPORTED)) when the wallet cannot send a batch.
- `TransactionError` when a transaction reverts, conflicts or is not mined in time.
- A `via` route can also fail with its own package's errors (e.g. `HcaError`).