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?
Best Answer
Dapp using truffle and local server this commend run:
and try it http://localhost:8000
Rpc domain --rpc --rpccorsdomain "http://localhost:8000" then run project