Get "Contract.ContractTrapped" erro when call new "xxx" contract from inside an depolyed contract in substrate of Shibuya testnet, bellow is my detailed operation:

1、Here are two related Contracts compiled by solang compiler scheduled to run in subsrate wasm of Shiybuya testnet 2、Contract B can be created by a specific interface of Contract A via new ContractB 3、Call the said interface shall be failed end up with 'Contract.ContractTrapped' error

I'm not sure if the error is caused by solang or the substarte runtime in Shibuya network, so could anyone konw that?

Bellow is what i done:

================Compile with solang=====================

#Solang version v0.1.10-84-g233920a1

#compiling command

docker run --rm -it -v $(pwd):/sources Package solang · GitHub -v -o /sources --target substrate /sources/test.sol


pragma solidity >=0.6.0;

contract Base{ constructor() payable{} }

contract Test{

constructor() payable{}

function createNew() public  {
        new Base();



exec createNew via PolkadotUI(https://cloudflare-ipfs.com/ipns/dotapps.io/?rpc=wss%3A%2F%2Frpc.shibuya.astar.network#/accounts) shall raise “Contract.ContractTrapped”


3 Answers 3


ContractTrapped typically occurs when there is an error in your contract. I suspect that in your case this might be because of the cross-contract calls.

What would really help is if you can post some minimal code example that reproduces your error.

Are you sure the contract you want to call has been deployed and that it's address is correct?

  • I used bellow steps: 1、 Deploy Test contract using Test.contract abi into Shibuya network via Polkadot/Substarte Portal as you mentioned above. 2、exec “createNew” of Test contract via Polkadot ui failed with “Contract.ContractTrapped” error. I’m pretty sure the error is caused by the expression “new Base()”, so i want to to know why this case will happen since it works normal in EVM-model. I’m not sure if it’s related to Shibuya substrate-runtime (mybe not support create new contract in an existed one ) or the solang compiler itself (has some issues to compile solidity into wasm-bytecode)
    – James Luo
    May 21, 2022 at 5:51
  • stackoverflow.com/help/minimal-reproducible-example would be best
    – Nuke
    May 21, 2022 at 15:02
  • In general, answers should not include followup questions, ideally these are sorted in comments on the OP before substrate.stackexchange.com/help/how-to-ask // substrate.stackexchange.com/help/how-to-answer FYI :
    – Nuke
    May 21, 2022 at 15:03

Unfortunately, right now, any runtime errors are not surfaced will just result in ContractTrapped. This makes debugging very hard.'

Having said that, new Base() instantiates a new contract.

  • The code for contract Base will need to be uploaded else it will fail.
  • The transaction needs enough value to be sent for creating a new contract.
  • Since value is not specified, the minimum deposit will be given as the initial balance for the contract. The actual value can be set with e.g. new Base{value: 10e6}().

I have exactly the same error ContractTrapped having code like below:

pragma solidity 0.8.0;

contract Base{
    string state; //added a state var
    constructor() payable {}

    function sum(uint256 a, uint256 b) public pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);
        return c;

contract Test{
    Base base;
    function createNew() payable public  {
        base = new Base();

Any idea how to solve it? Or even any tips how to debug runtime?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.