Documentation

    Class WalrusClient

    Index

    Constructors

    Properties

    readBlob: (
        __namedParameters: ReadBlobOptions,
    ) => Promise<Uint8Array<ArrayBufferLike>> = ...

    Read a blob from the storage nodes

    Methods

    • Certify a blob in a transaction

      Parameters

      Returns Promise<(tx: Transaction) => void>

      tx.add(await client.certifyBlob({ blobId, blobObjectId, confirmations }));
      
    • Create a transaction that certifies a blob

      Parameters

      Returns Promise<Transaction>

      const tx = await client.certifyBlobTransaction({ blobId, blobObjectId, confirmations });
      
    • Create a transaction that creates a storage object

      Parameters

      Returns Promise<Transaction>

      const tx = await client.createStorageTransaction({ size: 1000, epochs: 3, owner: signer.toSuiAddress() });
      
    • Create a transaction that deletes a blob

      Parameters

      Returns Promise<Transaction>

      const tx = await client.deleteBlobTransaction({ blobObjectId, owner });
      
    • Encode a blob into slivers for each node

      Parameters

      • blob: Uint8Array

      Returns Promise<
          {
              blobId: string;
              metadata: {
                  V1: {
                      encoding_type: | "RedStuff"
                      | "RS2"
                      | { RedStuff: null
                      | boolean
                      | object }
                      | { RS2: null | boolean | object };
                      hashes: Iterable<
                          {
                              primary_hash: EnumInputShape<
                                  {
                                      Digest: Iterable<number, any, any>;
                                      Empty: null | boolean | object;
                                  },
                              >;
                              secondary_hash: EnumInputShape<
                                  {
                                      Digest: Iterable<number, any, any>;
                                      Empty: null | boolean | object;
                                  },
                              >;
                          },
                          any,
                          any,
                      > & { length: number };
                      unencoded_length: string | number | bigint;
                  };
              };
              rootHash: Uint8Array<ArrayBufferLike>;
              sliversByNode: SliversForNode[];
          },
      >

      const { blobId, metadata, sliversByNode, rootHash } = await client.encodeBlob(blob);
      
    • Execute a transaction that certifies a blob

      Parameters

      Returns Promise<{ digest: string }>

      const { digest } = await client.executeCertifyBlobTransaction({ blobId, blobObjectId, confirmations, signer });
      
    • Execute a transaction that creates a storage object

      Parameters

      Returns Promise<
          {
              digest: string;
              storage: {
                  end_epoch: number;
                  id: { id: string };
                  start_epoch: number;
                  storage_size: string;
              };
          },
      >

      const { digest, storage } = await client.executeCreateStorageTransaction({ size: 1000, epochs: 3, signer });
      
    • Execute a transaction that deletes a blob

      Parameters

      Returns Promise<{ digest: string }>

      const { digest } = await client.executeDeleteBlobTransaction({ blobObjectId, signer });
      
    • Execute a transaction that extends a blob

      Parameters

      Returns Promise<{ digest: string }>

      const { digest } = await client.executeExtendBlobTransaction({ blobObjectId, signer });
      
    • Execute a transaction that registers a blob

      Parameters

      Returns Promise<
          {
              blob: {
                  blob_id: string;
                  certified_epoch: null
                  | number;
                  deletable: boolean;
                  encoding_type: number;
                  id: { id: string };
                  registered_epoch: number;
                  size: string;
                  storage: {
                      end_epoch: number;
                      id: { id: string };
                      start_epoch: number;
                      storage_size: string;
                  };
              };
              digest: string;
          },
      >

      const { digest, blob } = await client.executeRegisterBlobTransaction({ size: 1000, epochs: 3, signer });
      
    • Execute a transaction that writes attributes to a blob

      If attributes already exists, their previous values will be overwritten If an attribute is set to null, it will be removed from the blob

      Parameters

      Returns Promise<{ digest: string }>

      const { digest } = await client.executeWriteBlobAttributesTransaction({ blobObjectId, signer });
      
    • Extend a blob in a transaction

      Parameters

      Returns Promise<(_tx: Transaction) => void>

      const tx = await client.extendBlobTransaction({ blobObjectId, epochs });
      
    • Create a transaction that extends a blob

      Parameters

      Returns Promise<Transaction>

      const tx = await client.extendBlobTransaction({ blobObjectId, epochs });
      
    • Parameters

      Returns Promise<
          {
              blob_id: string;
              metadata: {
                  $kind: "V1";
                  V1: {
                      encoding_type: EnumOutputShapeWithKeys<
                          { RedStuff: true; RS2: true },
                          "RedStuff" | "RS2",
                      >;
                      hashes: {
                          primary_hash: EnumOutputShapeWithKeys<
                              { Digest: Uint8Array<ArrayBufferLike>; Empty: true },
                              "Empty" | "Digest",
                          >;
                          secondary_hash: EnumOutputShapeWithKeys<
                              { Digest: Uint8Array<ArrayBufferLike>; Empty: true },
                              "Empty" | "Digest",
                          >;
                      }[];
                      unencoded_length: string;
                  };
              };
          },
      >

    • The Move type for a Blob object

      Returns string | Promise<string>

    • Parameters

      Returns Promise<{ index: number; symbols: { data: number[]; symbol_size: number } }[]>

    • Get a storage confirmation from a storage node

      Parameters

      Returns Promise<StorageConfirmation>

      const confirmation = await client.getStorageConfirmationFromNode({ nodeIndex, blobId, deletable, objectId });
      
    • Gets the blob status from multiple storage nodes and returns the latest status that can be verified.

      Parameters

      Returns Promise<BlobStatus>

    • Parameters

      • __namedParameters: { blobObjectId: string }

      Returns Promise<null | Record<string, string>>

    • Create a transaction that registers a blob

      Parameters

      Returns Promise<Transaction>

      const tx = await client.registerBlobTransaction({ size: 1000, epochs: 3, blobId, rootHash, deletable: true });
      
    • Reset cached data in the client

      Returns void

      client.reset();
      
    • The cached staking pool object for the walrus package

      Returns Promise<
          {
              id: { id: string };
              new_package_id: null | string;
              package_id: string;
              version: string;
          },
      >

    • The staking state for the current version of walrus contract

      Returns Promise<
          {
              active_set: { id: { id: string } };
              committee: { pos0: { contents: { key: string; value: number[] }[] } };
              epoch: number;
              epoch_duration: string;
              epoch_state: EnumOutputShapeWithKeys<
                  {
                      EpochChangeDone: string;
                      EpochChangeSync: number;
                      NextParamsSelected: string;
                  },
                  "EpochChangeSync"
                  | "EpochChangeDone"
                  | "NextParamsSelected",
              >;
              first_epoch_start: string;
              n_shards: number;
              next_committee:
                  | null
                  | { pos0: { contents: { key: string; value: number[] }[] } };
              next_epoch_params:
                  | null
                  | {
                      storage_price_per_unit_size: string;
                      total_capacity_size: string;
                      write_price_per_unit_size: string;
                  };
              next_epoch_public_keys: { id: { id: string } };
              pools: { id: { id: string }; size: string };
              previous_committee: {
                  pos0: { contents: { key: string; value: number[] }[] };
              };
          },
      >

    • Calculate the cost of storing a blob for a given a size and number of epochs.

      Parameters

      • size: number
      • epochs: number

      Returns Promise<{ storageCost: bigint; totalCost: bigint; writeCost: bigint }>

    • The cached system object for the walrus package

      Returns Promise<
          {
              id: { id: string };
              new_package_id: null | string;
              package_id: string;
              version: string;
          },
      >

    • The system state for the current version of walrus contract

      Returns Promise<
          {
              committee: {
                  epoch: number;
                  members: {
                      node_id: string;
                      public_key: { bytes: number[] };
                      weight: number;
                  }[];
                  n_shards: number;
                  total_aggregated_key: { bytes: number[] };
              };
              deny_list_sizes: { id: { id: string } };
              event_blob_certification_state: {
                  aggregate_weight_per_blob: {
                      contents: {
                          key: { blob_id: string; ending_checkpoint_sequence_number: string };
                          value: number;
                      }[];
                  };
                  latest_certified_blob: | null
                  | { blob_id: string; ending_checkpoint_sequence_number: string };
              };
              future_accounting: {
                  current_index: number;
                  length: number;
                  ring_buffer: {
                      epoch: number;
                      rewards_to_distribute: { value: string };
                      used_capacity: string;
                  }[];
              };
              storage_price_per_unit_size: string;
              total_capacity_size: string;
              used_capacity_size: string;
              write_price_per_unit_size: string;
          },
      >

    • Write a blob to all storage nodes

      Parameters

      Returns Promise<
          {
              blobId: string;
              blobObject: {
                  blob_id: string;
                  certified_epoch: null
                  | number;
                  deletable: boolean;
                  encoding_type: number;
                  id: { id: string };
                  registered_epoch: number;
                  size: string;
                  storage: {
                      end_epoch: number;
                      id: { id: string };
                      start_epoch: number;
                      storage_size: string;
                  };
              };
          },
      >

      const { blobId, blobObject } = await client.writeBlob({ blob, deletable, epochs, signer });
      
    • Write attributes to a blob

      If attributes already exists, their previous values will be overwritten If an attribute is set to null, it will be removed from the blob

      Parameters

      Returns Promise<(tx: Transaction) => void>

      tx.add(await client.writeBlobAttributes({ blobObjectId, attributes: { key: 'value', keyToRemove: null } }));
      
    • Create a transaction that writes attributes to a blob

      If attributes already exists, their previous values will be overwritten If an attribute is set to null, it will be removed from the blob

      Parameters

      Returns Promise<Transaction>

      const tx = await client.writeBlobAttributesTransaction({ blobObjectId, attributes: { key: 'value', keyToRemove: null } });
      
    • Write encoded blob to a storage node

      Parameters

      Returns Promise<StorageConfirmation>

      const res = await client.writeEncodedBlobToNode({ nodeIndex, blobId, metadata, slivers });
      
    • Write a blob to all storage nodes

      Parameters

      Returns Promise<(null | StorageConfirmation)[]>

      await client.writeEncodedBlobToNodes({ blob, deletable, epochs, signer });
      
    • Write metadata to a storage node

      Parameters

      Returns Promise<StoreBlobMetadataResponse>

      const res = await client.writeMetadataToNode({ nodeIndex, blobId, metadata });
      
    • Write a sliver to a storage node

      Parameters

      Returns Promise<StoreSliverResponse>

      const res = await client.writeSliver({ blobId, sliverPairIndex, sliverType, sliver });
      
    • Write slivers to a storage node

      Parameters

      Returns Promise<void>

      await client.writeSliversToNode({ blobId, slivers, signal });
      
    MMNEPVFCICPMFPCPTTAAATR