Question about where account creation code goes

Let’s say for the sake of the example I wanted to create a web application where users can create donation pages and have visitors donate Solana/USDC/etc to the pages using their wallet.

I’m assuming I will need a script when each one of these donation pages are created a Solana account will need to be generated so visitors can donate to this new wallet (linked to the page). I know you can create a new account using the web3 JavaScript but I’m wondering if this is the correct way to do it. My initial developer mindset was that creating new wallet address is something that shouldn’t be done in the web app and should be part of the smart contact “program” side but I wasn’t able to find any documentation on how to create/delete/manage accounts in the smart contact. Can someone shed some light onto this? I feel like I need some more understanding of which part of the programming should be done in the smart contract side and which part should be done in the web app.

I know this is a loaded question so any bit of insight would be much appreciated.

Hey @MrNine, it’s actually the responsibility of the web app to pass in the accounts that the smart contract will need to complete the transaction. If the account hasn’t been created yet, then it’s actually the job of the web app to create a new keypair and then pass that brand-new keypair as an account to the smart contract.

The smart contract will then transfer ownership of the newly created account to itself and initialize the account with the data it needs.