Initializing new contract from another contract?

Is it possible to initialize a new contract from a previous contract? So can we create a new NFT contract from a factory? I know we can host.invoke_contract to call a message on another contract but was wondering if it was possible to create one in the first place?

It is not possible to create a new contract instance from a contract.

You would have to create it separately. You could then “initialize” it by calling a designated “initialize” endpoint.

1 Like

What do you mean here by “initialize”? If I created it separately it is already initialized.

And thank you for the response will need to find a counter for it :slight_smile:

I mean that initialization is whatever you define it to be. In general creating the instance does not have to mean that the smart contract is in any usable state. You could require that a special “initialize” endoint is first called before any other endpoint is enabled.

Makes sense which would change the state. May write a post in the forum explaining it for other devs coming in from Solidity and such as it may be different for them

Of course. We also have an FAQ for ethereum developers here FAQs — Concordium documentation

Perhaps you could expand on that instead? The repository with documentation is here https://github.com/Concordium/concordium.github.io

1 Like

hello hello! wanted to clarify something (please bear with me as I’m very new to the chain). so I understand that you cannot deploy new contracts to the chain programmatically; however, something is still not quite clear. what if I deployed two smart contract modules to the chain? one “factory” and an NFT contract, for example. is there a way that I can initialize multiple NFT contract instances programmatically via transactions on the factory contract? any help would be appreciated here, thanks!

You cannot create new instances from a smart contract.

You can do this externally, by sending multiple transactions via, e.g., an SDK. So it is still done programmatically.

Do you have a specific problem where that is not sufficient?

Just seeing this now. thanks for the reply, I suppose the implementation pattern you mentioned is sufficient; however, not quite as clean as doing it all in a single contract update transaction. we make do with what we have! nevertheless, I appreciate the help!

1 Like