Skip to main content

Quick Start

To make it easy for developers to get started, we’ve deployed web3infra.dev for developers to store data forever. This quick start will describe how to use arseeding-js to store data onto the Arweave network via web3infra.dev.

Prerequiste

In order to quickly have the data uploaded, you need to have prepared in advanced the following:

  1. node.js development environment
  2. have a MetaMask/ArConnect wallet.
  3. the wallet has any one of asset that listed on everPay.

If you’re not yet ready, please check the following: everPay recharge guide

Creat project

Open terminal, Create an empty folder to store the project, and use npm init to create package.json for package management.

mkdir arseeding-demo

cd arseeding-demo

npm init

Installation

Open the arseeding-demo file via the compiler, open the terminal and install arseeding-js with the following code.

npm i arseeding-js

Upload Data

After the installation is complete, create index.js in the directory and copy the following code into index.js.

const { genNodeAPI } = require('arseeding-js')

const run = async () => {
const instance = genNodeAPI('YOUR PRIVATE KEY')
const arseedUrl = 'https://arseed.web3infra.dev'
const data = Buffer.from('........')
const payCurrencyTag = 'ethereum-usdc-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' // everpay supported all token tag (chainType-symbol-id)
const options = {
tags: [{ name: 'Content-Type', value: 'image/png' }]
}
const res = await instance.sendAndPay(arseedUrl, data, payCurrencyTag, options)
console.log('res', res)
}
run()
tip

If you prefer to import arseeding-js using the following syntax, you need to add "type": "module" to the package.json file.

import { genNodeAPI } from 'arseeding-js'

Configuration instructions:

  • Populate your MetaMask key with YOUR PRIVATE KEY.You can also use Arconnect to import your keyfile json file path into it, Make sure that the wallet corresponding to the PRIVATE KEY has assets on everPay.
  • arseedUrl is the address of the Arseeding backend service that needs to be configured. Here we use the Arseed service provided by permadao at https://arseed.web3infra.dev.
  • The data needs to be filled with the binary data you want to upload, the developer can use the file io to read the corresponding file from the local drive.
  • payCurrencyTag is the payment token tag you need to select. If your MetaMask address is held by usdc in everPay, you can get the tag of all usdc by getTokenTagByEver('usdc'), if you hold other tokens, please fill in the symbol of other tokens.View specific use getTokenTagByEver.
  • In options you can configure your Arweave Tags, Arweave Tags refer to: here.
  • The Content-Type in tags needs to be configured based on the content you upload. For example, if you upload an image in png format, configure it as image/png. For details, refer to Content-Type.

When you’re ready to configure, call await instance.sendAndPay(arseedUrl, data, payCurrencyTag, ops) Or use Arconnect (createAndSubmitItem, newEverpayByRSA, payOrder) and other methods to upload your data to the Arseeding node in web3infra.

Execute the following command in the terminal for upload files.

node index.js

When executed correctly the terminal will output:

res {
everHash: '0xf88033873d3bfc525d9333ec51b60f3f3dc03f822a9a73f66a10ebbd944b29c6',
order: {
itemId: '2bpKpp0dtfFZE82-P0lOmeI5x4m2ynatFzdjBmCWd4k',
size: 192,
bundler: 'uDA8ZblC-lyEFfsYXKewpwaX-kkNDDw8az3IW9bDL68',
currency: 'USDC',
decimals: 6,
fee: '1141',
paymentExpiredTime: 1690702235,
expectedBlock: 1210331,
tag: 'ethereum-usdc-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
}
}

Eventually this data will be packaged into the Arweave network becoming permanent and immutable.

Download Data

In the returned result you can find res.order.itemId, the above itemId is 2bpKpp0dtfFZE82-P0lOmeI5x4m2ynatFzdjBmCWd4k.

The data can be downloaded using curl at:

curl --location --request GET 'https://arseed.web3infra.dev/2bpKpp0dtfFZE82-P0lOmeI5x4m2ynatFzdjBmCWd4k'

For a more in-depth study of Arseeding and web3infra check out: