[Ethereum] Is it possible to create new wallet account in Solidity contract


I want to create a new wallet account and send some my own currency to it whenever someone sends me some ether to my contract. Is it possible to do this via contract itself or I need to do it in another way. Any help regarding this will be highly appreciated.

Best Answer

Creating an Ethereum account i.e. public/private key pair, is computationally expensive. From reading the yellow paper, we know that the more instructions executed by the EVM, the higher the cost to execute that transaction on the network. You could theoretically write code to do this; However, how economically feasible would it be?

For example, after looking at the Java implementation of the Ethereum protocol, we can see the vast amount of proprietary code and libraries needed to effectively create an Ethereum 'account'.

An alternative solution would be to create these accounts off chain. You could then preload them into a smart contracts storage. If there are a large amount to be stored, you may run into costing issues again. Think about storing them in IPFS and referencing them from the smart contract to avoid these costs.

I hope this answers your question. Leave me a comment if you need clarification. :)

Related Topic