PublicArkivActions
PublicArkivActions<
transport,chain,account> =Pick<PublicActions<transport,chain,account>,"getBalance"|"getBlock"|"getBlockNumber"|"getChainId"|"getLogs"|"getTransaction"|"getTransactionCount"|"getTransactionReceipt"|"waitForTransactionReceipt"|"watchEvent"> &object
Defined in: src/clients/decorators/arkivPublic.ts:17
Type Declaration
Section titled “Type Declaration”buildQuery()
Section titled “buildQuery()”buildQuery: () =>
QueryBuilder
Returns a QueryBuilder instance for building and executing queries. The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
Returns
Section titled “Returns”A QueryBuilder instance for building and executing queries. QueryBuilder
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const query = client.buildQuery()const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()getBlockTiming()
Section titled “getBlockTiming()”getBlockTiming: () =>
Promise<{blockDuration:number;currentBlock:bigint;currentBlockTime:number; }>
Returns the current block timing.
Returns
Section titled “Returns”Promise<{ blockDuration: number; currentBlock: bigint; currentBlockTime: number; }>
The current block timing. GetBlockTimingReturnType
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const blockTiming = await client.getBlockTiming()// {// currentBlock: 10n, // block number// currentBlockTime: 1234567890, // block timestamp// blockDuration: 2, // in seconds// }getEntity()
Section titled “getEntity()”getEntity: (
key) =>Promise<Entity>
Returns the entity with the given key.
Parameters
Section titled “Parameters”Hex
The entity key (hex string)
Returns
Section titled “Returns”Promise<Entity>
The entity with the given key. Entity
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const entity = await client.getEntity("0x123")// {// key: "0x123",// value: "0x123",// }getEntityCount()
Section titled “getEntityCount()”getEntityCount: () =>
Promise<number>
Returns the number of entities in the DBChain.
Returns
Section titled “Returns”Promise<number>
The number of entities in the DBChain
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const entityCount = await client.getEntityCount()// entityCount = 0query()
Section titled “query()”query: (
query,queryOptions?) =>Promise<QueryReturnType>
Returns a QueryResult instance for fetching the results of a raw query. If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
Parameters
Section titled “Parameters”string
The raw query string
queryOptions?
Section titled “queryOptions?”The optional query options - QueryOptions
Returns
Section titled “Returns”Promise<QueryReturnType>
A QueryReturnType instance - QueryReturnType
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const queryResult = client.query('key = value && $owner = 0x123')// queryResult = { entities: [{ key: "0x123", value: "0x123" }], cursor: undefined, blockNumber: undefined }const queryResultWithOptions = client.query('key = value && $owner = 0x123', { includeData: { attributes: false, payload: true, metadata: true, }, orderBy: [{ name: "key", type: "string", desc: "asc" }], resultsPerPage: 10, cursor: undefined, atBlock: undefined,})// queryResultWithOptions = { entities: [{ key: "0x123", value: "0x123" }], cursor: "...", blockNumber: 32223n }subscribeEntityEvents()
Section titled “subscribeEntityEvents()”subscribeEntityEvents: (
{ onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended, },pollingInterval?,fromBlock?) =>Promise<() =>void>
Subscribes to entity events. Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
Parameters
Section titled “Parameters”{
onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended,\}onEntityCreated?
Section titled “onEntityCreated?”(event) => void
onEntityDeleted?
Section titled “onEntityDeleted?”(event) => void
onEntityExpired?
Section titled “onEntityExpired?”(event) => void
onEntityExpiresInExtended?
Section titled “onEntityExpiresInExtended?”(event) => void
onEntityUpdated?
Section titled “onEntityUpdated?”(event) => void
onError?
Section titled “onError?”(error) => void
pollingInterval?
Section titled “pollingInterval?”number
The polling interval in milliseconds
fromBlock?
Section titled “fromBlock?”bigint
The block number to start from
Returns
Section titled “Returns”Promise<() => void>
A function to unsubscribe from the events
Example
Section titled “Example”import { createPublicClient, http } from 'arkiv'import { braga } from 'arkiv/chains'
const client = createPublicClient({ chain: braga, transport: http(),})const unsubscribe = await client.subscribeEntityEvents({ onError: (error) => console.error("subscribeEntityEvents error", error),})unsubscribe() // unsubscribe from the eventsType Parameters
Section titled “Type Parameters”transport
Section titled “transport”transport extends Transport = Transport
chain extends Chain | undefined = Chain | undefined
account
Section titled “account”account extends Account | undefined = Account | undefined