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

  • Deploying Contract

    To deploy the contract, select the Contracts menu option as shown in the screenshot below − You will need to enter the contract’s bytecode on this screen. Remember, when you compile your Solidity contract code, it generated a bytecode that runs on EVM. You will now need to obtain this bytecode from Remix IDE. Go to the Remix…

  • Summary

    You learned how to write your own digital contract in Solidity. You developed and tested the contract interface in the Remix IDE. For further multi-user testing, you deployed this contract on Ganache Blockchain. On Ganache, you created two user accounts. The first account was used for publishing the contract. The second account was used for…

  • Solidity for Contract Writing

    Solidity is an object-oriented language especially developed for contract writing. It is a high-level language, which inherits traits from C++, Python, and JavaScript. The Solidity compiler compiles your source code into bytecode that runs on Ethereum Virtual Machine (EVM). For quick understanding of the Solidity syntax, look at the sample code in the IDE.pragma solidity…

  • 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…

  • Ganache for Blockchain

    Ganache is used for setting up a personal Ethereum Blockchain for testing your Solidity contracts. It provides more features when compared to Remix. You will learn about the features when you work out with Ganache. Before you begin using Ganache, you must first download and install the Blockchain on your local machine. Downloading Ganache You…

  • 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…