Interact with a live deployed smart contract using Remix IDE
Summary: This article is related to interacting with a smart contract this deployed on either testnet or mainnet of a blockchain. We can always write test cases or scripts to interact with the contract, but remix provides a quick method to query and interact with a live smart contract easily.
In this example, I have already deployed a smart contract on polygon (mumbai) testnet.
- Deployed Smart Contract Source Code: NFTToken.sol.
- Address of the deployed contract: 0x68B1D87F95878fE05B998F19b66F4baba5De1aed
- Metamask; configured with the blockchain, along with owner of token contract wallet connected to it, and having some token in wallet.
Step 1: Compile the contract in Remix IDE
- Visit https://remix.ethereum.org in browser, to open the remix IDE.
- Copy the source code of the smart contract that you have already deployed and compile it again. After a successful compile you should see something like this,
Step 2: Connect your Remix IDE to metamask
Set the environment in deploy configurations.
Select yes / connect for the pop up permissions so that you can link remix IDE to metamask wallet, make sure you select the correct account while connecting.
Step 3: Connect your Remix IDE to Metamask
We don't want to deploy this contract, as it is already deployed. We need to simply connect the already deployed contract.
Paste the address of the smart contract in “At Address” section.
Finally, click the “At Address” blue button.
From the results I came to know that there are no tokens created in the smart contract. This is how you can interact with a live smart contract.
As this function was a simple read function, so there will be no gas fees incurred.