0

I have a decentralized web application that is hosted in the cloud. I recently deployed a smart contract to two different test networks Ropsten and Goerli - my contract deployed to the Ropsten network is using infura as the host so the provider is https://ropsten.infura.io/v3/{project-id}. my web application is able to access the contract because it's hosted by infura However when I deployed the same contract to Goerli - I set up a local geth node and connected accounts that I created with clef. I deployed the same contract from localhost:8545 (the default geth port) I can interact with my contract locally when I run my application from localhost:3099.

However when users access the application via the web, How do I connect my web application to my locally hosted geth node? When I run my application locally (from a different port) current code below

if (process.env.NETWORK === 'goerli') { 
    host = process.env.HOST;
    port = process.env.GOERLIPORT;
    web3address = host + port; // http://localhost:8545
}
var web3 = new Web3(web3address);

Would I have to point my live web application to my public ip instead of localhost:8545? If I'm running my geth node locally?

Are there any tutorials or information on deploying smart contracts from a local geth node and have a web application that lives in the cloud interact with the contract that is hosted on such local node - As always any information is appreciated

1

How do I connect my web application to my locally hosted geth node?

You don't. You need to provide a public Ethereum node to your users yourself or with a service like Infura.

Here is a service provider list:

https://ethereumnodes.com/

2
  • Hi Mikko - thanks for taking the time to answer the question - I guess a follow up question would be, if you had a machine dedicated to running a full node - how would one make it public? In theory couldn't you deploy from that and just use your point application to your public IP? Could this be done securely? – James Daly Dec 31 '20 at 20:26
  • Was reading more about it here ethereum.stackexchange.com/a/10682/60337 How does one make an ethereum node public? – James Daly Dec 31 '20 at 20:45

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.