Skip to main content

createAndSubmitItem

Function

Upload data and pay for storage.

Example

import { EthereumSigner, ArweaveSigner } from 'arseeding-js'
import { createAndSubmitItem } from 'arseeding-js/cjs/submitOrder'
import { readFileSync } from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { Config } from 'arseeding-js/cjs/types'

const run = async () => {
// use ecc signer
const privateKey = '<your ecc private key>'
const signer = new EthereumSigner(privateKey)

// or

// or use rsa signer
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const wallet = JSON.parse(
readFileSync(path.join(__dirname, '<your arweave keyfile>.json')).toString()
)
const signer = new ArweaveSigner(wallet)

const data = Buffer.from('<need upload data, such as a picture>')
const options = {
tags: [
{ name: 'key01', value: 'val01' },
{ name: 'Content-Type', value: 'data type' } // you should set the data type tag
]
}
const arseedingUrl = 'https://arseed.web3infra.dev'
const tag = '<chaintype-symbol-id>' // everpay supported all token tag (chainType-symbol-id)
const config: Config = {
signer: signer,
path: '',
arseedUrl: arseedingUrl,
tag: tag
}
const order = await createAndSubmitItem(data, options, config)
console.log(order)
}

createAndSubmitItem: will upload data. If you use the Arseeding service provided by web3infra, you need to pay for the response order, otherwise the data will clear after 60 minutes. Once the payment is made, web3infra will 100% guarantee the upload of this data to the Arweave network.

If you turn on No_Fee mode using your own node, no additional payment work is required.

FieldDescription
signersigner instance created by using the Ethereum private key or Arweave Key File.
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.
configIf you want the order to be sequentially wound you can configure the needSeq parameter in the config to be true, the default is false.

Return Data

{
itemId: 'b9qf5fCDY0dB-nF3ixPqL6pHVPFLiDvNYBm_MOi4yq4',
size: 203,
bundler: 'uDA8ZblC-lyEFfsYXKewpwaX-kkNDDw8az3IW9bDL68',
currency: 'USDC',
decimals: 6,
fee: '1247',
paymentExpiredTime: 1691058571,
expectedBlock: 1213090,
tag: 'ethereum-usdc-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
}