Skip to main content

Protocol writes

Version: V2
View Markdown

A protocol write changes on-chain state through a signed transaction. Building atom bytes or an action envelope can happen locally; reading a quote needs contract state; submission requires an authorized signer. A prepared request is not a transaction, a transaction hash is not a successful receipt, and a receipt does not prove a Core node has indexed the change.

Builds on: Deterministic IDs, Vaults, Representation profiles, Classifications.

Implemented by: sdk, protocol, periphery, deployments, cli.

How it works​

OperationRuntime boundary
Primitive builder, calldata encoder, client-free envelopeLocal computation; envelope inputs include caller-supplied read context
SDK quote, readiness, or preparation actionMay perform RPC reads; no submission merely because a plan is returned
Protocol write wrapper or feeProxyExecutePlanCan simulate and submit using wallet clients
Receipt parsingConfirms success or failure and filters expected contract events
Core queryReads that node's projected state, which may lag chain confirmation

A quote is a snapshot, not a reservation. Before signing, review the chain, deployment, calldata, value, receiver, required signer, minimum output, and ordered steps. Recheck stale state and deployment capabilities. Contract artifacts describe an interface, not a guarantee that every deployment implements it.

FeeProxy plans can route creation and deposits and require different signers for approvals. feeProxyExecutePlan submits and waits for receipts; a later failure can leave earlier steps completed. Record those receipts and reread state before resuming. A refund helper can return null when nothing is claimable.

Example​

This helper builds an ordinary descriptive atom and asks the SDK for a create-and-seed plan. Calling it makes contract reads; it does not submit. Its caller supplies a configured MultiVault, receiver, name, and amount in base units.

import { buildThing } from '@0xintuition/primitives';
import { multivaultCreateAndSeedTerm } from '@0xintuition/sdk/actions';
import type { WriteConfig } from '@0xintuition/protocol';
import { stringToHex, type Address } from 'viem';

export async function prepareNamedAtom(
config: WriteConfig,
receiver: Address,
name: string,
assetsIn: bigint,
) {
const result = buildThing({ name });
if (!result.success) throw new Error(result.errors.join('; '));
return multivaultCreateAndSeedTerm(config, {
receiver,
atomsToCreate: [
{
termId: result.value.id,
data: stringToHex(result.value.data),
assetsIn,
},
],
seedDeposits: [],
});
}

The caller must handle an existing atom and current creation costs. The same name and serialized data produce the same ID; deriving it does not reserve it. This ordinary creation plan does not register companion URIs. Use multiVaultCreateAtomsWithUris or a URI-aware FeeProxy preparation path when those entries must be registered, after reading live URI limits.

Common mistakes​

  • Assuming a helper's name proves it submits: multivaultCreateAndSeedTerm returns a plan.
  • Calling a write wrapper while intending only an offline preview.
  • Treating a transaction hash as a receipt or a receipt as indexed visibility.
  • Assuming a hook reset cancels a pending wallet request or transaction.
  • Treating an off-chain Core API insert as on-chain registration.

Next​

Build action plans and envelopes for review. After confirmation, Indexing and querying explains how the write becomes visible to readers who query a Core node. Its default source stack requires explicit indexing configuration before it ingests chain events.

Sources: Action-plan ownership, MultiVault actions, FeeProxy execution.

Applies to V2 · @0xintuition/sdk 4.1.0 · @0xintuition/protocol 4.1.0 · @0xintuition/periphery 0.1.1 · @0xintuition/deployments 0.1.1 · @0xintuition/cli 0.1.1