Replies: 10 comments
-
Regarding your first example: Yes, this is the most simple way to instantiate a contract from within another contract. As for the reply: I think you might be misunderstanding where this is called. The reply is not called on the newly instantiated contract (B), but on the contract that instantiates (A). It is often used to save the address of contract B into the state of contract A. |
Beta Was this translation helpful? Give feedback.
-
@chipshort can you give me an example with Also, can I return the event output of contract B's instantiated contract to contract A? |
Beta Was this translation helpful? Give feedback.
-
this is my contractA code: https://github.com/DoraFactory/cw-amaci/blob/main/contracts/registry/src/contract.rs#L211-L239 I'm currently hoping to be able to get the contract address by reply, and it would be best if I could inherit the event data. But I'm getting this error when calling contractA. https://github.com/DoraFactory/cw-amaci/blob/main/contracts/registry/src/multitest/tests.rs#L142-L184 |
Beta Was this translation helpful? Give feedback.
-
I solved the problem with the test code with this code. https://github.com/DoraFactory/cw-amaci/blob/main/contracts/registry/src/multitest/mod.rs#L72 I observed that the event data does get inherited through the submessage form, and through the reply func, I also get the address of the contract. So how to call this transaction correctly with cli or client? |
Beta Was this translation helpful? Give feedback.
-
Here is an example for instantiate2: cosmwasm/contracts/virus/src/contract.rs Line 37 in 9e822c4 Your test code is wired up incorrectly. As I explained before, the reply is called on contract A, but you are telling multitest to call contract B. |
Beta Was this translation helpful? Give feedback.
-
@chipshort Did you mean this? DoraFactory/cw-amaci@26e0554 |
Beta Was this translation helpful? Give feedback.
-
Yes, that's the line I meant. If you want to use the reply instead of instantiate2, you should implement the |
Beta Was this translation helpful? Give feedback.
-
@chipshort I'm clear on what it means, thanks for your patience! 🙏 It's worked now. haha |
Beta Was this translation helpful? Give feedback.
-
@chipshort Is there any way to transfer the event in contractB to the reply method of contractA? this is my event logs I need transfer to contractA(registry) Because I'm running an indexer under the chain and need to log to the database based on this data. This is the transaction information sent by my current code, the event data is now too scattered adding to the difficulty of developing the indexer. If I can return all event data in reply, it will reduce my development difficulty. https://vota-testnet-explorer.dorafactory.org/doravotatestnet/tx/C45A865D9236A9478755AF09F6A259F7A396D20B4B0974E31EEEC2877AF3D731 |
Beta Was this translation helpful? Give feedback.
-
The way I use set_data seems to solve the problem, is this the recommended way to write it? Or is it safe? https://github.com/DoraFactory/cw-amaci/blob/main/contracts/amaci/src/contract.rs#L276-L319 |
Beta Was this translation helpful? Give feedback.
-
I want to implement a method in Contract A for instantiating a new contract.
And this is my first version code:
And I saw that there was the concept of
reply
and I didn't quite get what the need forreply
was here?I mainly want to create the amaci_code_id contract with this method, which one do you guys recommend to use more? use the reply or not use is ok?
Beta Was this translation helpful? Give feedback.
All reactions