Closed sbihgud closed 2 years ago
any news?
can you share your sign
and submit
instructions? (remove addresses and secrets from the code).
all addresses and secrets valid in TEST NET only
console.clear() const ripple = require('ripple-lib') const api = new ripple.RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
api.connect()
.then(async()=>{
txJSON = JSON.stringify(doPrepare())
const response = api.sign(txJSON, "ssSonmQj2xiyWNymB8UB6169mFDsX")
const txID = response.id
console.log("Identifying hash:", txID)
const txBlob = response.signedTransaction
console.log("Signed blob:", txBlob)
const earliestLedgerVersion = await doSubmit(txBlob)
console.log(earliestLedgerVersion)
api.on('ledger', ledger => {
console.log("Ledger version", ledger.ledgerVersion, "was validated.")
// if (ledger.ledgerVersion > maxLedgerVersion) {
// console.log("If the transaction hasn't succeeded by now, it's expired")
// }
})
// try {
// (async()=>{
// tx = await api.getTransaction(txID, {minLedgerVersion: earliestLedgerVersion})
// console.log("Transaction result:", tx.outcome.result)
// console.log("Balance changes:", JSON.stringify(tx.outcome.balanceChanges))
// })()
// } catch(error) {
// console.log("Couldn't get transaction outcome:", error)
// }
})
async function doPrepare() {
const preparedTx = await api.prepareTransaction({
"Account": "r38VSvqwRHesy6Dk7LBX9VBpwmNixsLT3J",
"TransactionType": "Payment",
"Amount": api.xrpToDrops("22"),//"2000000",
"Destination": "rGCRNJBkqBrYJRyn1GNjHN8YciZoUxXtyh",
// "Fee": 12,
// "Sequence": 2,
},{
// Expire this transaction if it doesn't execute within ~5 minutes:
"maxLedgerVersionOffset": 75
})
// const maxLedgerVersion = preparedTx.instructions.maxLedgerVersion
// console.log("Prepared transaction instructions:", preparedTx.txJSON)
// console.log("Transaction cost:", preparedTx.instructions.fee, "XRP")
// console.log("Transaction expires after ledger:", maxLedgerVersion)
return preparedTx.txJSON
}
async function doSubmit(txBlob) {
const latestLedgerVersion = await api.getLedgerVersion()
// const result = await
api.submit(txBlob)
.then(
// console.log
)
.catch(console.log)
// console.log(result)
// console.log("Tentative result code:", result.resultCode)
// console.log("Tentative result message:", result.resultMessage)
// Return the earliest ledger index this transaction could appear in
// as a result of this submission, which is the first one after the
// validated ledger at time of submission.
return latestLedgerVersion + 1
}
Hi, any ideas on this problem?
I'd be interested in seeing the output of those console.log
calls that are commented out in doPrepare
. Copied and pasted, not screenshotted, please.
@hamed-elahifar your doPrepare
is an async function. In your example, you are not "waiting" for it to execute. Adding await
should remove that error.
Closing this because the original issue-opener hasn't responded in over a year. If you're still having this problem, please reopen the issue.
Hello, there was an error when I was about to submit my signature to the network. My node and ripple lib versions are v12.13.1 and ^ 1.6.5, respectively. Demo and error are also below,