python - 为什么我不能从 py-substrate-interface 发送外部数据?

标签 python blockchain substrate polkadot

大家好,我正在通过 py-substrate-interface 提交外部信息。 ,但由于某种原因,我在遵循提到的示例 here 时不断收到错误。 我的代码如下:

    def send_funds(self, destination, amount):
        self.log.info("Sending {} DOT to {} ...".format(amount, destination.strip()))
        substrate = self.create_substrate_instance(self.node_ws_port[0])

        keypair = Keypair.create_from_mnemonic('level payment mom grape proof display cause engage erupt rain hair arm')
        print(keypair)

        call = substrate.compose_call(
            call_module='Balances',
            call_function='transfer',
            call_params={
                'dest': destination,
                'value': ceil(amount * DOT)
            }
        )

        try:
            extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
        except Exception as e:
            print(e)

        try:
            receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
            self.log.info("Extrinsic '{}' sent and included in block '{}'".format(receipt.extrinsic_hash, receipt.block_hash))
            self.log.info("{} DOT sent to address: {}".format(amount, destination))
        except SubstrateRequestException as e:
            self.log.error("Failed to send: {}".format(e))

我在这里放置了一个 try 和 except block :

        try:
            extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
        except Exception as e:
            print(e)

运行此代码块时出现以下错误:

No more bytes available (offset: 80 / length: 72)

如何解决这个问题。

最佳答案

大多数时候是RemainingScaleBytesNotEmptyException被引发,它与类型注册表相关。在 Substrate 运行时(如 Kusama、Polkadot 等)中定义了特定类型,这些类型(尚未)在元数据中公开,因此库必须包含对这些类型的原语的分解。

故障排除的一些提示:

关于python - 为什么我不能从 py-substrate-interface 发送外部数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67054979/

相关文章:

python - 价格的正则表达式不起作用

go - 在启用隐私的链代码之间传递查询

rust - 无法加载依赖 list

substrate - 基底存储中私有(private)变量的可能性

Python 计数段落

python - 为什么裸 Python 装饰器(没有@)不会产生编译器错误?

python - 使用 WN-Affect 检测字符串的情绪/情绪

rust - 如何将特征类型与基板模块中的字符串类型进行比较?

java - Web3j Transfer.sendFunds() 返回错误 "insufficient funds for gas * price + value"

rust - 如何消除同名特征之间的歧义?