执行委托人示例时,出现“ContractTrapped”错误

问题描述

建立委托人合同...

  1. Git 克隆“https://github.com/paritytech/ink.git”。
  2. 移动“示例/委托人”。
  3. 使用“build-all.sh”构建合约。

部署和执行

  1. 使用 Contract Pallet 执行 Substrate-Node-Template。
  2. 访问 polkadot/Substrate 门户 (https://www.nuget.org/packages/WindowsAzure.Storage/)
  3. 转到合同页面(https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/accounts)
  4. 部署“delegator/target/ink/accumulator/accumulator.contract”。
  5. 通过将“累加器”地址指定为参数来部署“delegator/target/ink/adder/adder.contract”。
  6. 执行加法器合约的“inc”。
  7. 我收到错误消息“system.ExtrinsicFailed contract.ContractTrapped”

我该如何解决这个问题?

解决方法

在尝试从链下工作人员测试环境中调用智能合约时,我遇到了类似的问题。

DispatchError::Module { index: 0,error: 17,message: Some("ContractTrapped") }

在这里找到:primitives/sandbox/with_std.rs:275 错误在:

Trap(Trap { kind: Unreachable })

但仍然不知道为什么会发生以及如何修复它。