payOrder
Function
Payments are made for uploaded data orders. This feature provides the ability to pay on behalf of a service provider for the storage of data that has been uploaded by a specified user.
Example
- Node
- Web
import {
newEverpayByEcc,
newEverpayByRSA,
payOrder
} from 'arseeding-js/cjs/payOrder'
import { readFileSync } from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const run = async () => {
// use ecc wallet
const eccPrivate = '<your ecc private key>'
const pay = newEverpayByEcc(eccPrivate)
// or
// use rsa wallet
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const arJWK = JSON.parse(
readFileSync(path.join(__dirname, '<your arweave keyfile>.json')).toString()
)
const arAddress = '<your arweave wallet address>'
const pay = newEverpayByRSA(arJWK, arAddress)
// pay
const everHash = await payOrder(pay, order)
console.log(everHash)
}
import { ethers } from 'ethers'
import Everpay, { ChainType } from 'everpay'
const run = async () => {
// ethereum
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const pay = new Everpay({
account: window.ethereum.selectedAddress,
chainType: 'ethereum' as ChainType,
ethConnectedSigner: signer
})
// or
// arweave
const arAddress = await window.arweaveWallet.getActiveAddress()
const pay = new Everpay({
account: arAddress,
chainType: 'arweave' as ChainType,
arJWK: 'use_wallet'
})
// pay
const everHash = await payOrder(pay, order)
console.log(everHash)
}
info
- Please enable the official environment when you make a payment, otherwise you will not be able to upload the data.
- See everpay-js for details
Parameters
Field | Description |
---|---|
eccPrivate | ecc private key. |
arJWK | arweave wallet key file. |
arAddress | arweave wallet address. |
pay | everpay Example. |
order | The data structure when paying for an order. You can use the data structure returned by the createAndSubmitItem function to pay for the order, or use getOrders to get the order data structure if it is missing. |
everhash | When an order is successfully paid, a unique transaction identifier is returned and the transaction can be viewed via the everscan browser. |
Return example
'0xb2800fc8451b6588eb9b12b03e1d1e640fa95722b020c366c4b6dffb4dad20eb'