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

Similar Posts

  • Compiling the Contract

    Once you write the complete contract code, compiling it in this IDE is trivial. Simply click on the Autocompile checkbox in the IDE as shown in the screenshot below − Alternatively, you may compile the contract by clicking the button with the title “Start to compile”. If there is any typo, fix it in the code window. Make…

  • Smart Contracts

    There are several tools available to develop and test contracts. One of the simplest tools is provided on the official Ethereum site itself. The tool is called Remix, we will use this for our contract development. Remix for Contract Development Open the Remix IDE by typing in the following URL in your browser.https://remix.ethereum.org The following screen…

  • A Quick Walkthrough

    We will now briefly understand what is available on the Ganache desktop. On the Desktop, at the top we have several menu options out of which a few are of immediate relevance to us. The menu bar is highlighted in the screenshot below − Clicking on the TRANSACTIONS menu shows all the transactions performed so far. You…