Ethereum - Creating Contract Users


In this chapter, we will learn the creation of contract users on Ethereum. To create a user for our published contract, we will create another MyEtherWallet client attached to the same Ganache Blockchain that you have been using in the previous steps. Go to the MyEtherWallet screen and create a new wallet.

Click on the contracts menu and select the “Interact with Contract” option as in the earlier case. Note that this new user is going to simply interact with the already published contract and not deploying his own contract. Specify the contract address and the ABI that you used in the earlier case.

Interact with Contract Address

Now, click Access button and invoke send method. When asked, input some value say 100 ETH to be sent. Submit the transaction. Upon submission, the following screen will appear.

Interact with Contract Access

To attach this new client to our Ganache Blockchain, go to Ganache Console. Click on the keys icon of account # 2 as shown in the following screenshot −

Ganache Console Screenshot

You will get the private key for account # 2.

Ganache Console private key

Copy the key that you receive and use it in your newly created wallet as shown here −

Newly Created Wallet

Click on the Unlock button to attach the wallet.

When the wallet is successfully unlocked, write the desired send transaction.

Wallet Successfully Unlocked

Generate the transaction by clicking on the “Generate Transaction” button.

Generate Transaction

Make the transaction and wait for some time for it to reflect in the Blockchain. Now, execute “getAmount”, the amount shown should be 200 now.

Generate get Amount

Execute “getBalance”. The value field should now be 800.

Generate get Balance

Examine the transaction log to see the various transactions performed by different users.

Examine The Transaction
Advertisements