golem-base-sdk
    Preparing search index...

    Interface GolemBaseClient

    interface GolemBaseClient {
        createEntities(
            creates: GolemBaseCreate[],
        ): Promise<{ entityKey: `0x${string}`; expirationBlock: number }[]>;
        deleteEntities(
            deletes: `0x${string}`[],
        ): Promise<{ entityKey: `0x${string}` }[]>;
        extendEntities(
            extensions: GolemBaseExtend[],
        ): Promise<
            {
                entityKey: `0x${string}`;
                newExpirationBlock: bigint;
                oldExpirationBlock: bigint;
            }[],
        >;
        getAllEntityKeys(): Promise<`0x${string}`[]>;
        getEntitiesForNumericAnnotationValue(
            key: string,
            value: number,
        ): Promise<`0x${string}`[]>;
        getEntitiesForStringAnnotationValue(
            key: string,
            value: string,
        ): 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>;
        getOwnerAddress(): Promise<`0x${string}`>;
        getRawClient(): internal.GolemBaseClient;
        getStorageValue(key: `0x${string}`): Promise<string>;
        queryEntities(
            query: string,
        ): Promise<{ entityKey: `0x${string}`; storageValue: string }[]>;
        updateEntities(
            updates: GolemBaseUpdate[],
        ): Promise<{ entityKey: `0x${string}`; expirationBlock: number }[]>;
        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: bigint;
                        oldExpirationBlock: bigint;
                    },
                ) => void;
                onUpdated: (
                    args: { entityKey: `0x${string}`; expirationBlock: number },
                ) => void;
                pollingInterval?: number;
                transport?: "http" | "websocket";
            },
        ): () => void;
    }
    Index

    Methods

    • Create one or more new entities in GolemBase

      Parameters

      • creates: GolemBaseCreate[]

        The entities to create

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

      An array of the entity keys of the entities that were created, together with the number of the block at which they will expire

    • Delete one or more new entities in GolemBase

      Parameters

      • deletes: `0x${string}`[]

        The entity keys of the entities to delete

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

      An array of the entity keys of the entities that were deleted

    • Extend the TTL of one or more new entities in GolemBase

      Parameters

      • extensions: GolemBaseExtend[]

        The entities to extend the TTL of

      Returns Promise<
          {
              entityKey: `0x${string}`;
              newExpirationBlock: bigint;
              oldExpirationBlock: bigint;
          }[],
      >

      An array of the entity keys of the entities that had their TTL extended, together with the numbers of the old and the new block at which the entities expire

    • Get the entity keys of all entities in GolemBase

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

    • Get all entities with a given numeric annotation

      Parameters

      • key: string

        The annotation key

      • value: number

        The annotation value

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

      An array of entity keys containing entities with the given annotation

    • Get all entities with a given string annotation

      Parameters

      • key: string

        The annotation key

      • value: string

        The annotation value

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

      An array of entity keys containing entities with the given annotation

    • Get the entity keys of all entities in GolemBase owned by the given address

      Parameters

      • address: `0x${string}`

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

      Array of the entity keys

    • Get all entity keys for entities that will expire at the given block number

      Parameters

      • blockNumber: bigint

        The block number

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

      An array of entities that expire at the given block

    • Get the total count of entities in GolemBase

      Returns Promise<number>

    • Get entity metadata

      Parameters

      • key: `0x${string}`

        The key of the entity to look up

      Returns Promise<EntityMetaData>

      The entity's metadata

    • Get the ethereum address of the owner of the ethereum account used by this client

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

    • Get the storage value associated with the given entity key

      Parameters

      • key: `0x${string}`

        The key of the entity to look up

      Returns Promise<string>

      The base64-encoded value stored in the entity

    • Query entities in GolemBase based on annotations

      Parameters

      • query: string

        The query to look up entities with

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

      Array of the entities that matched the query

    • Update one or more new entities in GolemBase

      Parameters

      • updates: GolemBaseUpdate[]

        The entities to update

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

      An array of the entity keys of the entities that were updated, together with the number of the block at which they will expire

    • 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: bigint;
                    oldExpirationBlock: bigint;
                },
            ) => 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: bigint;
                  oldExpirationBlock: bigint;
              },
          ) => void

          A callback that's invoked whenever entities have their TTL 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