Skip to main content
Your contract is deployed. The next step is to interact with it: call its functions to read or modify its state. This guide covers Remix, JavaScript, and Python.

Prerequisites

  • Successful smart contract deployment.
  • The ABI and contract address from the previous deployment are recorded. Generated after compilation and deployment.
  • Funded wallet connected to the appropriate network (peaq/agung).

Instructions

Remix

1. Access the Deployed Contract

  • In Remix, navigate to the Deployed Contracts section in the Deploy & Run Transactions sidebar.
  • You’ll see your deployed contract listed, with an interactive UI displaying the contract’s functions.

2. Perform Write Operations

  • In the Deployed Contracts interface, locate the set function.
  • Enter an integer as an input field (e.g. 10) and click the set button.
  • A MetaMask popup will be triggered to confirm the transaction. Confirm the transaction and wait for it to be appended on-chain.
  • After completion the new value will be stored on the blockchain.

3. Perform Read Operations

  • Locate the get function in the Deployed Contracts drop down in the Deploy & Run Transactions tab.
  • Click the get button to fetch the current value stored in the contract.
  • The result will appear below the function, showing the updated value (e.g., 10).

JavaScript

1. Create an Interaction Script

  • Inside the scripts/ directory of your project, create a new file named interact.js
  • Add the following script to interact with your deployed contract:
JavaScript

2. Execute the Interaction Script

  • From the root directory of your project, run the command below. It runs the script against the agung network defined in hardhat.config.js.
You have now written, deployed, and interacted with a smart contract. The next section does the same thing in Python.

Python

1. Install Dependencies

  • web3 - Allows the interaction with EVM deployed contracts in Python.
  • python-dotenv - Provides basic protection for secret variables.

2. Create Python File

  • Inside the scripts/ directory of your project, create a new file named interact.py
  • Add the following script to interact with your deployed contract:
Python

3. Execute the Interaction Script

  • To execute the code above you can use the following script:
The Python script now reads from and writes to the same SimpleStorage contract. Contracts can also be written so that their logic can be replaced later, which is covered in Upgradable Smart Contracts.