# Contract.ContractTrapped

**URL:** <https://forum.astar.network/t/contract-contracttrapped/3352>\
**Category:** General\
**Created:** [May 18, 2022, 8:31am UTC](https://forum.astar.network/t/contract-contracttrapped/3352 "2022-05-18T08:31:49Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forum.astar.network/u/james)\
**Post date:** [May 25, 2022, 11:35am UTC](https://forum.astar.network/t/contract-contracttrapped/3352/21 "2022-05-25T11:35:08Z")

</div>

Oh, sorry to bother you. I have test the code and give the question. Since i want to make the Test contract as a factory to new Base contract from inside of it’s “createNew” interface. But i found if one of interface has “public” or “external” access modifier, the call “createNew” will be failed in WASM.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/c/cec8f378ce993ac586fe036fdcd3b3e0542eb79c.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/4/46254f6626bbd5682f1d0c6733a3b0035201e95a.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/1/1a84ccaff1ad623f2c3e2a207d88af16fe8d14d4.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/9/9cfdc2ee3c9e28122f31faa0751c659cf39cb827.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/5/5c2b334bc75cd3f4ae56a7be243a76d3070eadfe.png)

Your code with “internal” access modifier could run success, but no interface is exposed which could be called by Test.

Thx a lot anyway. If that make u trouble plz just ingore.

---

<div class="post-metadata">

**Author:** ![tomasz-waszczyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.astar.network/tomasz-waszczyk/32/28_2.png) [@tomasz-waszczyk](https://forum.astar.network/u/tomasz-waszczyk)\
**Post date:** [May 25, 2022, 12:01pm UTC](https://forum.astar.network/t/contract-contracttrapped/3352/22 "2022-05-25T12:01:29Z")

</div>

Is it your question? [solang - Get "Contract.ContractTrapped" error in Shibuya wasm - Substrate and Polkadot Stack Exchange](https://substrate.stackexchange.com/questions/2750/get-contract-contracttrapped-error-in-shibuya-wasm/) ? 😃

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forum.astar.network/u/james)\
**Post date:** [May 25, 2022, 1:13pm UTC](https://forum.astar.network/t/contract-contracttrapped/3352/23 "2022-05-25T13:13:18Z")

</div>

Yes, but ther error has been resolved by your last post(sending some SBY when call the “createNew”).But it’s not the end, when added a public interface to “Base” contract,  
eg,

string public name – public state field  
or  
function sum(uint a, uint b) public view (uint) – interface

the call “createNew” failed again.

Instead, use “private” or “internal” access modifier for state fields or functions of the “Base” contract, the call “createNew” shall be success.

So im not sure if this issue is related to the solang compiler or the substrate-wasm, even my misoperation

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forum.astar.network/u/james)\
**Post date:** [May 25, 2022, 2:10pm UTC](https://forum.astar.network/t/contract-contracttrapped/3352/24 "2022-05-25T14:10:00Z")

</div>

I have sovled the error. If the contract Base is deployed, then call “createNew” shall be success!

---

<div class="post-metadata">

**Author:** ![tomasz-waszczyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.astar.network/tomasz-waszczyk/32/28_2.png) [@tomasz-waszczyk](https://forum.astar.network/u/tomasz-waszczyk)\
**Post date:** [May 25, 2022, 2:40pm UTC](https://forum.astar.network/t/contract-contracttrapped/3352/25 "2022-05-25T14:40:50Z")

</div>

Do you say about that?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/f/f3d14329743164e52b6cd7b5020a6f5b9bf14a1f.png)

So is it fully solved?

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forum.astar.network/u/james)\
**Post date:** [May 26, 2022, 2:03am UTC](https://forum.astar.network/t/contract-contracttrapped/3352/26 "2022-05-26T02:03:16Z")

</div>

Hi tomasz, acctually, my goal is to make the Test contract as a factory to produce new Base contract instance as demand.

But before now, i ran into two problems, recapped as bellow:

Q1、call ‘creatNew’ to instantiate Base contract without any exposed interface (public fields or functions) will be failed  
.  
To solve this problem, some SBY need be sent along with calling ‘createNew’

Q2、call ‘creatNew’ to instantiate Base contract with some exposed interface (public fields or functions) will be failed.

To solve this problem, the Base contract aslo be deployed before call ‘createNew’.

Bellow are my some test cases:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/b/bd590996b13c1a26427054078b4fdd73f898eda0.png)  
 ![c](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/9/9c087c1bddc95194af56cfc802724407eddcd0bc.png)  
 ![cs](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/5/53b31caab979ab1bceceb4010e1787d661cfb3ed.png)

 ![sn](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/6/63f02407e91add410fb625462d2a77120170c488.png)  
 ![sn_s](https://us1.discourse-cdn.com/flex020/uploads/plasmnet/original/2X/d/dfa131786f24537087a7dc46177e6669b717c7c1.png)

By now, my goal is achived!

Thx tomasz for your full support.

BR

---

<div class="post-metadata">

**Author:** ![tomasz-waszczyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.astar.network/tomasz-waszczyk/32/28_2.png) [@tomasz-waszczyk](https://forum.astar.network/u/tomasz-waszczyk)\
**Post date:** [June 12, 2022, 9:00pm UTC](https://forum.astar.network/t/contract-contracttrapped/3352/27 "2022-06-12T21:00:39Z")

</div>

You are welcome. Do you build something for Astar and/or in Solidity? Could you show your Github’s profile?

[Previous page](https://forum.astar.network/t/contract-contracttrapped/3352.md?page=1)
