Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeHCA

Installation

Install @ensforge/hca next to the SDK, then add the HCA actions to your client so that ens.hca and the hca() route are available.

Experimental

@ensforge/hca is experimental for 1.0. Its API can change in a minor release, and the bundler and Rhinestone paths have no production proof yet. Pin the version you test.

@ensforge/hca adds hosted contract accounts (HCA) to the ensforge client. An HCA is a smart account that ENS hosts for a wallet. See How it works.

Requirements

  • Node.js 20.19 or later.
  • @ensforge/sdk, effect (version 4.1.4 or later) and viem (version 2.57 or later). The package lists effect and viem as peer dependencies.
  • A chain with an HCA deployment: Ethereum mainnet or Sepolia. Other chains fail with HCA_UNAVAILABLE unless you define a deployment that has an hca group.

1. Install the packages

npm install @ensforge/hca @ensforge/sdk effect viem

2. Add the actions to the client

hcaActions() adds the ens.hca actions. hcaAdminActions() adds ens.hcaAdmin, which only governance accounts need. See Upgrades and governance.

Example (A Client With HCA Actions)

client.ts
import { hcaActions, hcaAdminActions } from "@ensforge/hca";
import { Ensforge, ensActions } from "@ensforge/sdk";
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { sepolia } from "viem/chains";

const account = privateKeyToAccount(
  "0x0123456789012345678901234567890123456789012345678901234567890123",
);

const ens = Ensforge.create({
  publicClient: createPublicClient({ chain: sepolia, transport: http() }),
  walletClient: createWalletClient({ account, chain: sepolia, transport: http() }),
})
  .extend(ensActions())
  .extend(hcaActions())
  .extend(hcaAdminActions());
  • Replace the placeholder key with your signer. Never commit a real key.
  • Writes through an HCA need a wallet client, because the HCA's owner signs or sends them.

Use the Effect API

The same actions run in Effect programs: import Actions from @ensforge/hca/effect. See The Effect API.

Troubleshooting

HCA_UNAVAILABLE

The client's chain has no HCA deployment. Use mainnet or Sepolia, or pass a deployment that has an hca group. See HCA_UNAVAILABLE.

Was this page helpful?