Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
The web3-bzz package is a module of the web3.js library that allows interaction with the Swarm decentralized storage system. It provides functionalities to upload, download, and manage files on the Swarm network.
Upload File
This feature allows you to upload a file to the Swarm network. The code sample demonstrates how to upload a simple text file and log the resulting hash.
const Web3Bzz = require('web3-bzz');
const bzz = new Web3Bzz('http://localhost:8500');
const file = new Blob(['Hello, Swarm!'], { type: 'text/plain' });
bzz.uploadFile(file).then(hash => {
console.log('File uploaded with hash:', hash);
});
Download File
This feature allows you to download a file from the Swarm network using its hash. The code sample shows how to download a file and log its content.
const Web3Bzz = require('web3-bzz');
const bzz = new Web3Bzz('http://localhost:8500');
const hash = 'your-file-hash';
bzz.downloadFile(hash).then(file => {
console.log('File downloaded:', file);
});
Upload Directory
This feature allows you to upload a directory to the Swarm network. The code sample demonstrates how to upload a directory containing an HTML file and a CSS file.
const Web3Bzz = require('web3-bzz');
const bzz = new Web3Bzz('http://localhost:8500');
const directory = [
{ path: 'index.html', data: '<html><body>Hello, Swarm!</body></html>' },
{ path: 'style.css', data: 'body { font-family: Arial; }' }
];
bzz.uploadDirectory(directory).then(hash => {
console.log('Directory uploaded with hash:', hash);
});
The ipfs-http-client package allows interaction with the InterPlanetary File System (IPFS), a peer-to-peer hypermedia protocol. Similar to web3-bzz, it provides functionalities to upload, download, and manage files on a decentralized network. However, it is designed for IPFS rather than Swarm.
The orbit-db package is a serverless, distributed, peer-to-peer database built on IPFS. It offers similar decentralized storage capabilities but focuses on database functionalities rather than file storage. It provides a higher-level abstraction compared to web3-bzz.
The gun package is a decentralized, offline-first, graph database that provides real-time data synchronization. While it offers decentralized storage like web3-bzz, it is more focused on real-time data and graph structures rather than file storage.
This is a sub package of web3.js
This is the swarm package of web3.js for further information please read the documentation.
> npm install web3-bzz
import {Bzz} from 'web3-bzz';
new Bzz('http://swarm-gateways.net');
All the typescript typings are placed in the types folder.
FAQs
Web3 module to interact with the Swarm network.
The npm package web3-bzz receives a total of 227,967 weekly downloads. As such, web3-bzz popularity was classified as popular.
We found that web3-bzz demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.