mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
'use strict'
|
|
if (typeof module !== "undefined") {
|
|
// Use var here because const/let are block-scoped to the if statement.
|
|
var xrpl = require('xrpl')
|
|
}
|
|
|
|
const main = async () => {
|
|
try {
|
|
// Connect -------------------------------------------------------------------
|
|
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
|
|
await client.connect();
|
|
|
|
// Get credentials from the Testnet Faucet ------------------------------------
|
|
console.log("Requesting an address from the Testnet faucet...");
|
|
const { wallet } = await client.fundWallet();
|
|
console.log("Wallet: ", wallet.address);
|
|
|
|
const escrowCancelTransaction = {
|
|
"Account": wallet.address,
|
|
"TransactionType": "EscrowCancel",
|
|
"Owner": wallet.address,
|
|
"OfferSequence": 34821001, // Sequence number
|
|
};
|
|
|
|
xrpl.validate(escrowCancelTransaction);
|
|
|
|
// Sign and submit the transaction --------------------------------------------
|
|
console.log('Signing and submitting the transaction:', JSON.stringify(escrowCancelTransaction, null, "\t"));
|
|
const response = await client.submitAndWait(escrowCancelTransaction, { wallet });
|
|
console.log(`Finished submitting! ${JSON.stringify(response.result, null, "\t")}`);
|
|
|
|
await client.disconnect();
|
|
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
main()
|