问题标签 [polkadot-js]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
99 浏览

blockchain - 无法在节点和运行时之间转换参数“tx”:解码字段 CheckMortality.0 时出错

我尝试使用 polkadot-js libray 运行一个简单的应用程序,用于在 plasm 上的 Dusty 帐户之间传输令牌。运行代码片段的源代码和 package.json 可以在这个 git repo上找到

节点版本: v12.8.2
纱线版本: 1.22.5

堆栈跟踪:

trying connection to wss://rpc.dusty.plasmnet.io/ Connected to wss://rpc.dusty.plasmnet.io/ You are connected to chain Dusty using Plasm Node v1.6.1-cf15b11-x86_64-linux-gnu - wss://rpc.dusty.plasmnet.io/ got nonce Type { negative: 0, words: [ 0 ], length: 1, red: null, registry: TypeRegistry {} } 2021-02-05 21:00:27 RPC-CORE: submitExtrinsic(extrinsic: Extrinsic): Hash:: 1002: Verification Error: Execution: Could not convert parameter tx between node and runtime: Error decoding field CheckMortality.0: RuntimeApi, Execution: Could not convert parametertx between node and runtime: Error decoding field CheckMortality.0 (node:13572) UnhandledPromiseRejectionWarning: Error: 1002: Verification Error: Execution: Could not convert parametertx between node and runtime: Error decoding field CheckMortality.0: RuntimeApi, Execution: Could not convert parametertx between node and runtime: Error decoding field CheckMortality.0 at RpcCoder._checkError (<mydir>\examples\plasm-simple-transfer\node_modules\@polkadot\api\node_modules\@polkadot\rpc-provider\coder\index.js:84:13) at RpcCoder.decodeResponse (<mydir>\examples\plasm-simple-transfer\node_modules\@polkadot\api\node_modules\@polkadot\rpc-provider\coder\index.js:47:10) at WsProvider.value (<mydir>\examples\plasm-simple-transfer\node_modules\@polkadot\api\node_modules\@polkadot\rpc-provider\ws\index.js:214:90) at W3CWebSocket.value [as onmessage] (<mydir>\examples\plasm-simple-transfer\node_modules\@polkadot\api\node_modules\@polkadot\rpc-provider\ws\index.js:194:153) at W3CWebSocket._dispatchEvent [as dispatchEvent] (<mydir>\examples\plasm-simple-transfer\node_modules\yaeti\lib\EventTarget.js:107:17) at W3CWebSocket.onMessage (<mydir>\examples\plasm-simple-transfer\node_modules\websocket\lib\W3CWebSocket.js:234:14) at WebSocketConnection.<anonymous> (<mydir>\examples\plasm-simple-transfer\node_modules\websocket\lib\W3CWebSocket.js:205:19) at WebSocketConnection.emit (events.js:315:20) at WebSocketConnection.processFrame (<mydir>\examples\plasm-simple-transfer\node_modules\websocket\lib\WebSocketConnection.js:554:26) at <mydir>\examples\plasm-simple-transfer\node_modules\websocket\lib\WebSocketConnection.js:323:40 (node:13572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:13572) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

此外,当我尝试进行清晰运行(删除 node_modules 并重新安装)时,我收到相同的消息,但字段 CheckMortality 被 CheckNonce 替换。由 plasm-types 库返回的字段可以在此文件中以 json 格式找到。

我试图通过浏览节点模板存储库来找出错误的类型,但我无法弄清楚。如何修复?

0 投票
2 回答
589 浏览

substrate - 无法在节点和运行时之间转换参数“tx”:枚举 MultiSignature 中没有这样的变体

嗨,当我尝试将余额从 Alice 转移到 Dave(或任何其他转移)时,我在 polkadot-js 中收到以下错误。

错误:balances.transferKeepAlive 1002:验证错误:执行:无法tx在节点和运行时之间转换参数:枚举 MultiSignature 中没有这样的变体:RuntimeApi,执行:无法tx在节点和运行时之间转换参数:枚举 MultiSignature 中没有这样的变体

请参考下面的屏幕截图: 屏幕截图

0 投票
0 回答
87 浏览

substrate - 如何调用底层节点元数据中声明的常量

我正在使用这个库https://github.com/centrifuge/go-substrate-rpc-client我们通过我的 gloang 代码中的这个调用获取最新的元数据api.RPC.State.GetMetadataLatest()。这将从 go-substrate-rpc-client 库返回给我连接的基板节点的元数据结果。

我能够为任何给定的调色板获取存储、调用和事件,对于以下类似,可以实现相同的效果,

  1. 存储==>key, err = types.CreateStorageKey(meta, "System", "Account", signature.TestKeyringPairAlice.PublicKey, nil)
  2. 来电==>c, err := types.NewCall(meta, "Balances.transfer", bob, types.NewUCompactFromUInt(1000))
  3. 事件==>sub, err := api.RPC.Author.SubmitAndWatchExtrinsic(ext)

但我无法找到一种方法来获取使用 go-substrate-rpc 在元数据中声明的常量。

Balances Palette 包含一个常量ExistentialDeposit,其值通过golang api 检索。

0 投票
1 回答
211 浏览

polkadot - Polkadot-JS 导入带派生的 BIP44 地址?

SafePal S1 根据他们的 Polkadot 网站使用以下派生路径:

米/44h/354h/0h

SafePal 使用 BIP39/44 助记词标准。我正在尝试将我的助记词导入 Polkadot-JS Chrome 扩展程序,但没有关于派生路径使用什么的参考。有人可以在这里帮忙吗?

0 投票
1 回答
372 浏览

docker - Polkadot websocket API 不监听新块

我使用 polkadot.js api,从 shell 运行,并期望收到多个“链位于块 #12345”消息。但我只收到其中一条消息,我不知道为什么。

我正在使用以下 docker 命令运行 Polkadot 节点:

docker run -it -p 30333:30333 -p 9944:9944 -p 80:9933 -v /mnt/polkadot:/polkadot/.local/share parity/polkadot:latest --rpc-external --rpc-cors=all --chain westend --ws-external

并且正在关注 polkadot.js api文档中的示例

如果我停止 docker 容器然后重新启动它,我会再收到 1 条消息,所以我知道连接仍然打开。似乎节点没有发出消息。

如果我查询wss://rpc.polkadot.io而不是我的节点(在端口 9944 上),我会得到预期的行为。

任何人都可以提出解决方案或调查步骤吗?

0 投票
0 回答
48 浏览

substrate - 如何在 ApiPromise 中注册一个自定义的托盘,以便我们可以用 polkadotjs 调用它?

我正在尝试执行以下操作, await api.tx.custom.function()但会引发以下错误TypeError: Cannot read property 'function' of undefined我们如何在 ApiPromise 中注册自定义托盘?

0 投票
0 回答
205 浏览

substrate - 使用 polkadot lib 的公钥/私钥加密?

我正在构建一个由 polkadot js 支持的底层区块链。在处理任务时,我需要公钥/私钥加密和解密。例如:Bob 想向 Alice 发送一封加密的电子邮件。为此,Bob 获取 Alice 的公钥并加密他给她的消息。然后,当 Alice 收到消息时,她会使用只有她自己知道的私钥来解密来自 Bob 的消息。有谁知道这是如何通过 Polkadot js 库完成的?帮助将不胜感激!

0 投票
1 回答
303 浏览

substrate - 如何在 polkadot.js 中配置枚举

以下是我的基板代码:

如何在json文件中配置枚举类型?https://polkadot.js.org/apps

这不起作用:

0 投票
1 回答
384 浏览

javascript - 使用 api.rpc.payment.queryFeeDetails 获取外部费用

我想使用api.rpc.payment.queryFeeDetailsapi 调用(https://polkadot.js.org/docs/substrate/rpc#queryfeedetailsextrinsic-bytes-at-blockhash-feedetails)来获取有关 Substrate 区块链中特定外部费用的信息。

我正在使用这段代码来做到这一点:

但我收到了这个错误:

我做错了什么?

0 投票
1 回答
194 浏览

polkadot-js - 是什么导致了这个无效的 JSON ABI 结构错误?

我正在尝试部署墨水!通过 polkadotJS 进行合约。

执行时,我收到此错误:

根据Polkadot的说法,该错误是由低于 3.0-rc1 的版本引起的。然而我的版本是墨水!3.0.0-rc3

我的阿比:

所以我的墨水!版本不是问题,还有什么原因造成的?或者我可能做错了什么?