golem-base-sdk
    Preparing search index...

    Interface GolemBaseROClient

    Read-only client interface for GolemBase providing access to query operations without the ability to modify data on the blockchain.

    Use this client when you only need to read data from GolemBase and don't require transaction capabilities.

    const roClient = createROClient(chainId, rpcUrl, wsUrl);
    const entityCount = await roClient.getEntityCount();
    const entities = await roClient.getAllEntityKeys();
    interface GolemBaseROClient {
        getAllEntityKeys(): Promise<`0x${string}`[]>;
        getEntitiesOfOwner(address: `0x${string}`): Promise<`0x${string}`[]>;
        getEntitiesToExpireAtBlock(blockNumber: bigint): Promise<`0x${string}`[]>;
        getEntityCount(): Promise<number>;
        getEntityMetaData(key: `0x${string}`): Promise<EntityMetaData>;
        getRawClient(): internal.GolemBaseROClient;
        getStorageValue(key: `0x${string}`): Promise<Uint8Array<ArrayBufferLike>>;
        queryEntities(
            query: string,
        ): Promise<{ entityKey: `0x${string}`; storageValue: Uint8Array }[]>;
        watchLogs(
            args: {
                fromBlock: bigint;
                onCreated: (
                    args: { entityKey: `0x${string}`; expirationBlock: number },
                ) => void;
                onDeleted: (args: { entityKey: `0x${string}` }) => void;
                onError?: (error: Error) => void;
                onExtended: (
                    args: {
                        entityKey: `0x${string}`;
                        newExpirationBlock: number;
                        oldExpirationBlock: number;
                    },
                ) => void;
                onUpdated: (
                    args: { entityKey: `0x${string}`; expirationBlock: number },
                ) => void;
                pollingInterval?: number;
                transport?: "http" | "websocket";
            },
        ): () => void;
    }

    Hierarchy

    Index

    Methods

    • Returns all entity keys stored in GolemBase.

      Returns Promise<`0x${string}`[]>

      A promise that resolves to an array of entity keys (Hex[]).

    • Retrieves all entity keys owned by a specific Ethereum address.

      Parameters

      • address: `0x${string}`

        The address whose owned entities should be returned.

      Returns Promise<`0x${string}`[]>

      A promise that resolves to an array of entity keys owned by the address.

    • Finds all entities that are scheduled to expire at a specific block.

      Parameters

      • blockNumber: bigint

        The block number to check against.

      Returns Promise<`0x${string}`[]>

      A promise that resolves to an array of entity keys expiring at the given block.

    • Returns the total number of entities stored in GolemBase.

      Returns Promise<number>

      A promise that resolves to the total count of entities.

    • Retrieves metadata for a given entity key.

      Parameters

      • key: `0x${string}`

        The key to retrieve metadata for.

      Returns Promise<EntityMetaData>

      An EntityMetaData object with structured information about the entity.

    • Returns the raw internal client used under the hood. The internal client which exposes low-level methods and also gives access to the raw viem.sh ethereum clients, which allows to call low-level ethereum methods directly

      This includes low-level Ethereum client access (via viem.sh). This is considered an advanced feature. Use with caution if you need to make low-level Ethereum calls directly.

      Returns internal.GolemBaseROClient

      The internal client object used by the SDK.

    • Returns the raw base64-encoded storage value associated with a given entity key.

      Parameters

      • key: `0x${string}`

        The entity key to fetch the data for.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A Uint8Array containing the base64 encoded value stored in the entity.

    • Queries entities in GolemBase using annotations or metadata filters.

      Parameters

      • query: string

        A query string in the GolemBase filter syntax.

      Returns Promise<{ entityKey: `0x${string}`; storageValue: Uint8Array }[]>

      A promise that resolves to an array of matching entity keys.

    • Install callbacks that will be invoked for every GolemBase transaction

      Parameters

      • args: {
            fromBlock: bigint;
            onCreated: (
                args: { entityKey: `0x${string}`; expirationBlock: number },
            ) => void;
            onDeleted: (args: { entityKey: `0x${string}` }) => void;
            onError?: (error: Error) => void;
            onExtended: (
                args: {
                    entityKey: `0x${string}`;
                    newExpirationBlock: number;
                    oldExpirationBlock: number;
                },
            ) => void;
            onUpdated: (
                args: { entityKey: `0x${string}`; expirationBlock: number },
            ) => void;
            pollingInterval?: number;
            transport?: "http" | "websocket";
        }
        • fromBlock: bigint

          The starting block, events trigger the callbacks starting from this block

        • onCreated: (args: { entityKey: `0x${string}`; expirationBlock: number }) => void

          A callback that's invoked whenever entities are created

        • onDeleted: (args: { entityKey: `0x${string}` }) => void

          A callback that's invoked whenever entities are deleted

        • OptionalonError?: (error: Error) => void

          A callback that's invoked whenever there is an error during the processing

        • onExtended: (
              args: {
                  entityKey: `0x${string}`;
                  newExpirationBlock: number;
                  oldExpirationBlock: number;
              },
          ) => void

          A callback that's invoked whenever entities have their BTL extended

        • onUpdated: (args: { entityKey: `0x${string}`; expirationBlock: number }) => void

          A callback that's invoked whenever entitier are updated

        • OptionalpollingInterval?: number

          In that case of HTTP transport, the polling interval in milliseconds. Defaults to the default polling interval of viem

        • Optionaltransport?: "http" | "websocket"

          The transport to use, either HTTP or WebSocket (the default)

      Returns () => void

      a callback to cancel the subscription and stop receiving notifications