WalrusWriter class
Writes blobs to Walrus through an upload relay, with every cost paid by the signer: WAL for storage, SUI for gas and the relay's tip.
No publisher and no server-side key are involved. A write takes two
wallet approvals: one to register the blob (and pay), one to certify it
once the relay has stored it. The resulting Blob object belongs to the
signer, or to the recipient passed to write.
Works on Flutter web (metadata comes from walrus-wasm in a Web Worker)
and natively (from the walrus_ffi library). Chain reads use Sui's
gRPC-web API.
final writer = WalrusWriter(network: WalrusNetwork.testnet);
final result = await writer.write(
bytes,
epochs: 26,
signer: WalletTransactionSigner(
address: account.address,
execute: (tx) => wallet.signAndExecuteTransaction(tx.json),
),
onStage: (stage) => print(stage),
);
print('${result.blobId} is stored until epoch ${result.endEpoch}');
Constructors
- WalrusWriter({required WalrusNetwork network, WalrusChainReader? chain, UploadRelayClient? relay, BlobEncoder? encoder, Client? httpClient, BigInt? maxRelayTip})
-
httpClientcarries the upload to the relay; pass one that reports progress to show an upload bar.encoderdefaults to the platform's encoder (seecreateDefaultBlobEncoder).
Properties
- chain → WalrusChainReader
-
final
- encoder → BlobEncoder
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRelayTip → BigInt?
-
Maximum relay tip this caller permits, in MIST (1 SUI = 10^9 MIST).
Checked for both estimates and registration, before the wallet is asked.
Null means no SDK cap; the wallet still asks the person to approve the
payment. Set an explicit budget for automated signers.
final
- network → WalrusNetwork
-
final
- relay → UploadRelayClient
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
balances(
String address) → Future< WalrusWalletBalances> -
The SUI and WAL
addressholds. -
close(
) → void - Close the relay's HTTP client if this writer created it.
-
estimate(
{required int size, required int epochs}) → Future< WalrusWriteEstimate> -
What storing
sizebytes forepochsepochs costs right now. -
estimateFiles(
List< QuiltBlob> files, {required int epochs}) → Future<WalrusWriteEstimate> -
What storing
filesas one quilt (see writeFiles) costs right now. The quilt is laid out to measure it, so this costs about as much memory as the files themselves. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
restoreFilesFlow(
WalrusWriteCheckpoint checkpoint, {Future< void> onCheckpoint(WalrusWriteCheckpoint checkpoint)?}) → Future<WalrusWriteFilesFlow> - Restore a quilt with its original layout, files and relay nonce.
-
restoreFlow(
WalrusWriteCheckpoint checkpoint, {Future< void> onCheckpoint(WalrusWriteCheckpoint checkpoint)?}) → Future<WalrusWriteFlow> - Restore an interrupted blob write after checking its saved content.
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
Uint8List data, {required WalrusTransactionSigner signer, required int epochs, bool deletable = true, String? recipient, void onStage(WalrusWriteStage stage)?}) → Future< WalrusWriteResult> -
Store
dataforepochsepochs, paid bysigner. -
writeFiles(
List< QuiltBlob> files, {required WalrusTransactionSigner signer, required int epochs, bool deletable = true, String? recipient, void onStage(WalrusWriteStage stage)?}) → Future<WalrusWriteFilesResult> -
Store several
filestogether as one Walrus quilt: one blob, so one payment approval, one certify approval and one storage fee for the whole batch. (Every blob pays for at least about 64 MB of encoded storage, so a quilt of small files costs a fraction of separate blobs.) -
writeFilesFlow(
List< QuiltBlob> files, {required int epochs, bool deletable = true, String? recipient, Future<void> onCheckpoint(WalrusWriteCheckpoint checkpoint)?}) → WalrusWriteFilesFlow -
A step-by-step write of several
filesas one quilt (see writeFiles). -
writeFlow(
Uint8List data, {required int epochs, bool deletable = true, String? recipient, Future< void> onCheckpoint(WalrusWriteCheckpoint checkpoint)?}) → WalrusWriteFlow -
A step-by-step write of
data. Keep the flow to retry a failed step: The bytes are copied into an immutable snapshot. WalrusWriteFlow.run continues where it stopped. Known wallet rejections are retryable; unknown submission outcomes require explicit resolution before another transaction can be sent.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited