Skip to content

Latest commit

 

History

History
 
 

exercise2

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Exercise 2: Interacting with an existing Smart Contract

In this exercise we will be using MyCrypto to interact with Smart Contracts.

The Smart Contract we will be using here is already deployed in the Rinkeby testnet and has some basic functionality which you will be interacting with. These are the methods available:

  • "hello": Will return a greeting message
  • "getNumPokes": Will return the number of pokes sent to the contract
  • "poke": Will send a poke to the contract (requires a transaction confirmed by MetaMask)

Instructions

First let's set it up:

  • Pre-requisite: Have MetaMask installed as a Chrome or Firefox plugin (see Exercise 1)
  • Go to MyCrypto
  • Select how you want to access your wallet. Click on Web3/MetaMask and follow the steps for approval

Follow these steps to interact with the contract:

[
    {
        "inputs": [],
        "name": "getNumPokes",
        "outputs": [
            {
                "internalType": "int256",
                "name": "",
                "type": "int256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "hello",
        "outputs": [
            {
                "internalType": "string",
                "name": "",
                "type": "string"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "poke",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }
]
  • Play around with the available functions
    • NOTE: reading functions will not require a transaction but writing functions do, so you will have to confirm it using MetaMask.

Now, if you want to play around with a more complex contract feel free to select the ones provided by the tool, or take a look at voting (contract details here).