有人能帮助跟踪elrond网络上价值转移的事务状态吗?
const testTransaction = new Transaction({
value: Balance.egld(1),
data: new TransactionPayload('Test Transfer'),
receiver: new Address(ownerWallet),
nonce: sender.nonce,
gasPrice: new GasPrice(10000000000,
gasLimit: new GasLimit(1000000)
});
await refreshAccount();
const { sessionId } = await sendTransactions({
transactions: testTransaction,
transactionsDisplayInfo: {
processingMessage: 'Processing transaction',
errorMessage: 'An error has occured during Transaction',
successMessage: 'Transaction successful'
}
});我目前正在使用sendTransactions发送事务。
发布于 2022-02-09 10:25:58
根据erdjs文档的文档,您可以使用TransactionWatcher.
下面是文档中的一个简化示例:
await tx1.send(provider);
let watcher = new TransactionWatcher(tx1.hash, provider);
await watcher.awaitStatus(status => status.isExecuted());erdjs文档:https://elrondnetwork.github.io/elrond-sdk-docs/erdjs/latest/
发布于 2022-10-02 04:55:36
我没有设法使用观察者,所以每隔0.5秒就从sessionStorage读取数据,直到状态“成功”为止
let transactions = JSON.parse(sessionStorage.getItem('persist:dapp-core-transactions'));
const txData = JSON.parse(sessionStorage.getItem('txData'));
let txSessionId = sessionStorage.getItem('txSessionId');
let signedTransactions = JSON.parse(transactions.signedTransactions);
let currentTransaction = signedTransactions[txSessionId];
// if (currentTransaction != null) {
// let transactionOnNetwork = await watcher.awaitCompleted();
// console.log(transactionOnNetwork);
// }
// console.log(signedTransactions);
if (currentTransaction && txSessionId) {
console.log(currentTransaction);
if (currentTransaction.status === 'sent') {
const checkTransaction = setInterval(async () => {
console.log("Checking transaction status");
let transactions = JSON.parse(sessionStorage.getItem('persist:dapp-core-transactions'));
let signedTransactions = JSON.parse(transactions.signedTransactions);
let currentTransaction = signedTransactions[txSessionId];
if (currentTransaction.status === 'success' && txData) {
clearInterval(checkTransaction);
await doSomething(currentTransaction);
sessionStorage.removeItem('txSessionId');
}
}, 500);
}
}https://stackoverflow.com/questions/71023682
复制相似问题