0

I am working on a project and I have successfully deployed a smart contract on Kovan test network, but for some reason, I am not able to interact with it in JS code. So, now I want to access it through remix IDE(as it has the option to do so)

How I am trying to do this:

  • Entering Remix
  • Switching to Injected Web3 option in Environment
  • Connecting metamask with remix
  • Entering the contract address in the At address field
  • Pressing the At address button

Nothing is happening after pressing the button.

Deployed contract address: 0xCC0F8a34B0e4ce5baac80c50E5bB1E4042dDED67, etherscanlink.

This is the contract code(mostly irrelevant to the actual problem):

contract CampaignFactory{
    address[] public deployedCampaigns;

    function createCampaign(uint minimum) public { 
    }

    function getDeployedCampaigns() public view returns (address[]) {
        return [];
    }
}

I tried remix in Google Chrome and Mozilla Firefox, the same problem.

Please tell me if, this feature is available or not(interacting though deployed contracts on test networks in remix IDE)?

Suggestions?

1

Your steps to use Remix are fine, so just two remarks that might help:

  1. Make sure you have selected your contract CampaignFactory in field CONTRACT from <Deploy & Run transactions> menu. Otherwise, if you put the contract address but you haven't selected the contract, it won't deploy it in Remix. The field CONTRACT is linked to the file explorer, where you save all your contracts.

  2. Your contract is apparently not compiling. Not sure what you try to achieve, your Solidity pragma and the reason to return an empty array, but you need to add the location in the return type. E.g.:

    function getDeployedCampaigns() public view returns (address[] memory) {
       return deployedCampaigns;
    }
    
  3. Extra: probably not the case, but I have had issues when using Remix with https, so better to use http if your browser allows to do so.

4
  • Why do remix want the contract itself, the contract is already deployed on the Kovan test network and I expect remix to fetch it from there(and not ask me). But thanks for the clarification. I will try these. Dec 24 '20 at 10:28
  • Are you saying that remix cannot fetch contracts from test networks? Because really I was expecting to just enter the contract address and get the interaction options. Dec 24 '20 at 10:32
  • 1
    You need the code, otherwise, there is no way to translate the functions of the contract in Remix. In fact, if you look at your deployed contract with etherscan, you’ll see that your code is unreadable from there. It’s the way Remix works to translate the code. With JS, you also need to include the ABI code from the contracts to use its methods via web3.js or ethers.js. Dec 24 '20 at 12:02
  • I just forget completely that I need the interface (ABI) of the deployed contract to communicate with it. Dec 25 '20 at 22:21
1

Since you already have the source code of the contract, you can follow the below steps to get the interaction options on Remix

  1. Create a .sol file and paste the contract code in it
  2. Compile the code using the appropriate settings (version etc.)
  3. Switch to the "Deploy & run transactions" tab. Select the contract name in the contract field if it has not already been selected
  4. Enter the address of the contract and click the "At Address" button. The methods will become available to you in the "Deployed Contracts" section
  5. You can now interact with the contract as you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.