I'm trying to run a contract on a private local network so that I can develop and deploy a contract on the mainnet for some ERC20 token.
Starting with the greeter tutorial, I compiled the default example as follow
$ solc -o target_greeter --bin --abi src/the_greeter.sol
I also created a testnet as follow:
$ geth --identity "SolidityTestNode" --rpc --rpcport "8080" --rpccorsdomain "*" --datadir testnet/ --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 1999 init testnet/CustomGenesis.json
Then I connected to my local network via ethereum wallet by starting it as follow:
$ ethereumwallet --network test --rpc testnet/geth.ipc
I then assumed that I could deploy a contract as follow:
But it returns error Could not compile source code.
I also tried to enter that code in the geth console, but greeterFactory.new() line never returns the prompt and I don't see any syntax error in the example
How am I supposed to deploy the Greeter contract on my local testnet ? The tutorial isn't precise enough in that regard.
Thank you for your support.
Related
I am new to deploying smart contracts with hardhat and am following a tutorial. However, after running const contract = await ethers.getContractAt("Decentratwitter","0x5FbDB2315678afecb367f032d93F642f64180aa3") I get the following error. Any ideas on how to fix connection issues?
avinash#avinash-HP-Laptop-15-bw0xx:~$ cd twitter
avinash#avinash-HP-Laptop-15-bw0xx:~/twitter$ npx hardhat run scripts/deploy.js --network hardhat
Decentratwitter deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
avinash#avinash-HP-Laptop-15-bw0xx:~/twitter$ npx hardhat console --network localhost
Welcome to Node.js v14.19.3.
Type ".help" for more information.
const contract = await ethers.getContractAt("Decentratwitter","0x5FbDB2315678afecb367f032d93F642f64180aa3")
Uncaught HardhatError: HH108: Cannot connect to the network localhost.
Please make sure your node is running, and check your internet connection and networks config
at getContractAtFromArtifact (/home/avinash/twitter/node_modules/#nomiclabs/hardhat-ethers/src/internal/helpers.ts:337:19)
at getContractFactoryByAbiAndBytecode (/home/avinash/twitter/node_modules/#nomiclabs/hardhat-ethers/src/internal/helpers.ts:280:21)
at getSigners (/home/avinash/twitter/node_modules/#nomiclabs/hardhat-ethers/src/internal/helpers.ts:45:20)
at EthersProviderWrapper.send (/home/avinash/twitter/node_modules/#nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
at GanacheGasMultiplierProvider.request (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:306:23)
at GanacheGasMultiplierProvider._isGanache (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:317:30)
at HttpProvider.request (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/http.ts:80:29)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at HttpProvider._fetchJsonRpcResponse (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/http.ts:205:15)
Caused by: Error: connect ECONNREFUSED 127.0.0.1:8545
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:130:17)
Run npx hardhat node in your terminal. Leave the process running.
Open a new terminal window.
Run npx hardhat run [script-name] --network localhost
Hope it helps!
I noticed that with a node on my AWS instance and geth node on my laptop, my AWS node can add my laptop as a peer, but my laptop cannot add my AWS instance.
Both nodes use a similar geth command line to the following:
geth --identity "node2" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "./" --port "30303" --rpcapi "db,eth,net,web3" --networkid 1432 --nat "any" console --nodiscover
Would anyone know the cause of this behavior?
I made Genesis block and turned on with geth
like this
geth --identity "PrivateNetwork" --datadir "/Users/username/dev/ethereum/data" --port "30303" --rpc --rpcaddr 0.0.0.0 --rpcport "8123" --rpccorsdomain "*" --nodiscover --networkid 1900 --nat "any" --rpcapi "db,eth,net,web3,miner" console
and... checked with this command:
eth.accounts'&'eth.getBalance(eth.accounts[0])
It works, however I don't know how to connect with mist
I had tried /Applications/Mist.app/Contents/MacOS/Mist --rpc http://localhost:8123 but what I can see is only this error message below
Error starting up node and/or syncing Error: Couldn't start swarm process.
at Timeout.error [as _onTimeout] (/Applications/Mist.app/Contents/Resources/app.asar/node_modules/swarm-js/lib/swarm.js:451:23)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)"
I thought geth is CLI client and Mist is GUI client for ethereum net
I'm not sure even It is right
Do I need to turn on both of them? or turn on only one? please help me!
Make sure you dont use the same rpcport for both of the applications. Use a different port for each one.
I guess you given wrong ip address. So when you run the command you will find below on your gth console.
INFO [01-31|10:32:06] IPC endpoint opened:
/Users/divum/Desktop/local-network/geth.ipc INFO [01-31|10:32:06]
HTTP endpoint opened: http://127.0.0.1:8545
Now try with
/Applications/Mist.app/Contents/MacOS/Mist --rpc [HTTP_END_POINT_URL]
Replace HTTP_END_POINT_URL with your log http endpoint url.
I'm trying to set up a local Ethereum node in a Vagrant (trusty64, geth 1.7.1-stable):
geth --identity "test_remote" --datadir "./geth_data_remote" --trace "./geth_data_remote/trace.txt" --dev
and getting the following error:
19:00:20.199679 syncDir: sync /var/www/vhosts/localhost/htdocs/geth_data_remote/geth/chaindata: invalid argument 19:00:20.199749 CURRENT: sync /var/www/vhosts/localhost/htdocs/geth_data_remote/geth/chaindata: invalid argument
Locally (OSX 10.12.6, geth 1.6.7-stable) it works without any problems that's why I can't get the problem.
p.s. Setup in Vagrant works only with a default path. What could be the reason?
Geth 1.6.7.
I have used this manual
https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster
looks very simple
run bootnode
./bootnode -nodekeyhex
dc90f8f7324f1cc7ba52c4077721c939f98a628ed17e51266d01c9cd0294033a
UDP listener up
self=enode://890b6b5367ef6072455fedbd7a24ebac239d442b18c5ab9d26f58a349dad35ee5783a0dd543e4f454fed22db9772efe28a3ed6f21e75674ef6203e47803da682#[::]:30301
run 2 geth`s on the local machine
geth --bootnodes
enode://890b6b5367ef6072455fedbd7a24ebac239d442b18c5ab9d26f58a349dad35ee5783a0dd543e4f454fed22db9772efe28a3ed6f21e75674ef6203e47803da682#127.0.0.1:30301
--datadir "./node1" --port 30310 --rpcport 8110 --ipcdisable --networkid 1024 --cache=512 --rpcapi personal,db,eth,net,web3 --rpc console 2>> ./node1/geth1.log
geth --bootnodes
enode://890b6b5367ef6072455fedbd7a24ebac239d442b18c5ab9d26f58a349dad35ee5783a0dd543e4f454fed22db9772efe28a3ed6f21e75674ef6203e47803da682#127.0.0.1:30301
--datadir "./node1" --port 30311 --rpcport 8111 --ipcdisable --networkid 1024 --cache=512 --rpcapi personal,db,eth,net,web3 --rpc console 2>> ./node1/geth1.log
checked peers via console
admin.peers []
As you can see nodes do not see each other. What have I done wrong?
Thanks.
You have to add the second instance to your admin node (i.e. your first instance). Run the command admin.addPeer(enodeUrlOfFirstInstance).