So I am making a multiSig wallet and i am making a UI with web3.js and all of that. I am pretty much finished my project and evrything looks and works great and i have included the ability for ERC20 transfers too. However there is one final thing that i want to include that is troubling me and i cannot seem to figure out a good solution. Basically i want to have it so that a user can log in and have the option to create multiple wallet instances. The way i currently have it there is only one contract that gets deployed. This obvioudsly works fine for myself when testing etc. However i am now thinking, what if some other user in a different location opens my DApp. Then they will be faced with the original deployed contract showing my funds and other signatories etc. They would also not be able to do anything because they are not an owner and therefore will not be able to call any of the wallets functions.

So what i want to do is set up my front end so that each time someone opens my DApp the have the ability to create a new wallet instance (maybe by deploying a new contract instance at the click of a "create wallet" button or something. I am struggling of thinking of a good way to do this.

So far i have considered the following two options and now i would like some advice of a good way to achieve what i want.

Using a Factory Contract

The first option i have looked at is to perhaps modify my multisig contract and make it into a factory contract where an on-chain template contract is used as a factory that generates contract instances from the template. From this i could perhaps be able to code some logic in the front end that allows users to create wallets.

Using web3.js' wallet.create

The second option i was looking at was using the "create wallet" functionality of web3.js. For example in the web3 documentation there a numerious examples of functions like web3.eth.accounts.wallet.create(numberOfAccounts [, entropy]); which Generates one or more accounts in the wallet. If wallets already exist they will not be overridden. Now i have not researched into this way as much (but i plan to do so) but it seems that if i did it this way i would be replacing the metamask functionality of providing accounts for my wallet which i currently am doing with this more "from scracth" approach for lack of a better word.

Using web3.js' contract.deploy()

The last approach I have considered is to use myContract.deploy() with web3.js library to manually deploy a new wallet contract instance each time a user would like to create a new wallet. I think i could get this to work but i am struggling to think user login about how my dAPP will know what contract instance to load for each user that accesses my Dapp?? maybe im overthinking this one a bit

I would like the opinion of some of you guys who know more than me, the best way to go about this so that users can log in and create multiple wallet instances. I am very new to solidity i have only been learning it for about a month and thus my knowledge is in its youth so i would appreciate any advice on how to solve my issue because i am really happy with my project and it would be great if i could make it this extra bit better and more "production ready" if you will. I am only really looking for general guidence and maybe an outline of an approach anyone would recommend with that i will be able to figure out the code and logic myself

Regards Evan


Using a Factory Contract

Just do this, because that's what everyone else (Gnosis Safe, SushiSwap, etc.) are doing.

  • soo are you suggest i just use the a factory contract? Yes ok thank you i was just brainstrorming different approaches and didnt know what would be the easiest (an best) to implement. thank you
    – Cian Darcy
    Aug 21 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.