这是我的xrpl函数。它来自xrpl教程,应该可以工作。但是它返回tefBAD_AUTH错误。
我正在写xrpl dapps,它有点web3。
const xrpl = require("xrpl");
const poolSecret = "sEd**********************";
const poolWallet = xrpl.Wallet.fromSeed(poolSecret)
async function main(addr) {
console.log("Connecting to Testnet...")
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
await client.connect()
// Prepare transaction -------------------------------------------------------
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": addr,
"Amount": xrpl.xrpToDrops("1"),
"Destination": poolWallet.address
})
const max_ledger = prepared.LastLedgerSequence
console.log("Prepared transaction instructions:", prepared)
console.log("Transaction cost:", xrpl.dropsToXrp(prepared.Fee), "XRP")
console.log("Transaction expires after ledger:", max_ledger)
// Sign prepared instructions ------------------------------------------------
const signed = poolWallet.sign(prepared)
console.log("Identifying hash:", signed.hash)
console.log("Signed blob:", signed.tx_blob)
// Submit signed blob --------------------------------------------------------
try {
const tx = await client.submitAndWait(signed.tx_blob)
// Wait for validation -------------------------------------------------------
// submitAndWait() handles this automatically, but it can take 4-7s.
// Check transaction results -------------------------------------------------
console.log("Transaction result:", tx.result.meta.TransactionResult)
console.log("Balance changes:", JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2))
// End of main()
client.disconnect()
} catch (e) {
console.log(e)
}
}
main("rf*******************************");
但是它返回这个错误。这是完整的日志
Connecting to Testnet...
Prepared transaction instructions: {
TransactionType: 'Payment',
Account: 'rf*******************************',
Amount: '1000000',
Destination: 'ra*******************************',
Flags: 0,
Sequence: 36726053,
Fee: '12',
LastLedgerSequence: 36750914
}
Transaction cost: 0.000012 XRP
Transaction expires after ledger: 36750914
Identifying hash: 79D3030E5C7F53B04C7FD9C4BC0D7D65BEEEAFA2787BB72C87CA8F6B553BA32B
Signed blob: 12000022000000002402306525201B0230C6426140000000000F424068400000000000000C7321EDA47EA21FCF73BF28D57230BCECB075B2A710C0A15E1D49DA2CA30AE672D667067440B5B294834715D70A90DEFECCD66C7AF839FEE250ED078249C2D85315F66D562856025B2812F1285065D4BABC638DC6488F604C4381D9EFF91E6C8795E09E810581144A0CD16399904DE78F0B132D8CC7105091BB911A83143FF554299C3A982782E1201E87E73B0284D73F79
**XrplError: The latest ledger sequence 36750915 is greater than the transaction's LastLedgerSequence (36750914).**
Preliminary result: tefBAD_AUTH
at /home/barnyjake/work/xrp/node_modules/xrpl/dist/npm/sugar/submit.js:65:19
at Generator.next (<anonymous>)
at fulfilled (/home/barnyjake/work/xrp/node_modules/xrpl/dist/npm/sugar/submit.js:5:58) {
data: undefined
}
我用的地址在钱包里工作得很好。
我正在使用ubuntu 20.04,我尝试了这个节点v14 &v16 .
可以尝试两件事:
-
From"bad auth"消息更改您正在尝试连接的客户端,尝试"wss://testnet.xrpl-labs.com/"它显式地支持CORS (https://xrpl.org/public-servers.html)
-
从"最新的分类帐序列"…消息短答:尝试更改(或显式设置)您的Flags值为2147483648。
长答:对于NFTokenCreateOffer"我也有同样的错误。事务类型。当我设置"旗标"时,它为我纠正了。属性设置为正确的值。
从你的输出来看,你的Flags被设置为0,我认为这与支付交易类型的任何真正的标志都不匹配。
我有一个自己的系统,我已经编写了使用"支付"的代码。事务,其中我将Flags设置为"2147483648";(tfulllycanonicalsig - https://xrpl.org/transaction-common-fields.html#flags-field),我知道这是不赞成的,但它适用于我。
在自动填充被调用之前,我的支付交易是这样的:
const transaction = {
TransactionType: 'Payment',
Account: walletDto.address,
Amount: amount,
Destination: sendDetails.sendToAddress,
Flags: 2147483648,
};
我希望这对你有帮助