Skip to main content

Overview

The createDeposit method uploads files to decentralized storage and creates a payment record on the Solana blockchain.

Estimate Cost First

Before uploading, get a cost estimate:

Response

Always estimate costs before uploading to avoid transaction failures due to insufficient balance.

Create Deposit

Upload files and create a deposit on-chain:

Parameters

File | File[]
required
Single file or array of files to upload
number
required
Storage duration in days (minimum: 7)
PublicKey
required
Solana wallet public key for payment
Function
required
Async function to sign the transaction
string
Optional email for expiration reminders (sent 7 days before)

Response

boolean
Whether the upload succeeded
string
Content identifier for the uploaded file(s)
string
Solana transaction signature
string
IPFS gateway URL to access the file
string
Human-readable success message
string
Error message (only if success is false)

Complete Example

Single vs Multiple Files

Single File

Multiple Files

Multiple files are packaged as a directory on IPFS. Pinata returns a single root CID for the directory. See Content Identifiers for details.

Error Handling

Common errors and solutions:
Error: Transaction fails due to insufficient SOLSolution: Check balance before uploading using estimateStorageCost
Error: User cancels the wallet signature requestSolution: Catch the error and show appropriate message
Error: Failed to upload to IPFS or confirm transactionSolution: Implement retry logic or ask user to try again
Error: Browser runs out of memory processing large filesSolution: Limit file size or implement chunked uploads

Transaction Flow

What happens when you call createDeposit:
1

Pin to IPFS

Server receives your files and pins them to IPFS. The server returns the authoritative CID for your content.
2

Build Transaction

A Solana transaction is built using that CID along with the payment amount and duration
3

Sign Transaction

Your signTransaction callback is invoked
4

Submit to Network

Transaction is submitted to Solana blockchain
5

Wait for Confirmation

SDK waits for transaction confirmation
6

Confirm Upload

Server marks the upload active in the database, linking the transaction signature to the pinned CID
7

Return Result

CID, transaction signature, and gateway URL are returned to your app

Best Practices

Always Estimate First

Check costs before uploading to avoid failed transactions

Show Progress

Use loading states and toasts for better UX

Handle Errors Gracefully

Provide clear error messages to users

Verify Balance

Ensure sufficient SOL before initiating upload

Upload History

View past uploads

Storage Renewal

Extend storage duration

CID Computation

How CIDs are computed

Storage Payments

Payment mechanics