首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将Ripple (加密币- XRP)发送到Wallet

无法将Ripple (加密币- XRP)发送到Wallet
EN

Stack Overflow用户
提问于 2021-11-15 17:39:23
回答 1查看 154关注 0票数 0

我尝试使用以下代码将ripple (加密币)- XRP发送到另一个地址,但收到以下错误:

“未捕获(在promise中)错误:水龙头URL未定义或无法推断。”

在HTML文件中包含了下面的JS参考,

script src="https://unpkg.com/xrpl@2.0.0/build/xrpl-latest-min.js“script type=”应用程序/javascript“src=”发送-xrp.js“

我错过了什么?

发送-xrp.js ===========

代码语言:javascript
复制
    // 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()
EN

回答 1

Stack Overflow用户

发布于 2021-11-26 03:43:56

seed不同的是,“密钥”或privateKey是用于签名的。此外,您似乎正在连接到Mainnet,而不是Testnet try:

代码语言:javascript
复制
const wallet = xrpl.Wallet.fromSeed(seed)
const client = new xrpl.Client(`wss://s.altnet.rippletest.net:51233`)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69978582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档