Reputation: 469
Build Delegator Contracts...
Deploy & Execute
How can I solve this problem?
Upvotes: 1
Views: 564
Reputation: 469
I could execute delegator example at the latest commit of the github. I could not recognize this cause of the error,but now the error is solved.
Upvotes: 0
Reputation: 2484
More recently, ContractTrapped
can be returned if your contract constructor is not payable
. You currently need to decorate with payable
as follows:
impl Dapp {
/// Creates a new payable contract
#[ink(constructor, payable)]
pub fn new(initial_supply: Balance) -> Self {
...
}
Upvotes: 2
Reputation: 2484
You can run into ContractTrapped
if your substrate node and polkadot-js versions are not compatible.
Try updating the following in your packages.json
"@polkadot/api": "<add latest version>",
"@polkadot/api-contract": "<add latest version>",
"@polkadot/types": "<add latest version>",
"@polkadot/util": "<add latest version>"
Latest version can be found in the tags on GitHub.
Upvotes: 0
Reputation: 555
It's probably late but I will leave this here for future strugglers. If you run into a TrapCode
, take a closer look at it and what type of TrapCode
it is. Here is more on TrapCodes
: https://docs.wasmtime.dev/api/wasmtime/enum.TrapCode.html
I was getting a TrapCode
for example. My substrate node was telling me that it was a TrapCode::UnreachableCodeReached
which was because my smart contract did not implement some functions, which other contract were trying to call from the first smart contract, hence unreachable code.
Upvotes: 0
Reputation: 61
I have a similar issue when trying to call Smart Contract from within offchain worker test environment.
DispatchError::Module { index: 0, error: 17, message: Some("ContractTrapped") }
Found here: primitives/sandbox/with_std.rs:275 The error in:
Trap(Trap { kind: Unreachable })
But still have no idea why it happened and how to fix it.
Upvotes: 0