Check existing issues
Viem Version
2.46.1
Current Behavior
// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
// 2. Set up your client with a desired chain & transport.
const client = createPublicClient({
chain: mainnet,
transport: http('http://localhost:8545'),
});
const start = async () => {
const blockNumber = await client.getBlockNumber();
const block = await client.getBlock({ blockNumber });
const balance = await client.getBalance({
address: '0x8D97689C9818892B700e27F316cc3E41e17fBeb9',
blockTag: { blockHash: block.hash } // <<- type error
});
console.log(blockNumber, block.hash, balance);
};
start().catch((e) => console.error(e));
Expected Behavior
// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
// 2. Set up your client with a desired chain & transport.
const client = createPublicClient({
chain: mainnet,
transport: http('http://localhost:8545'),
});
const start = async () => {
const blockNumber = await client.getBlockNumber();
const block = await client.getBlock({ blockNumber });
const balance = await client.getBalance({
address: '0x8D97689C9818892B700e27F316cc3E41e17fBeb9',
blockTag: { blockHash: block.hash } // this should be possible with EIP-1898
});
console.log(blockNumber, block.hash, balance);
};
start().catch((e) => console.error(e));
Steps To Reproduce
No response
Link to Minimal Reproducible Example
No response
Anything else?
This EIP (https://eips.ethereum.org/EIPS/eip-1898) has support in all major clients and RPC services.
Please take a look: #3165 and #4186
Check existing issues
Viem Version
2.46.1
Current Behavior
Expected Behavior
Steps To Reproduce
No response
Link to Minimal Reproducible Example
No response
Anything else?
This EIP (https://eips.ethereum.org/EIPS/eip-1898) has support in all major clients and RPC services.
Please take a look: #3165 and #4186