Skip to content

createWalletClient

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

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

Creates a Public Client with a given Transport configured for a Chain.

A Public Client is an interface to “public” Ethereum JSON-RPC API, Arkiv JSON-RPC API, and Braga JSON-RPC API methods such as retrieving block numbers, transactions, reading from smart contracts, etc through Public Actions.

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

import { createPublicClient, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createPublicClient({
chain: braga,
transport: http(),
})
const { entityKey, txHash } = await client.createEntity({
payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
attributes: [{ key: "testKey", value: "testValue" }],
expiresIn: 1000,
})
console.log("entityKey", entityKey)
console.log("txHash", txHash)
// {
// entityKey: "0x123",
// txHash: "0x123",
// }

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, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createWalletClient({
chain: braga,
transport: http(),
})
const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
console.log("entityKey", entityKey)
console.log("txHash", txHash)
// {
// entityKey: "0x123",
// txHash: "0x123",
// }

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

Extends the entity with the given key.

ExtendEntityParameters

The entity update parameters

TxParams

Optional transaction parameters

Promise<ExtendEntityReturnType>

The updated entity with transaction hash

import { createWalletClient, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createWalletClient({
chain: braga,
transport: http(),
})
const { entityKey, txHash } = await client.extendEntity("0x123", {
expiresIn: 1000,
})
console.log("entityKey", entityKey)
console.log("txHash", txHash)
// {
// entityKey: "0x123",
// txHash: "0x123",
// }

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

Mutates the entities with the given keys.

MutateEntitiesParameters

The mutation parameters (creates, updates, deletes, extensions)

TxParams

Optional transaction parameters

Promise<MutateEntitiesReturnType>

The mutation result with transaction hash

import { createWalletClient, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createWalletClient({
chain: braga,
transport: http(),
})
const { entityKey, txHash } = await client.mutateEntities({
creates: [{
payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
attriubutes: [{ key: "testKey", value: "testValue" }],
expiresIn: 1000,
}],
updates: [{
entityKey: "0x123",
payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
attributes: [{ key: "testKey", value: "testValue" }],
expiresIn: 1000,
}],
deletes: [{
entityKey: "0x321",
}],
extensions: [{
entityKey: "0x1234",
expiresIn: 1000,
}],
})
console.log("entityKey", entityKey)
console.log("txHash", txHash)
// {
// entityKey: "0x123",
// txHash: "0x123",
// }

updateEntity: (data, txParams?) => Promise<UpdateEntityReturnType>

Updates the entity with the given key.

UpdateEntityParameters

The entity update parameters

TxParams

Optional transaction parameters

Promise<UpdateEntityReturnType>

The updated entity with transaction hash

import { createWalletClient, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createWalletClient({
chain: braga,
transport: http(),
})
import { createPublicClient, http } from 'arkiv'
import { braga } from 'arkiv/chains'
const client = createPublicClient({
chain: braga,
transport: http(),
})