-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Check existing issues
- I checked there isn't already an issue for the bug I encountered.
Viem Version
2.29.0
Current Behavior
Getting the balance of an account using publicClient.getBalance and blockNumber: 0n returns the balance of the account in the latest block.
Expected Behavior
The balance in the block zero should be returned.
Steps To Reproduce
Start an anvil node and run this script:
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { anvil } from "viem/chains";
const publicClient = createPublicClient({
chain: anvil,
transport: http()
})
const walletClient = createWalletClient({
account: privateKeyToAccount("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"),
chain: anvil,
transport: http()
})
await walletClient.sendTransaction({
to: "0xff000000000000000000000000000000000000ff",
value: 1000n
})
console.log(await publicClient.getBalance({
address: "0xff000000000000000000000000000000000000ff",
blockNumber: 0n,
}))Link to Minimal Reproducible Example
No response
Anything else?
I guess this is a non-strict check that is interpreting 0n as falsy.
Metadata
Metadata
Assignees
Labels
No labels