transfer
功能
根据 Everpay 实例创建时,传递的 account
, ethConnectedSigner
, arJWK
参数,在转账时进行以下步骤:
- 内部构建 EverpayTxWithoutSig。
- 调用对应(插件)钱包/webauthn签名功能,生成
sig
,组装 EverpayTx。 - 将信息发送给 everPay 后端服务器,进行签名验证。
- 后端服务器验证通过,更新用户资产余额。并将该笔 everPay 交易记录存储在 arweave 区块链上。
开发者可浏览 DOCS - 系统概览 - 交易 章节获取更多信息。
信息
任意 everPay 账户均支持将任意其在 everPay 上的资产转账给其他 everPay 账户,无论要转账给的 everPay 账户是 ethereum 还是 arweave 账户模型。例如:
- arweave 账户模型的
5NPqYBdIsIpJzPeYixuz7BEH_W7BEk_mb8HxBD3OHXo
everPay 账户,可向 ethereum 账户模型的0x26361130d5d6E798E9319114643AF8c868412859
everPay 账户,转账 AR、ETH、USDT。 - 反之亦然。
参数
everpay.transfer(transferParams: TransferParams):SendEverpayTxResult
- 参数
- 类型
返回
// Note: This type does not have an export
interface PostEverpayTxResult {
status: string
}
export interface SendEverpayTxResult extends PostEverpayTxResult {
everpayTx: EverpayTx
everHash: string
}
示例
ethereum 账户给其他账户转账
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const everpay = new Everpay({
account: window.ethereum.selectedAddress,
chainType: 'ethereum',
ethConnectedSigner: signer
})
everpay.transfer({
tag: 'ethereum-usdt-0x923fcb255da521037385457fb549a51f78ef0af4',
amount: '5.26'
to: '5NPqYBdIsIpJzPeYixuz7BEH_W7BEk_mb8HxBD3OHXo',
data: { hello: 'world', this: 'is everpay' }
}).then(console.log)
/* 示例返回
{
status: 'ok',
everpayTx: {
tokenSymbol: 'usdt',
action: 'transfer',
from: '0x26361130d5d6E798E9319114643AF8c868412859',
to: '5NPqYBdIsIpJzPeYixuz7BEH_W7BEk_mb8HxBD3OHXo',
amount: '5260000',
fee: '0',
feeRecipient: '0x6451eB7f668de69Fb4C943Db72bCF2A73DeeC6B1',
nonce: '1625987254171',
tokenID: '0xd85476c906b5301e8e9eb58d174a6f96b9dfc5ee',
chainType: 'ethereum',
chainID: '42',
data: '{"hello":"world","this":"is everpay"}',
version: 'v1',
sig: '0x3ee66c303fe59b8e1f84e638cb7cca8bbb0e5b0ca63f784021e877be13c176d35d831e120a20eb8c72741fcc40c6a35a566d3ed34f6274d4c26160f38c14eec11b'
},
everHash: '0x0b7be08f6b96c2f1c7a810c72af2cc46632e4a7f0f9e36ccb10840864fedd470'
}
*/
arweave 账户给其他账户转账
const arAddress = await window.arweaveWallet.getActiveAddress()
const everpay = new Everpay({
account: arAddress,
chainType: 'arweave',
arJWK: 'use_wallet',
})
everpay.transfer({
tag: 'arweave,ethereum-ar-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,0x83ea4a2fe3ead9a7b204ab2d56cb0b81d71489c8',
amount: '0.0000000001',
to: '0x26361130d5d6E798E9319114643AF8c868412859'
}).then(console.log)
/* 示例返回
{
status: 'ok',
everpayTx: {
tokenSymbol: 'ar',
action: 'transfer',
from: '5NPqYBdIsIpJzPeYixuz7BEH_W7BEk_mb8HxBD3OHXo',
to: '0x26361130d5d6E798E9319114643AF8c868412859',
amount: '100',
fee: '0',
feeRecipient: '0x6451eB7f668de69Fb4C943Db72bCF2A73DeeC6B1',
nonce: '1629277056512',
tokenID: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,0xcc9141efa8c20c7df0778748255b1487957811be',
chainType: 'arweave,ethereum',
chainID: '0,42',
data: '',
version: 'v1',
sig: 'aiXZo1IINdFWNKnq_4SJDq93qWuIzXfaUlIoo8RnXCGVvaM39a7royP7A0bmiVbcDhGAnsyN44UnEiQx1ilUcXkMXyUNoz3w7MEy2XVLmR4nXPljMwXNhRi3WqsyCfk_bMCGnoibYj0CHFCnJU00Ik2L6dor8NlbcwoP5h6E24yrgOGVbMKxCQwL2EC2PSVNkHle0rfHePYuPYCwze0rCdle5G1IitbbJRKaPz7dKx5qjb6F8jV80ivMOHToU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