1

我使用 SPL 创建了一个令牌。我已经在测试网上的钱包地址中铸造了一些供应

代币地址:668JcT5AiLYNi8XVaDNntTaLWzuQ8EnbBzA9zSmKbipW(https://explorer.solana.com/address/668JcT5AiLYNi8XVaDNntTaLWzuQ8EnbBzA9zSmKbipW?cluster=testnet

收款人钱包地址:A9CCmocX2jNXMFuqqHg6uxT4sptFTTws3qXn5tTo5sy9 ( https://explorer.solana.com/address/A9CCmocX2jNXMFuqqHg6uxT4sptFTTws3qXn5tTo5sy9/tokens?cluster=testnet )

在收件人的代币持有部分,我可以看到余额为 0.026203001

同时回到我的 React 前端,我试图显示收件人地址持有的各种 SPL 代币的余额

import * as solanaWeb3 from '@solana/web3.js';
..
..

const solanaWeb3Connection = new solanaWeb3.Connection(solanaWeb3.clusterApiUrl('testnet'))

const balance = await solanaWeb3Connection.getBalance( new solanaWeb3.PublicKey(metadata.publicAddress)) //SOL balance I guess

const tokenAccounts = await solanaWeb3Connection.getTokenAccountsByOwner(new solanaWeb3.PublicKey(<recipient address>), 
    { mint : new solanaWeb3.PublicKey(<spl token address>) }, "finalized")

但我得到一个奇怪的响应,显示灯的值为 2039280(见下文)。检索 .026203001 值的正确方法是什么

{
  "context": {
    "slot": 113853707
  },
  "value": [
    {
      "account": {
        "data": {
          "type": "Buffer",
          "data": [
            '.....'
          ]
        },
        "executable": false,
        "lamports": 2039280,
        "owner": {
          "_bn": "06ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9"
        },
        "rentEpoch": 276
      },
      "pubkey": {
        "_bn": "f3b25516176b4d976c2808080643441ded068758cf33244fad11d6e388d54f55"
      }
    }
  ]
}
4

0 回答 0