I'm developing a Dapp using truffle and I need to connect to a contract that I uploaded on rinkeby using truffle migrate --network rinkeby
. Problem is that I'm unable to connect to the rinkeby network from the web3 interface. I run a rinkeby local node using
geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --rpcport 8545 --rpcaddr localhost --rpccorsdomain "*" --unlock="0x4A1b47b0b119AFD421ec4E3b5B54D8EF5141b59c"
The front-end code is
if (typeof web3 !== 'undefined'){
web3 = new Web3(web3.currentProvider);
}else{
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
But the code always slaps me with
Error: Provider not set or invalid.
How can I resolve this issue and how to create a new contract instance from contract abi?
--rpcaddr 0.0.0.0
? this has worked for me in the past though I can't remember why, hence the comment instead of a full answer!rinkeby: { host: "localhost", port: 8545, network_id: 4, from: "address", gas: gas }