Metamask is not showing the ethereum address balance on local geth instance - ethereum

Steps to reproduce:
Start local geth node with following command: geth --rinkeby
--rpc --rpcaddr "127.0.0.1"
Connect metamask chrome extension to http://localhost:8545
Create a new ethereum account, ABC, on metamask
New account is visible on https://rinkeby.etherscan.io
Transfer some ethereum to ABC on rinkeby network
On Metamask, we can see ABC balance is increased on rinkeby network
However, we see ABC balance as zero, no change on localhost:8545
We checked the block number on local instance of geth, it is greater than the transaction block, so this means new block is downloaded to local instance of geth.
We couldnot figure out why Metamask is still showing the balance 0 when it is connected to localhost:8545. Your helps are appreciated.
Etherscan image
Block image
Metamask image
Metamask error image

Related

Waiting for enough suitable peers before syncing

I am running an ethereum node on Windows 11. I am using Geth for my execution client along with Prysm for my consensus client. They have been syncing for the past two days but no data is being written to my hard drive by Geth and no progress is being made towards a working ethereum node.
I installed Geth through the download page.
I installed Prysm with this command in an administrative Git Bash in the Prysm directory;
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.bat --output prysm.bat
I run both Geth and Prysm in separate administrative command prompts.
This is the command I use to start Geth;
geth --datadir D:\ethereum --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret jwt.hex
This is the command I use to start Prysm;
prysm.bat beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=jwt.hex --suggested-fee-recipient=0x01234567722E6b0000012BFEBf6177F1D2e9758D9
I always start Prysm after starting Geth.
My Geth terminal repeats the message "Beacon client online, but never received consensus updates. Please ensure your client is operational to follow the chain"
My Prysm terminal commonly displays messages such as
←[90m[2023-01-17 20:30:44]←[0m ←[32m INFO←[0m←[36m initial-sync:←[0m Waiting for enough suitable peers before syncing ←[32mrequired←[0m=3 ←[32msuitable←[0m=0
Below are screenshots of my Geth and Prysm terminals.
Geth terminal
Prysm terminal
Why is Geth not writing any data? My friend who has a working node says it should write about 800gb.
If your node does not find any peers in the peer-to-peer network, it cannot download any data and sync.
This is usually a sign of a local network issue. Make sure your node has a public IP address or has properly exposed ports to Internet. Preferably any computer in Internet should be able to connect to your computer running Prysm.
See the documentation here.

unable to add localhost network to metamask in Ethereum Block Chain

I have no localhost network in metamask and now I want to to add my own localhost network, but it gives me error. Kindly help me in this.
Try with RPC URL: http://localhost:8545/
And of course you have to run the node on your local machine.

How to prefund a hardhat local node address

On spinning up a hardhat node locally, I get 10 addresses pre funded with 10k ETH. But none of these show up on metamask when I connect it to localhost:8545. As a result I'm not able to interact with a dapp deployed locally
Am I doing something wrong?
Usually, the back-end development project provides funded accounts which you can enter into Metamask, It's not like the Goerli or (now defunct) Rinkeby test networks where you can visit a site and have some ETH added to your test account because those test networks are hosted. You need to spin up a local project and have it provide funded accounts.
Such an example is Lesson 9: Hardhat Smart Contract Lottery in (Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript by Free Code Camp)
here is the code ...
https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc
If you run that project it generates a number of addresses which you can connect to in Metamask.
MetaMask has no way of knowing which of your local accounts you want to import, or which are funded (prior to the import).
So you need to import the accounts to MetaMask manually using the private keys provided by Hardhat.

Ethereum wallet shows it has ethers but geth does not show the balance

I am starting to learn ethereum. I have downloaded the Ethereum Wallet, created two accounts and using Rinkeby faucet I got 3 ethers in one of the account. I can see the balance in my wallet. I then ran geth --testnet --datadir d:\data and it started syncing. I let it run for a day and now it slowly adds new blocks. I started another get console and attached it to get.ipc. On the console, I did:
eth.accounts
I see both the accounts in my wallet with first account set as coinbase. But when I ran
eth.getBalance(accounts[0])
I get 0 balance. What might be something I might have overlooked? Thanks in advance
connect to Rinkeby faucet using metamask chrome extension. Provide your account details there you can check that you received ether or not.
It will show you the balance once it has completed syncing. For me it took more than one day to sync, then I could see the account balance properly.
Try eth.syncing to check the status and if eth.blockNumber gives 0 as output that means syncing hasn't finished yet.

Remix Ethereum where goes the contract?

I don't understand where actually the smart contract goes, when I click on create under remix.ethereum.org. If I choose for example the Injected Web3, this should publish the contract to the ropsten test net, right? But how can I access the contract then? When I use metamask it injects me the right provider when I use web3.js, but how can I find this contract now, if I don't want to use the injected web3, but manually choose the provider address in web3.js? Can I access the smart contract this way?
Edit: I don't know what should be wrong about my question.I seriously find nothing about how how to connect to a smart contract for example in the ropsten test network without injected web3. Normally you do this in web3.js:
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
}
But if you don't have an injected web3, then you use the localhost. But I cannot connect then to the smart contract, because it does not know, in which net I actually published the smart contract, right?
Remix has 3 different environment options that can be used to deploy/test Solidity contracts: JavaScript VM, Injected Web3, and Web3 Provider. This option can be changed under the Environment drop down under the Run tab. (It looks like you've got this part...just documenting for completeness).
JavaScript VM: This is Remix's own internal sandbox. It does not connect to MainNet, TestNet, or any private network. It's an in-memory blockchain that can be used for simple testing and quick mining.
Injected Web3: This is the option to use for the browser plugin (MetaMask). Here, you are telling Remix to defer all control of the blockchain integration to the MetaMask plugin. At this point, MetaMask controls which network you are connecting to. In the plugin, you can connect to MainNet, Ropsten, Rinkeby, etc through Infura's node network. In this case, you're not running a node locally. MetaMask also has a localhost option where you can run your own node locally and MetaMask will send all transactions to it (this local network can be a private network using any node client or you can use a test blockchain like TestRPC).
Web3 Provider: This allows you to enter a URL in Remix to connect to the blockchain. The most common setup here is to be running a local node and connecting to it through it's IP/port. This is pretty much the same as using MetaMask's localhost option, but you're just cutting the plugin out of being the middleman. Just like option #2, the network your connected to depends on how you've configured your local node (it can be main, test, private, etc.).
So, "where your smart contract goes" depends on which of the configurations you have set up. Selecting Injected Web3 does not automatically mean your contract is being deployed to Ropsten. It depends on which network you have selected in the MetaMask plugin.
When using MetaMask through Remix, you need to use the plugin to select the appropriate account and confirm/reject transactions. Selecting the account is a bit confusing because Remix doesn't pick up all of the accounts imported into MetaMask. The Account dropdown will only have the account currently selected in MetaMask. In addition, if you change the account in MetaMask, you have to reload Remix for it to have that account selected in the dropdown. It does NOT automatically detect when the account has changed in MetaMask.
Once the account is properly selected (and assuming you're using an account that holds ether), you can now deploy your contract. Hit Create in Remix and then switch over to the plugin again. There, you should see a pending transaction waiting to approved. Select the transaction, then click Submit.
Transaction list:
Approve/Reject screen:
After submitting, it'll take a few seconds for the transaction to be mined. MetaMask will show when it's completed. That's it! To interact with the contract, you can initiate your transactions through Remix similar to the deployment steps above.