Unable to send Ripple Cryptocurrency Coin - XRP to Wallet

0 votes

I am trying to use the below code to send ripple (Cryptocurrency Coin)- XRP to another address, but I am getting the below error :

"Uncaught (in promise) Error: Faucet URL is not defined or inferrable."

Included the below JS reference in HTML file,

script src="https://unpkg.com/xrpl@2.0.0/build/xrpl-latest-min.js" script type="application/javascript" src="send-xrp.js"

What am I missing???

send-xrp.js ===========

// Dependencies for Node.js. // In browsers, use a <script> tag instead. if (typeof module !== "undefined") { 
// Use var here because const/let are block-scoped to the if statement. var xrpl = require('xrpl') } // Example credentials const wallet = xrpl.Wallet.fromSeed("I ENTERED MY SECRET KEY HERE") console.log(wallet.address) // Connect ------------------------------------------------------------------- async function main() { console.log("Connecting to Testnet... I CHANGED BELOW TO PRODUCTION NETWORK") const client = new xrpl.Client('wss://xrplcluster.com') await client.connect() // Get credentials from the Testnet Faucet ----------------------------------- console.log("Getting a wallet from the Testnet faucet...") const {wallet, balance} = await client.fundWallet() 
// Prepare transaction ------------------------------------------------------- const prepared = await client.autofill({ "TransactionType": "Payment", "Account": wallet.address, "Amount": xrpl.xrpToDrops("35"), "Destination": "ENTERED MY DESTINATION KEY HERE" }) 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 = wallet.sign(prepared) console.log("Identifying hash:", signed.hash) console.log("Signed blob:", signed.tx_blob) // Submit signed blob -------------------------------------------------------- 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() } main()

Apr 7, 2022 in Blockchain by Soham
• 9,700 points

1 answer to this question.

0 votes

The "Secret Key" or privateKey is for signing which is a different animal than the seed. Also, it appears you are connecting to the Mainnet, not the Testnet try:

const wallet = xrpl.Wallet.fromSeed(seed) const client = new xrpl.Client(`wss://s.altnet.rippletest.net:51233`)

answered Apr 11, 2022 by Rahul
• 9,670 points

Related Questions In Blockchain

+1 vote
1 answer

Unable to send payment using API. Please help.

Firstly, check your passwords, your API code and your wallet ...READ MORE

answered Apr 3, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer
+1 vote
1 answer

Is there a way to send funds from a specific bitcoin address in a wallet?

I'll answer my own question, It was unbelievably ...READ MORE

answered Sep 3, 2018 in Blockchain by Perry
• 17,100 points
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
0 votes
1 answer

how Localbitcoins and other bitcoin wallet able to send/receive without network fee

Organizations that offer online wallets aren't obligated ...READ MORE

answered Mar 31, 2022 in Blockchain by Rahul
• 9,670 points
0 votes
1 answer

How to add liquidity for an inflationary cryptocurrency

This is the process of the functioning ...READ MORE

answered Mar 24, 2022 in Blockchain by Rahul
• 9,670 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP