Skip to content

Braga has been retired. The next public testnet is coming in September 2026. Read the announcement →

createWalletClient

createWalletClient<transport, chain, accountOrAddress, rpcSchema>(parameters): object

Defined in: src/clients/createWalletClient.ts:50

Creates a Wallet Client with a given Transport configured for a Chain and an account.

A Wallet Client signs and sends transactions, so it carries an account and exposes everything that mutates state — createEntity, patchEntity, deleteEntity, extendEntity, changeOwnership and mutateEntities — on top of the read actions a Public Client has.

transport extends Transport

chain extends Chain | undefined = undefined

accountOrAddress extends `0x${string}` | Account | undefined = undefined

rpcSchema extends RpcSchema | undefined = ArkivRpcSchema

Configuration object for the wallet client (chain, transport, account, etc.)

A Arkiv Wallet Client. WalletArkivClient

changeOwnership: (data, txParams?) => Promise<ChangeOwnershipReturnType>

Changes the ownership of the entity with the given address.

ChangeOwnershipParameters

The ownership change parameters

TxParams

Optional transaction parameters

Promise<ChangeOwnershipReturnType>

The entity with updated ownership and transaction hash

createEntity: (data, txParams?) => Promise<CreateEntityReturnType>

Creates a new entity.

CreateEntityParameters

The entity creation parameters

TxParams

Optional transaction parameters

Promise<CreateEntityReturnType>

The created entity with transaction hash

If the expiry exceeds a protocol bound or would leave the entity dead on arrival.

If an attribute value does not fit the type it names.

If a name violates the attribute-name grammar.

import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
import { i32 } from "@arkiv-network/sdk/attr"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
})
const { entityKey, txHash, expiresAt } = await client.createEntity({
payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
contentType: "application/json",
attributes: { testKey: "testValue", level: i32(3) },
expires: ExpirationTime.fromDays(30),
})

deleteEntity: (data, txParams?) => Promise<DeleteEntityReturnType>

Deletes the entity with the given key.

DeleteEntityParameters

The entity deletion parameters

TxParams

Optional transaction parameters

Promise<DeleteEntityReturnType>

The deleted entity with transaction hash

import { createWalletClient } from "@arkiv-network/sdk"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
})
// entityKey is the bytes32 key returned by createEntity.
const { txHash } = await client.deleteEntity({ entityKey })

extendEntity: (data, txParams?) => Promise<ExtendEntityReturnType>

Sets a new expiry on the entity with the given key.

The new lifetime is resolved the same way a create’s is: a duration counts from now rather than adding to what the entity has left, and atBlock / atDate pin an absolute deadline. The engine rejects an extension that would not move the expiry later.

ExtendEntityParameters

The entity key and its new lifetime

TxParams

Optional transaction parameters

Promise<ExtendEntityReturnType>

The entity key, transaction hash, and the block it is now expected to expire at

If the expiry is malformed, exceeds a protocol bound, or would leave the entity dead on arrival.

import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
})
const { txHash, expiresAt } = await client.extendEntity({
entityKey,
expires: ExpirationTime.fromDays(30),
})

mutateEntities: (data, txParams?) => Promise<MutateEntitiesReturnType>

Mutates the entities with the given keys.

Every operation lands in one transaction, so the whole batch applies or none of it does. At least one operation is required.

MutateEntitiesParameters

The mutation parameters (creates, patches, deletes, extensions, ownershipChanges)

TxParams

Optional transaction parameters

Promise<MutateEntitiesReturnType>

The mutation result with transaction hash

If an expiry exceeds a protocol bound or would leave the entity dead on arrival.

If an attribute value does not fit the type it names.

import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
})
const { txHash, createdEntities } = await client.mutateEntities({
creates: [{
payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
contentType: "application/json",
attributes: { testKey: "testValue" },
expires: ExpirationTime.fromDays(30),
}],
patches: [{ entityKey: keyToRevise, set: { status: "archived" }, unset: ["draft"] }],
deletes: [{ entityKey: staleKey }],
extensions: [{
entityKey: keyToKeepAlive,
expires: ExpirationTime.atBlock(1_200_000n),
}],
ownershipChanges: [{ entityKey: keyToHandOver, newOwner }],
})

patchEntity: (data, txParams?) => Promise<PatchEntityReturnType>

Applies a patch to the entity with the given key: sets some fields, unsets others, and leaves everything it does not name alone.

PatchEntityParameters

The entity key and the mutations to apply

TxParams

Optional transaction parameters

Promise<PatchEntityReturnType>

The entity key and the transaction hash

If the patch has nothing to apply.

If a name appears in both set and unset.

If an attribute value does not fit the type it names.

If a name violates the attribute-name grammar.

import { createWalletClient, jsonToPayload } from "@arkiv-network/sdk"
import { i32 } from "@arkiv-network/sdk/attr"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
})
// Publish the entity: one attribute changes, one goes away, the payload is replaced.
const { txHash } = await client.patchEntity({
entityKey,
set: { status: "published", revision: i32(2) },
unset: ["draft"],
payload: jsonToPayload({ title: "Hello" }),
})
import { createWalletClient } from "@arkiv-network/sdk"
import { cheesecake } from "@arkiv-network/sdk/chains"
import { http } from "viem"
import { privateKeyToAccount } from "viem/accounts"
const client = createWalletClient({
chain: cheesecake,
transport: http(),
account: privateKeyToAccount("0x..."),
})