Using the Deployed Smart Contract in Remix
To interact with our smart contract, let's look at the functionality we have available. Under Deployed Contracts, expand your deployed Money Game smart contract to see its functions:
We have the following functions:
play: allows a user with a blockchain address to join the current game - the red button means it's a
payablefunction and we need to pass in
etherto call it
readTargetNumber: shows the owner of the contract the current targetNumber
Reading data from the smart contract#
When a smart contract gets deployed on the Ethereum blockchain, you have a piece of software that lives on the blockchain. The software we have created is the Money Game. This section will teach you how to interact with a deployed smart contract on
Remix (i.e. play the Money Game that we created on the Ethereum blockchain). To use the Money Game smart contract we will invoke various functions (the ones we created) using Remix.
Account field under the
Deploy & Run Transactions section.
I take note that the account that I deployed with started with
0x5b3 and ends with
Remix where I can see my blockchain transactions, I will see the corresponding transaction that I executed to deploy my smart contract.
Now that we can confirm the address that I used to deploy the smart contract, let's see if we can invoke the
readTargetNumber function. If we can invoke it correctly, we should see the value
5 returned to us since that is what we set it as when we deployed the smart contract.
To invoke the function, click the button labeled
readTargetNumber. You should see a value returned,
5 (if you set your
targetNumber) to be
The console will also identify to you that the address you deployed with is trying to read the function.
To confirm that the function works, let's change the address that we are using and try to call the function again. I can change the function by scrolling back to the top of Remix and changing the address to another account (e.g. one that starts with
0xAb8 and ends with