@caplane/shared is the order encoding, signing, and registry layer the consumer agent, the relayer, and the el-proxy share. It is the convenience layer; the encoding spec is the contract. You can reimplement the encoding in any language and still be correct. The groups below mirror the package’s index.ts exports. The @caplane/consumer-agent conveniences (the connect() on-ramp) are listed at the end.
Order and hashing
| Export | Signature | Purpose |
|---|---|---|
Order | interface | The 8-field order. See the Order struct. |
ORDER_TUPLE | const | The ABI tuple mirroring Order field order and types. |
encodeOrder | (order: Order) => Hex | abi.encode(order) via viem’s encodeAbiParameters. |
orderHash | (order: Order) => Hex | keccak256(encodeOrder(order)), the EIP-3009 nonce. |
Signing
| Export | Signature | Purpose |
|---|---|---|
TRANSFER_WITH_AUTHORIZATION | const | The EIP-3009 typed-data schema (nonce is bytes32). |
buildTransferAuthorization | (domain, order, broker, validAfter, validBefore) => TransferAuthorization | The unsigned authorization (pure; testable against a golden digest). |
transferAuthDigest | (auth: TransferAuthorization) => Hex | The EIP-712 digest the token verifies. |
signOrder | (account, domain, order, broker, validAfter, validBefore) => Promise<SignedAuthorization> | Sign the authorization with nonce = orderHash. Returns { v, r, s, validAfter, validBefore, orderHash }. |
SignedAuthorization | interface | The split signature plus the window and the bound orderHash. |
Wire and relayer types
| Export | Signature | Purpose |
|---|---|---|
orderToJson | (order: Order) => OrderJson | Serialize an order to its wire shape (uint256 as decimal strings). |
orderFromJson | (json: OrderJson) => Order | Parse an order from its wire shape. |
RELAY_ERROR_STATUS | Record<RelayErrorCode, number> | The code to HTTP status map. |
RelayRequest | interface | The POST /broker body. |
RelaySuccess | interface | The 200 response (ok, txHash, orderHash, brokered, receipt, feeCollected). |
RelayFailure | interface | The error response (ok: false, code, message). Carries no key material. |
RelayResponse | type | The union RelaySuccess or RelayFailure. |
RelayErrorCode | type | The seven settlement error codes. See errors. |
RelayerInfo | interface | The GET /info body (feeFloorBps, supportedChainIds, relayer). |
OrderJson | interface | The order’s JSON wire shape. |
Registry and discovery
Addresses are never hard-coded. They are read from the registry, which is the single trust root.| Export | Signature | Purpose |
|---|---|---|
loadRegistry | (chainId, opts?) => Registry | Load a chain’s registry (contracts, USDC domain, rpcUrl, explorer). |
loadChain | (chainId, opts?) => Registry | Alias used by connect(). |
resolveDeploymentsDir | (opts?) => string | Resolve the deployments directory. |
resolveCapability | (name, opts?) => ResolvedCapability | Resolve a capability to its chain and adapter address. Fails closed on an unknown capability. |
listCapabilities | (opts?) => string[] | The capability names available. |
loadCapabilities | (opts?) => CapabilitiesFile | Parse capabilities.json. |
domainFromRegistry | (registry) => Eip712Domain | Build the USDC EIP-712 domain. |
CHAIN_IDS | const | { arbitrumSepolia: 421614, robinhoodTestnet: 46630 }. |
REGISTRY_FILES | const | The registry file names per chain. |
Registry, RegistryUsdc, RegistryTimeboost, Eip712Domain, CapabilitySpec, ResolvedCapability | types | The registry and capability shapes. |
Attestation (for the AttestedAdapter)
The optional provider attestation surface, used by the AttestedAdapter. Exports:ATTESTATION_TYPES, ATTESTOR_DOMAIN_NAME, ATTESTOR_DOMAIN_VERSION, OFFCHAIN_VERIFYING_CONTRACT, buildAttestation, attestationDigest, signAttestation, recoverAttestor, verifyAttestation, encodeAttestedParams, paramsSubject, and the Attestation / AttestorDomain types. These build, sign, and verify the EIP-712 attestation an AttestedAdapter checks at grant time.
Consumer conveniences (@caplane/consumer-agent)
The on-ramp over the surface above. Documented end to end in broker a capability.| Export | Signature | Purpose |
|---|---|---|
connect | (opts: ConnectOptions) => Promise<CaplaneClient> | Registry-bound, key-free client. Exposes buyAllocation and the generic broker. |
discover | (publicClient, adapter, params) => Promise<Quote> | Read adapter.quote(params) for { price, payToken }. |
buildOrder | (args: BuildOrderArgs) => Order | Assemble an order; nonce defaults to a random salt. |
randomNonce | () => bigint | A random 256-bit salt for order.nonce. |
submit | (relayerUrl, order, sig, chainId, opts?) => Promise<RelaySuccess> | POST the signed order; throws SubmitError(code) on rejection. |
SubmitError | class | A typed submit failure carrying the RelayErrorCode. |
encodeAllocationParams | (vaultId: bigint) => Hex | abi.encode(uint256 vaultId) for the Allocation adapter. |
decodeAllocationReceipt | (receipt: Hex) => bigint | Decode an Allocation grant receipt to the minted slot id. |
See also
- Order encoding: the contract the SDK implements.
- Relayer API: the wire the
submitpath speaks. - Broker a capability: the SDK in use.

