What is the best way to deploy a contract from DApp Builder

Hello everyone. I didn't know how to make my question clear, for which I'm sorry)
I've seen a lot of smart contract builders recently, where you can create and deploy your contract via DAPP and the users' wallet as an owner (like in Remix ethereum, but without the editor).
My question is, how's that possible? Is there an open API or something which lets you deploy the contract on the user's behalf? I've tried to find some docs, but couldn't((

As an example of the builder, you can visit https://studio.manifold.xyz.

Thanks a lot for your time

Hi,

Is hard to tell exactly how they do it, since they are not open sourced, but most likely they have the logic of deploying a contract, using web3 library or hardhat, and they only deploy on their own network on your behalf assigning you a random address previously funded, if you re goin to deploy to a real network it will ask you to connect your wallet, meaning Remix is not deploying your smart contract in your behalf, you are doing that with your own account on that network.

1 Like

I've made the builder where I'm just generating the smart contract based on the properties that the user passes and giving back the .sol code, which can be downloaded or copied. Now I want to add the possibility to deploy the contract, and couldn't find a solution or even a best practice to accomplish that task.

I would suggest working on a connection with metamask so the user do it themselves.

Any examples or practices without the private key and remix IDE that you can suggest ?

@JulissaDantes waiting for your response)
Thanks in advance

Hi @armanmamyan,

I'm not sure how the website you mention is doing it, but the way I would approach it is to use a Factory contract. The factory contract would have the code of the contract you want to deploy. The user would call the factory contract to deploy the final contract. Your Dapp would also pass to the factory the construction parameters for the Factory contract, and then the Factory would instantiate the final contract using those parameters. If you want the user to own the deployed contract you could use Ownable from OZ and then change the ownership after deployment.

1 Like

Hi @RobertoCano. Thank you so much for a such detailed response.
Regarding the ownership, you mean call transferOwnership() method after deployment?
It's not a good practice in case of NFT contracts, as the community can treat that as a scam. I've created more than 50 contract for different clients from all over the world. Most of the time that transfer causes a panic.

Sure! You don't need to do that if it's not aligned with your requirements. Still I think those D'apps you mention are following the Factory approach. Have a look at it to see if it fits your needs.

Yes, they are. I've started to deep dive into the Factory contracts and Foundry. I think that's the best approach.
What I do right now, is just save basic templates and rename the keywords when the user applies them.
Take a look at this, when you have time. Will appreciate any feedback.