
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
arweave-storage-sdk
Advanced tools
The Arweave Storage SDK is a comprehensive toolkit designed to easily store any type of data permanently, facilitating seamless file and folder management on the Arweave blockchain. It leverages Arweave's decentralized permanent storage capabilities and ArFS specification to offer a robust solution for managing drives, folders, and files in a secure and immutable manner. With built-in encryption support, Arweave Storage SDK allows you to store files privately ensuring only authorized parties can access the content.
For seamless data storage and retrieval on Arweave, use the Arweave Storage SDK
.
The SDK is structured around several key services and models that produce Arweave compatible transactions:
Drives – Create, list, and manage Arweave Storage SDK’s drives.
Folders – Organize files in a hierarchical folder system.
Files – Create, download, and manage file data.
Query – Get uploaded file links, search for files using tags.
The library makes use of modern JavaScript/TypeScript features that require at least Node 18.
Install the package with:
npm install arweave-storage-sdk
# or
yarn add arweave-storage-sdk
Below is a quick example of how to initialize the Arweave Storage SDK,create a drive, a folder, and a file, or quickly upload a file. For more detailed use-cases, refer to the Examples section.
To use the SDK, initialize StorageApi with a configuration object. This will create a new Arweave Storage SDK client. You may also specify the application name (appName
) and optional configurations.
const { Configuration, StorageApi, Token, Network } = require('arweave-storage-sdk');
const config = new Configuration({
appName: '<Name of your App>'
privateKey: '<ENV to private key or use_web_wallet>',
network: Network.BASE_MAINNET,
token: Token.USDC
})
const storageClient = new StorageApi(config);
await storageApiInstance.ready
Once you have the storage client initialized and before you go ahead to upload any files, its really important to create a secured session by authenticating yourself. This allows you to track or query your uploads, receipts. It is easy and can be done in one line.
//Login
await storageApiInstance.api.login()
And that's it. You’re ready to make authenticated requests with the service.
Assuming you have a valid session post login, the next step is to query for file upload prices. This is an optional step, in-case you are interested in setting up uploads conditionally or to check your wallet for enough balance before your upload. Based on your selected token and network, estimates will be provided to you in the same token and also in USD.
export interface GetEstimatesResponse {
size: number
usd: number
usdc: {
amount: string
amountInSubUnits: string
}
payAddress: string
}
const size = file.size // 200000 bytes
const estimates = await storageClient.getEstimates(size) // size of type number
console.log(estimates)
{
"data": {
"size": 200000,
"usd": 0.008599242237052303,
"usdc": {
"amount": "0.0086",
"amountInSubUnits": "8600"
},
"payAddress": "<USDC ADDRESS OF THE SERVICE>"
}
}
Upload a file (or buffer) quickly using the quickUpload method.
The quickUpload
method simplifies the process of uploading a file to Arweave. It automatically handles the creation of the transaction, including setting metadata such as content type, visibility, and tags. The receipt returned includes the unique ID, to query and confirm the file upload.
const file = <web File object, file path, buffer or stream>const receipt = await storageClient.quickUpload(file, {
name: file.name || "test.txt",
dataContentType: 'text/plain', // content type of the file
visibility: '<public|private>',
tags: [{name: "Collection-Type", value: "ART"}], size: file.size // size in bytes of type number
});
console.log('File has been uploaded. receipt:', receipt.id);
Create a new drive to manage your files on Arweave.
Drives act as containers for your files and folders. The additional parameters such as visibility and tags help you categorize and control access to your content. This context is useful if you’re new to managing storage on decentralized platforms.
const drive = await storageClient.drive.create('My Drive', {
visibility: 'public',
tags: [{name: "Collection-Type", value: "ART"}]
});
console.log('Drive created with ID:', drive.id);
Organize your files by creating folders within a drive.
Folders help you structure your files within a drive. In this example, you can see how to specify the parent drive and (optionally) a parent folder to build a hierarchical file system.
const folder = await storageClient.folder.create('My Folder', {
driveId: '<driveId>',
parentFolderId: '<parentFolderId>',
visibility: 'public',
tags: [{name: "Collection-Type", value: "ART"}]
});
console.log('Folder created with ID:', folder.id);
Store a file on Arweave by creating a file transaction.
This snippet creates a file by converting a string into a buffer and then sending it as a transaction to Arweave. The parameters include metadata like file name, size, and content type.
const fileData = Buffer.from('Hello, Arweave!');
const file = await storageClient.file.create({
name: 'My File',
size: fileData.length,
dataContentType: 'text/plain',
driveId: '<driveId>',
parentFolderId: '<parentFolderId>',
file: fileData,
visibility: 'public',
tags: [{name: "Collection-Type", value: "ART"}]
});
console.log('File uploaded; transaction ID:', file.txId);
Note: The visibility
field can be set to public
or private
.
Arweave Storage SDK’s WalletService is designed to help you interact with your stored files and manage your funds. Whether you need to fetch a list of files or check your wallet balance, this service simplifies those tasks. Here’s what you can do with this WalletService:
Initialize the Arweave Storage SDK object with various configuration options. The appName
is recommended as it helps in organizing and searching your transactions on Arweave. The privateKey
can either be your account’s key or a flag to use a browser wallet. Other parameters like network
, token
, and gateway
let you tailor the SDK to your specific environment.
const { Configuration, Network, Token} = require('arweave-storage-sdk');
const config = new Configuration({
appName: 'My cool project'
privateKey: process.env.PRIVATE_KEY,
network: Network.BASE_MAINNET,
token: Token.USDC
})
Option | Optional | Description |
---|---|---|
appName | true | App name to be used in Arweave transactions. Recommended to use since it makes searching all your app files easier. |
privateKey | false | Private key of your account. JWK in case of Arweave. if 'use_web_wallet' is used, sdk will rely on browser wallets. |
network | true | Network of your payment token. Eg: 'SOL_MAINNET'. Simply use the Network object provided by the sdk to see supported networks. Defaults to Arweave. |
token | true | Token to use for payments. Eg: 'USDT'. Use the Token object provided by the sdk to see all supported tokens. Defaults to AR. |
Encryption: For private drives or file storage, use the built-in Crypto utilities to manage encryption.
API Calls: The SDK uses the ArFSApi internally to interact with the Arweave network. You can override or customize gateway endpoints if needed.
Terms of Service and Privacy Policy: The link to the Terms of Service and Privacy Policy for the Arweave Data Storage SDK Tos and Privacy Policy
FAQs
ArFS based File System for web/backend
We found that arweave-storage-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.