golem-base-sdk
    Preparing search index...

    Interface GolemBaseClient

    interface GolemBaseClient {
        createEntities(
            creates: GolemBaseCreate[],
            args?: {
                gas?: bigint;
                maxFeePerGas?: bigint;
                maxPriorityFeePerGas?: bigint;
                txHashCallback?: (txHash: `0x${string}`) => void;
            },
        ): Promise<CreateEntityReceipt[]>;
        deleteEntities(
            deletes: `0x${string}`[],
            args?: {
                gas?: bigint;
                maxFeePerGas?: bigint;
                maxPriorityFeePerGas?: bigint;
                txHashCallback?: (txHash: `0x${string}`) => void;
            },
        ): Promise<DeleteEntityReceipt[]>;
        extendEntities(
            extensions: GolemBaseExtend[],
            args?: {
                gas?: bigint;
                maxFeePerGas?: bigint;
                maxPriorityFeePerGas?: bigint;
                txHashCallback?: (txHash: `0x${string}`) => void;
            },
        ): Promise<ExtendEntityReceipt[]>;
        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>;
        getOwnerAddress(): Promise<`0x${string}`>;
        getRawClient(): internal.GolemBaseClient;
        getStorageValue(key: `0x${string}`): Promise<Uint8Array<ArrayBufferLike>>;
        queryEntities(
            query: string,
        ): Promise<{ entityKey: `0x${string}`; storageValue: Uint8Array }[]>;
        sendTransaction(
            creates?: GolemBaseCreate[],
            updates?: GolemBaseUpdate[],
            deletes?: `0x${string}`[],
            extensions?: GolemBaseExtend[],
            args?: {
                gas?: bigint;
                maxFeePerGas?: bigint;
                maxPriorityFeePerGas?: bigint;
                txHashCallback?: (txHash: `0x${string}`) => void;
            },
        ): Promise<
            {
                createEntitiesReceipts: CreateEntityReceipt[];
                deleteEntitiesReceipts: DeleteEntityReceipt[];
                extendEntitiesReceipts: ExtendEntityReceipt[];
                updateEntitiesReceipts: UpdateEntityReceipt[];
            },
        >;
        updateEntities(
            updates: GolemBaseUpdate[],
            args?: {
                gas?: bigint;
                maxFeePerGas?: bigint;
                maxPriorityFeePerGas?: bigint;
                txHashCallback?: (txHash: `0x${string}`) => void;
            },
        ): Promise<UpdateEntityReceipt[]>;
        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

    • Create one or more new entities in GolemBase

      Parameters

      • creates: GolemBaseCreate[]

        The entities to create

      • Optionalargs: {
            gas?: bigint;
            maxFeePerGas?: bigint;
            maxPriorityFeePerGas?: bigint;
            txHashCallback?: (txHash: `0x${string}`) => void;
        }

        Optional parameters, see sendTransaction

      Returns Promise<CreateEntityReceipt[]>

      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

      • Optionalargs: {
            gas?: bigint;
            maxFeePerGas?: bigint;
            maxPriorityFeePerGas?: bigint;
            txHashCallback?: (txHash: `0x${string}`) => void;
        }

        Optional parameters, see sendTransaction

      Returns Promise<DeleteEntityReceipt[]>

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

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

      Parameters

      • extensions: GolemBaseExtend[]

        The entities to extend the BTL of

      • Optionalargs: {
            gas?: bigint;
            maxFeePerGas?: bigint;
            maxPriorityFeePerGas?: bigint;
            txHashCallback?: (txHash: `0x${string}`) => void;
        }

        Optional parameters, see sendTransaction

      Returns Promise<ExtendEntityReceipt[]>

      An array of the entity keys of the entities that had their BTL 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 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<Uint8Array<ArrayBufferLike>>

      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: Uint8Array }[]>

      Array of the entities that matched the query

    • Parameters

      • Optionalcreates: GolemBaseCreate[]

        The list of create operations to include in this transaction

      • Optionalupdates: GolemBaseUpdate[]

        The list of update operations to include in this transaction

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

        The list of delete operations to include in this transaction

      • Optionalextensions: GolemBaseExtend[]

        The list of extend operations to include in this transaction

      • Optionalargs: {
            gas?: bigint;
            maxFeePerGas?: bigint;
            maxPriorityFeePerGas?: bigint;
            txHashCallback?: (txHash: `0x${string}`) => void;
        }
        • Optionalgas?: bigint
        • OptionalmaxFeePerGas?: bigint

          Sets the max fee per gas manually

        • OptionalmaxPriorityFeePerGas?: bigint

          Sets the max priority fee per gas manually

        • OptionaltxHashCallback?: (txHash: `0x${string}`) => void

          Callback to invoke with the transaction hash of the transaction

      Returns Promise<
          {
              createEntitiesReceipts: CreateEntityReceipt[];
              deleteEntitiesReceipts: DeleteEntityReceipt[];
              extendEntitiesReceipts: ExtendEntityReceipt[];
              updateEntitiesReceipts: UpdateEntityReceipt[];
          },
      >

    • Update one or more new entities in GolemBase

      Parameters

      • updates: GolemBaseUpdate[]

        The entities to update

      • Optionalargs: {
            gas?: bigint;
            maxFeePerGas?: bigint;
            maxPriorityFeePerGas?: bigint;
            txHashCallback?: (txHash: `0x${string}`) => void;
        }

        Optional parameters, see sendTransaction

      Returns Promise<UpdateEntityReceipt[]>

      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: 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