0

在尝试 polkadotjs 库时,它会在传输过程中出错。

这是我的代码:

const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api")

;(async () => {
  const wsprovider = new WsProvider("ws://127.0.0.1:9944")
  const api = await ApiPromise.create({
    provider: wsprovider,
    types: {
      DepartmentDetails: {
        name: "Text",
        location: "Text",
        details: "Text",
        departmentid: "u128",
      },
    },
  })
  const keyring = new Keyring({ type: "sr25519" })
  const alice = keyring.addFromUri("//Alice")
  const BOB = keyring.addFromUri("//Bob")
  try {
    const txHash = await api.tx.balances.transfer(BOB, 12345).signAndSend(alice)
    console.log(`Submitted with hash ${txHash}`)
  } catch (err) {
    console.log(err)
  }
 
  process.exit()
})()

它给出错误:
错误:createType(Call):: Struct: failed on 'args':: Struct: failed on 'dest':: Decoding [object Object]: value.substr is not a function

4

0 回答 0