0glabs / 0g-chain

The First Modular AI Chain
Apache License 2.0
28 stars 37 forks source link

Discrepancy Account Balance Between Web3 and 0gchaind Queries #45

Closed yingjun-wu closed 1 month ago

yingjun-wu commented 1 month ago

When using localtestnet.sh to set up a local testnet, I encountered an issue where querying the evm-faucet account balance using web3 returns zero balance. However, querying the same account using 0gchaind query bank balances 0g18jz5lyhhy6ncjlyty064kttw93yzaulqxppxhr shows that the account has some balance.

Could you please advise on any solutions to this issue? Thank you!

ethanz0g commented 1 month ago

@yingjun-wu ,

Could you please tell a bit more about how you used web3 to query the evm-faucet account balance?

yingjun-wu commented 1 month ago

@yingjun-wu ,

Could you please tell a bit more about how you used web3 to query the evm-faucet account balance?

Thank you for yours reply! Here is how to check the balance using web3: For 0gchaind to check the balance,

0gchaind query bank balances 0g18jz5lyhhy6ncjlyty064kttw93yzaulqxppxhr
balances:
- amount: "1000000000000000000000"
  denom: neuron
pagination:
  next_key: null
  total: "0"

We can use the 0gchaind tool to convert the Ethereum address corresponding to the 0g18jz5lyhhy6ncjlyty064kttw93yzaulqxppxhr address

0gchaind debug addr 0g18jz5lyhhy6ncjlyty064kttw93yzaulqxppxhr
Address: [60 133 79 146 247 38 167 137 124 139 35 245 91 45 110 44 72 46 243 224]
Address (hex): 3C854F92F726A7897C8B23F55B2D6E2C482EF3E0
Bech32 Acc: 0g18jz5lyhhy6ncjlyty064kttw93yzaulqxppxhr
Bech32 Val: 0gvaloper18jz5lyhhy6ncjlyty064kttw93yzaulq9ts6z7

So when I used the eth_getBalance method of web3 to check the balance, I found it was zero.

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x3C854F92F726A7897C8B23F55B2D6E2C482EF3E0", "latest"],"id":1}' http://localhost:8545

it return,

{"jsonrpc":"2.0","id":1,"result":"0x0"}
ethanz0g commented 1 month ago

What is the version of your 0gchaind?

$ 0gchaind version

yingjun-wu commented 1 month ago

When I execute 0gchaind version, it returns empty and I cannot see the version information. By the way, I compiled it based on the master branch.

yingjun-wu commented 1 month ago

When I execute 0gchaind version, it returns empty and I cannot see the version information. By the way, I compiled it based on the master branch.

This issue has been resolved and I will close it. The main reason for this problem is that I was using the master branch to compile, and the problem was solved when I switched to the dev branch.