0

With Remix IDE, I can deploy Smart Contracts and interact with them, with Remix VM, without deploying on testnets.

When I want to interact with Smart Contracts developed on Remix IDE, from a webapp (e.g. with ethers), I deploy them in a testnet (public layer, not localhost like Remix VM) and later on I connect to the testnet RPC node and contract address, with the help of Metamask.

Can I connect directly to Remix VM connection from my localhost webapp?

From documentation I can get that Remix VM connection RPC URL is:

http://localhost:8545

I cannot find the Chain ID in documentation, but I have developed a simple function to get it, which returns "1" value.

function getChainID() public view returns (uint256){
        return block.chainid;
    }

The point is that Metamask does not accept that network as valid (http://localhost:8545 with chainID: 1). How could I connect to Remix VM chain?

1 Answer 1

1

Why do you wanna connect to Remix VM? You need to do the other way around, I guess.

  • Spin up a local node using hardhat or anvil. It should be running in http://localhost:8545.
  • Connect remix to the localnode by choosing the hardhat or anvil provider.
  • Now you can deploy contracts to your localnode using Remix.
  • Also you can connect your metamask and frontend app to your localnode to test the transactions.

This is the simplest approach.

2
  • While it is also a simple approach, it requires to run the hardhat node on terminal. Using Remix VM (if possible) you could avoid even running hardhat node. Commented Jan 18 at 13:35
  • 1
    If you want to connect to a node, the node should expose a RPC server to accept requests. Remix VM runs its sandbox blockchain in the browser and it doesn't expose a RPC server. So you can connect Remix with external providers, but not vice versa.
    – PraneshASP
    Commented Jan 18 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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