Skip to main content

sendAndPay

Function

Upload data and pay for storage.

Example

import { genNodeAPI } from 'arseeding-js'

const run = async () => {
const instance = await genNodeAPI('YOUR PRIVATE KEY')
const arseedUrl = '<https://arseed.web3infra.dev>'
const data = Buffer.from('need upload data ...')
const tag = '<chaintype-symbol-id>' // everpay supported all token tag (chainType-symbol-id)
const options = {
tags: [
{ name: 'Content-Type', value: 'data type' },
{ name: 'aa', value: 'aaa' }
]
}
const res = await instance.sendAndPay(arseedUrl, data, tag, options)

// If you need upload orders by sequence, you can configure the needSeq parameter to true
const res = await instance.sendAndPay(arseedUrl, data, tag, options, true)

console.log(res)
}

The sendAndPay function will do both the upload and the payment, so make sure your wallet has sufficient assets on the everPay Protocol. If you are using your own Arseeding node and have No_Fee mode turned on, please use the "data only" upload method for the upload process.

FieldDescription
arseedingUrlarseedUrl 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.
dataThe data data that needs to be uploaded.
tagIf your MetaMask address holds usdc in everPay, you can obtain the token tag for tokens that require payment fees by calling getTokenTagByEver('usdc'). Please refer to getTokenTagByEver for detailed instructions on how to use it.
optionsIn ops you can configure your Arweave Tags, Arweave Tags refer to: here.
tagsContent-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.
needSeqIf you need upload orders by sequence, you can configure the needSeq parameter to true.

返回数据

{
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'
}
}