I cannot access a deployed and mined Ethereum contract on a private network from the Geth Javascript console. Not sure where the issue is, any help is appreciated.
Thank you in advance for your time.
Scenario
I launched my Geth as below
geth --datadir ~/.ethereum/myProject --networkid 1234 --rpc --rpcport 8546 --rpcapi "eth,net,web3" --unlock 0 console
I've deployed and mined an Ethereum contract (to simplify things, I've used the default MetaCoin contract provided by Truffle), and I got the trx and contract address back.
I can access it from the Truffle console but if I try from the Geth Javascript console I get an error.
Please refer to the pictures below:
Truffle console
Geth javascript console
Software used
Geth (v1.7.3-stable)
NodeJS (v6.12.3)
TestRPC (v6.0.3 (ganache-core:2.0.2))
Truffle (v4.0.5)
Geth does not know about MetaCoin. In Geth console, you need to do:
var MetaCoin = web3.eth.Contract(metaCoinJsonAbi, itsAddress);
// or web3.eth.contract depending on the version of Web3
Then you can use it. Refer to this.
Related
I've run the Ethereum Goerli Network with the following command:
geth --goerli --datadir="/mnt/sdc1/ethereum/goerli/" --port="30304" --cache 4096 --http --http.addr="0.0.0.0" --http.port="8546" --http.vhosts="*" --http.corsdomain="*" --http.api="admin, debug, web3, eth, txpool, personal, clique, miner, net" --authrpc.jwtsecret=/tmp/jwtsecret --authrpc.vhosts="*" --authrpc.port=8553 --allow-insecure-unlock --mine --miner.threads=4 --miner.etherbase '0x...'
with enabled miner and etherbase, but mining is not started.
I've seen the next in logs:
INFO [07-07|19:01:18.501] Commit new sealing work number=7,186,017 sealhash=3033a3..979541 uncles=2 txs=22 gas=29,479,757 fees=0.04464585701 elapsed=108.735ms
WARN [07-07|19:01:18.501] Block sealing failed err="unauthorized signer"
What's wrong?
How can I enable mining in Ethereum Goerly Network?
Thank's
As of August 11th, 2022, the Goerli network "merged" to be proof-of-stake network secured by validators who stake testnet ETH tokens rather than by miners.
There is a guide on how to become a Goerli validator here, if interested: https://coinmarketcap.com/alexandria/article/how-to-set-up-an-eth-2-0-validator-on-goerli-testnet
I just installed geth and
I start an instance of geth with this command: geth --rinkeby --syncmode=light --http
then I attach to that instance with this command: geth attach http://127.0.0.1:8545
and it seems to work well...
personal command return me that:
but on command personal.newAccount() I get this error:
From what I found in a old post: https://ethereum.stackexchange.com/questions/51772/account-created-using-web3-is-not-showing-in-geth-console I should allow personal api on starting command, but right now --rpcapi personal option is not available.
Do you have any idea what I did wrong?
I want to run livepeer and for that I need it to get connected to an Ethereum network. There are two options as mentioned here:
Hosted API services
Self hosted Ethereum node
If I want to opt for the latter, how would I mention rinkeby?
Because I only want to use for the test purposes.
The tutorial uses geth as example of the self-hosted Ethereum node.
In the geth manual, you can find the --rinkeby option to connect your node to the Rinkeby network.
Example:
geth --rinkeby --rpc --rpcapi "eth,net,web3"
It seems that the Livepeer doc only shows 1 hyphen (-) for the geth options, but it really should be 2 (--).
Don't forget to change the network option to -network rinkeby on Livepeer start as well.
Example:
livepeer -network rinkeby -ethUrl "http://localhost:8545"
I'm trying to start Ethereum, so I created my wallet first using metamask and I added to geth using private key with this command.
geth account import private_key.txt
After that I run the mining command using geth --mine, so my question is : am I really mining to my correct wallet ?
OPTION 1:
You can set the account your Ethereum miner mines to by running the following in the geth console:
miner.setEtherbase('yourethaddress')
You can also set a local address to mine to using:
miner.setEtherbase(eth.accounts[2])
Replace '2' with the number of your account.
OPTION 2: When starting your geth node you can use the --etherbase flag.
geth --rpc --etherbase 0xC95767AC46EA2A9162F0734651d6cF17e5BfcF10
Using your ETH public address.
More information here: https://geth.ethereum.org/docs/interface/mining
We're using web3 to connect to the rinkeby test ethereum network. When doing so through geth, via localhost, with the below web3 command:
var web3 = new Web3('http://localhost:8545');
We don't get any errors. We use this command to start geth:
geth --rinkeby --rpc --rpcapi="personal,eth,network,web3,net" --ipcpath "~/Library/Ethereum/geth.ipc"
However when we try using the rinkeby test network directly:
var web3 = new Web3('https://rinkeby.infura.io/');
We get this error:
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (errors.js:42)
at XMLHttpRequest.request.onreadystatechange (index.js:73)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:546)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:387)
at XMLHttpRequest.js:493
at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
at MessageQueue.__callFunction (MessageQueue.js:353)
at MessageQueue.js:118
at MessageQueue.__guardSafe (MessageQueue.js:316)
Most of the operations work on both networks, but .send() calls fail when connecting to the rinkeby network directly.
We think it's an issue with authentication, since other commands succeed that don't perform transactions. However, we tried using the HDWalletProvider and none of our accounts created via geth have mnemonics.
Any advice or troubleshooting steps would be appreciated. Thanks
Transactions have to be signed. When you send a transaction via your local geth node, it knows the private key corresponding to the address you're sending from, so it can sign the transaction for you (once you unlock the account).
A public node like Infura (fortunately!) doesn't know your private key, so it can't sign transactions for you. You'll need to sign them locally and then send them using sendSignedTransaction.