Search code examples
blockchainethereumgethtether

Geth getting 0 tether on local getBalance()


I face the problem of getting a balance of erc-20 on local accounts.

> eth.accounts
["0x6c197808a849b9157422ed33d821e8e6e29ad8f8", "0x6e062dc98a5e4d7e494cb8c4b4d8cf40e8a4d958"]

> eth.coinbase
"0x6c197808a849b9157422ed33d821e8e6e29ad8f8"

> web3.fromWei(eth.getBalance(eth.coinbase), "tether")
0

> web3.fromWei(eth.getBalance('0x6c197808a849b9157422ed33d821e8e6e29ad8f8'), "tether")
0

> web3.fromWei(eth.getBalance('0x6c197808A849B9157422Ed33d821e8e6E29Ad8F8'), "tether")
0

Etherscan telling me that tokens are already on the address.screenshot

Chain is configured, synced and is on current block.

> eth.syncing
false

And I can see balances on other, not my local, addresses.

> web3.fromWei(eth.getBalance('0xD72D878EC833788a087fD613BDdd9A15Bcb6eF2d'), "tether")
4.4612e-15

System information

Geth version: 1.9.6-stable
OS & Version: Ubuntu 18.04
Git Commit: bd05968077f27f7eb083404dd8448157996a8788
Architecture: amd64
Protocol Versions: [63]
Network Id: 1
Go Version: go1.11.5
Operating System: linux

Solution

  • What you are querying for is not the balance of Tether(USDT), but the balance of ether in Tether unit.

    here is the ref.

    1 Tether = 1012 Ether

    If you want to query the balance of an erc20 token, there is a function called balanceOf in that erc20 smart contract, you can interact with the contract with web3.