Contract.ContractTrapped

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.





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.

1 Like

Is it your question? solang - Get "Contract.ContractTrapped" error in Shibuya wasm - Substrate and Polkadot Stack Exchange ? :smiley:

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

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

Do you say about that?

So is it fully solved?

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:




By now, my goal is achived!

Thx tomasz for your full support.

BR

2 Likes

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

1 Like