How to generate Ethereum wallet address in C#

By | 25. April 2019

With this short article we will start series of blockchain related topics. Mostly we cover questions for beginners, but eventually we will also look into more complex themes.

So today we start with simple Ethereum address/account generator.

 

First we create small Windows form application with button to generate address and two edit boxes to show public address and private key.

 

We will use Nethereum.Portable nuget package. Though this package contains much more than needed for address generation, we will us it as it will be also in future blog posts to come.

Also reference to System.Numerics must be added.

The code is few lines only.

First we generate random private key, convert it to hex string format and after that calculate public key from private key.  Private key always determines the public key.

 

Found key pair is then filled to text boxes on screen but also written to text file what is created in location of executable file itself. New keys are appended to file as generated.

Keep in mind that if private key is lost then the account with all assets on it is lost too. There is no way to recover it. Also if outsider gains access to private key then he/she gains access to all assets on account.

 

And result is:

 

Source Code: CreateEthAddressSource.zip (19 downloads)

Or if if you want juts for fun generate addresses then you can download binary:

Executable: CreateEthAddressBinary.zip (10 downloads)

 

Leave a Reply