Arweave
Dive into the specifics of connecting and using Arweave with web3stash
Initialization
To use Arweave you have to pass "ARWEAVE" as the service name. No other name will work!
const arweaveService = Web3Stash("ARWEAVE",{arweavePrivateKey:""},{Arweave APIconfig options})
Configuration
To use Arweave in web3stash, you need one thing:
arweavePrivateKey - PrivateKey to be used to sign transactions
There are some other important config options you might like to pass like host, port, protocol, etc. Those need to be passed in configOptions, the third Parameter.
Note: Use these names only while passing keys in object i.e, {arweavePrivateKey:"",}
Optional Config Options
You can pass config options that are available with Arweave service- You can check Arweave docs to check what config options are there that you can pass while initializing arweave
{
host?: string;
protocol?: string;
port?: string | number;
timeout?: number;
logging?: boolean;
logger?: Function;
network?: string;
}
Default values are set for
host= arweave.net
port=443
protocol=https
others as per arweave default values
Methods Available
The following methods are available for this service, More will be added soon
Uploading JSON data
arweaveService.uploadJson({name:"example", url:"abc.com"}, {arweaveOptions}).then().catch()
Uploading Image
arweaveService.uploadImage("./image.png", {arwweaveOptions}).then().catch()
Uploading Video
arweaveService.uploadVideo("./video.mp4", {arweaveOptions}).then().catch()
Uploading File
arweaveService.uploadFile("./data.txt", {arweaveOptions}).then().catch()
Uploading Images from Stream
arweaveService.uploadImageFromStream(readableStream, 1024, "png", {arweaveOptions}).then().catch()
Uploading Video from Stream
arweaveService.uploadVideoFromStream(readableStream, 1024, "mp4", {arweaveOptions}).then().catch()
Uploading File from Stream
arweaveService.uploadFileFromStream(readableStream, 1024, "txt", {arweaveOptions}).then().catch()
Output
All the functions return id (cid) and metadata (data returned by the service on upload)
{id:"dewfnlpweurmwknrwiojhgcbxczz", metadata:{}}
Last updated