The console.warn() static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.
complete - true when all requested copies were stored and committed on-chain. This is the primary field to check.
requestedCopies - the number of copies that were requested (default: 2)
pieceCid - content address of your data, used for downloads
size - size of the uploaded data in bytes
copies - array of successful copies, each with providerId, dataSetId, pieceId, role ('primary' or 'secondary'), retrievalUrl, and isNewDataSet
failedAttempts - providers that were tried but did not produce a copy. The SDK retries failed secondaries with alternate providers, so a non-empty array often just means a provider was swapped out. These are diagnostic, check complete for the actual outcome.
Piece batching is enabled by default. Compatible uploads that run concurrently can share an on-chain transaction when they use the same provider and data set. Each provider maintains its own batch.
The SDK automatically splits compatible concurrent uploads according to the encoded Filecoin message-size budget. Legacy data sets additionally have an 80-piece safety cap. Start uploads together without manually grouping them or waiting between groups. See Larger, Cheaper Storage Batches for details.
For browser File objects, start the uploads together to give them an opportunity to join the same batch:
Sequential uploads cannot share a batch because each call waits for its own on-chain confirmation before the next call starts:
for (const fileof files) {
await synapse.storage.upload(file.stream())
}
By default, the SDK submits a batch after a zero-delay window once its uploads and pulls finish parking. You can instead hold compatible pieces until the next piece would exceed a piece-count cap or encoded message-size budget, or until you explicitly flush them:
flush() waits for accepted uploads and pulls to finish parking, then submits their pending batch windows. It does not report whether every upload was submitted or confirmed successfully. Inspect the settled results for rejections and check complete on fulfilled upload results. Start uploads before flushing; awaiting an upload first in limiter mode can leave it waiting indefinitely.
Compatible uploads can report the same transaction hash in their callbacks. Batched secondary pulls sign their per-piece authorization separately from the eventual commit batch, so interactive wallets can prompt again at commit time. To reuse one signature for pull and commit, disable batching or use the split operations with the same presigned extraData.
Set pieceBatching: false when creating Synapse to disable batching. Use the split operations when you need manual control over provider selection, signing, or each store, pull, and commit phase.
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length)
The default is 2 copies. The first copy is stored on an endorsed provider (high trust, curated), and secondary copies are stored with approved providers, which pull the data from the primary via SP-to-SP transfer.
The console.warn() static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.
upload() is designed around partial success over atomicity: it commits whatever succeeded rather than throwing away successful work. This means the return value is the primary interface for understanding what happened.
If upload() returns (no throw), at least one copy is committed on-chain. But the result may contain fewer copies than requested. Every copy in copies[] represents a committed on-chain data set that the user is now paying for.
// Check overall success: complete === true means all requested copies succeeded
if (!
const result:UploadResult
result.
UploadResult.complete: boolean
complete) {
var console:Console
console.
Console.warn(...data: any[]): void
The console.warn() static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length}/${
const result:UploadResult
result.
UploadResult.requestedCopies: number
requestedCopies} copies succeeded`)
for (const
const attempt:FailedAttempt
attemptof
const result:UploadResult
result.
UploadResult.failedAttempts: FailedAttempt[]
failedAttempts) {
var console:Console
console.
Console.warn(...data: any[]): void
The console.warn() static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.
For auto-selected providers (no explicit providerIds or dataSetIds), the SDK automatically retries failed secondaries with alternate providers up to 5 times. If you explicitly specify providers, the SDK respects your choice and does not retry.
| +-- SP-to-SP: secondary provider fetches from primary
+-- Upload: bytes sent to one provider (no on-chain state yet)
store: Upload bytes to a single SP. Returns { pieceCid, size }. The piece is “parked” on the SP but not yet on-chain and subject to garbage collection if not committed.
pull: SP-to-SP transfer. The destination SP fetches the piece from a source SP. No client bandwidth used.
commit: Submit an on-chain transaction to add the piece to a data set. Creates the data set and payment rail if needed.
The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
extraData, // pre-signed auth (optional, reused for commit)
PullOptions.signal?: AbortSignal |undefined
signal:
const abortController:AbortController
abortController.
AbortController.signal: AbortSignal
The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
The console.error() static method outputs a message to the console at the "error" log level. The message is only displayed to the user if the console is configured to display error output. In most cases, the log level is configured within the console UI. The message may be formatted as an error, with red colors and call stack information.
The from parameter accepts either a URL string (base service URL) or a function that returns a piece URL for a given PieceCID.
Pre-signing: presignForCommit() creates an EIP-712 signature that can be reused for both pull() and commit(). This avoids prompting the wallet twice. Pass the same extraData to both calls.
The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
extraData, // pre-signed auth from presignForCommit() (optional)
CommitOptions.signal?: AbortSignal |undefined
signal:
const abortController:AbortController
abortController.
AbortController.signal: AbortSignal
The signal read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
pieceIds - assigned piece IDs (one per input piece)
dataSetId - data set ID (may be newly created)
isNewDataSet - whether a new data set was created
Cancellation: aborting signal after onSubmitted only stops waiting for confirmation. The transaction can still land on chain. If the commit was creating a data set, the context does not learn the new data set ID, so calling commit() on it again creates another data set.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
map(
cid: PieceCID
cid=> ({
pieceCid: PieceCID
pieceCid:
cid: PieceCID
cid })),
CommitOptions.extraData?:`0x${string}`|undefined
extraData })
:
var Promise:PromiseConstructor
Represents the completion of an asynchronous operation
Each phase’s errors are independent. Failures don’t cascade, and you can retry at any level:
Phase
Failure
Data state
Recovery
store
Upload/network error
No data on SP
Retry store() with same or different context
pull
SP-to-SP transfer failed
Data on primary only
Retry pull(), try different secondary, or skip
commit
On-chain transaction failed
Data on SP but not on-chain
Retry commit() (no re-upload needed)
The key advantage of split operations: if commit fails, data is already stored on the SP. You can retry commit() without re-uploading the data. With the high-level upload(), a CommitError would require re-uploading.