- #1087
ac3b7eab
Thanks @jxom! - Append errors fromaggregate3
to return results ifallowFailure=true
instead of throwing an error.
- #1072
edf264f3
Thanks @linchengzzz! - Added Linea chain.
- #1058
533b5900
Thanks @jxom! - AddedprepareTransactionRequest
,signTransaction
, andsendRawTransaction
.
- #1044
3daedbf5
Thanks @jxom! - AddedestimateFeesPerGas
&baseFeeMultiplier
to the Chain Fees configuration (chain.fees
).
- #1035
7981fa99
Thanks @aaronmgdr! - AddedparseTransactionCelo
to theviem/chains/utils
entrypoint.
- #1040
1e5bd4a0
Thanks @jxom! - Madevalue
optional onwriteContract
/simulateContract
forpayable
functions.
- #1022
2eb56bc7
Thanks @Songkeys! - Fixed an issue wherewaitForTransactionReceipt
would be infinitely pending when an error is thrown after a transaction has been replaced.
- #1013
dd1e1028
Thanks @avasisht23! - AddedEIP1193EventMap
type.
- #984
e1032c7b
Thanks @holic! - AddedsignTransaction
&privateKeyToAddress
exports toviem/accounts
entrypoint.
-
#1006
7311e201
Thanks @jxom! - Addedfees
tochain
config that includes adefaultPriorityFee
for setting a default priority fee (maxPriorityFeePerGas
) for a chain.import type { Chain } from 'viem' export const example = { // ... fees: { defaultPriorityFee: 1_000_000n, // 0.001 gwei // or async defaultPriorityFee() { // ... some async behavior to derive the fee. } }, // ... } as const satifies Chain
- #886
fef66bfb
Thanks @jxom! - Added formatter for Optimism transaction receipts (formatl1GasPrice
,l1GasUsed
, etc).
-
#886
fef66bfb
Thanks @jxom! - Added entrypoints for chain utilities (viem/chains/utils
) with exports for chain-specific chains, formatters, serializers, and types.Examples:
import { type CeloBlock, type CeloTransaction, type OptimismBlock, type OptimismTransaction, serializeTransactionCelo, } from 'viem/chains/utils'
- #1008
9d93953f
Thanks @holic! - Added"already known"
as a node message matcher toNonceTooLowError
.
- #999
de94d81f
Thanks @jxom! - Support passinggasPrice
for chains that includebaseFeePerGas
but do not support EIP-1559 Transactions (e.g. BSC).
- #974
11410bab
Thanks @jxom! - Fixed issue wheregetFunctionSelector
&getEventSelector
were returning incorrect selectors for tuple parameters.
- #954
e98e2651
Thanks @jaxernst! - Added filter reinitialization logic forwatchContractEvent
andwatchEvent
for when a filter has been uninstalled.
- #967
eb8954a0
Thanks @Zil-B! - Moved@types/ws
into dependencies to fix an issue where required runtime types weren't being exported.
-
#847
1e5d4545
Thanks @jxom! - NarrowedgetBlock
,watchBlocks
,getFilterChanges
,getFilterLogs
&getLogs
return types for whenblockTag
orincludeTransactions
is provided.- When
blockTag !== 'pending'
, the return type will now include some non-nullish properties if it were dependent on pending blocks. Example: ForgetBlock
, theblock.number
type is now non-nullish sinceblockTag !== 'pending'
. - On the other hand, when
blockTag: 'pending'
, some properties will be nullish. Example: ForgetBlock
, theblock.number
type is nownull
sinceblockTag === 'pending'
. - When
includeTransactions
is provided, the return type of will narrow thetransactions
property type. Example:block.transactions
will beTransaction[]
whenincludeTransactions: true
instead ofHash[] | Transaction[]
.
TLDR;
// Before const block = publicClient.getBlock({ includeTransactions: true }); block.transactions; // ^? Hash[] | Transaction[] block.transactions[0].blockNumber; // ^? bigint | null // After const block = publicClient.getBlock({ includeTransactions: true }); block.transactions; // ^? Transaction[] block.transactions[0].blockNumber; // ^? bigint // Before const block = publicClient.getBlock({ blockTag: "pending", includeTransactions: true }); block.number; // ^? number | null block.transactions[0].blockNumber; // ^? bigint | null // After const block = publicClient.getBlock({ blockTag: "pending", includeTransactions: true }); block.number; // ^? null block.transactions[0].blockNumber; // ^? null
- When
-
#847
1e5d4545
Thanks @jxom! - Type Change:TPending
has been added to slot 2 of theLog
generics.type Log< TQuantity = bigint, TIndex = number, + TPending extends boolean = boolean, TAbiEvent extends AbiEvent | undefined = undefined, TStrict extends boolean | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined, >
-
#951
c75d3b60
Thanks @jxom! - Added support for multipleevents
on Filters/Log Actions:createEventFilter
getLogs
watchEvent
Example:
import { parseAbi } from "viem"; import { publicClient } from "./client"; const logs = publicClient.getLogs({ events: parseAbi([ "event Approval(address indexed owner, address indexed sender, uint256 value)", "event Transfer(address indexed from, address indexed to, uint256 value)" ]) });
-
#847
1e5d4545
Thanks @jxom! - Type Change:TIncludeTransactions
&TBlockTag
has been added to slot 1 & 2 of theBlock
generics.type Block< TQuantity = bigint, + TIncludeTransactions extends boolean = boolean, + TBlockTag extends BlockTag = BlockTag, TTransaction = Transaction< bigint, number, TBlockTag extends 'pending' ? true : false >, >
- #941
12c685a1
Thanks @jxom! - Capture error signatures that do not exist on the ABI inContractFunctionRevertedError
.
- #942
e26e356c
Thanks @alexfertel! - DeprecatedOnLogParameter
&OnLogFn
in favor ofWatchEventOnLogParameter
&WatchEventOnLogFn
types. AddedWatchContractEventOnLogParameter
&WatchContractEventOnLogFn
types.
789592dc
Thanks @jxom! - Fixed an issue where callingencodePacked
with an emptybytes[]
array would return anUint8Array
instead ofHex
value.
- #922
71c9c933
Thanks @mikemcdonald! - Fixed an issue whereparseUnits
would throwCannot convert to a BigInt
for large numbers with a fraction component.
- #878
4e227303
Thanks @salieflewis! - ExportedFilter
type.
- #907
319cdb61
Thanks @Raiden1411! - Updatedabitype
to 0.9.3
- #874
a9bc9f6d
Thanks @Alexsey! - FixedBaseError.walk
to returnnull
if the predicate callback is not satisfied.
- #864
b851c41b
Thanks @jxom! - Fixed an issue wheredataSuffix
was not being provided to therequest
returned fromsimulateTransaction
.
- #853
a955007e
Thanks @johngrantuk! - Allow using EIP-1559 transactions on chains with 0 base fee.
d24e5bc4
Thanks @jxom! - Fixed a race condition inwaitForTransactionReceipt
causing multiple parallel instances to not resolve.
- #755
064cc09e
Thanks @aaronmgdr! - Added serializer for Celo CIP-42 transactions.
- #791
98fd9172
Thanks @jxom! - Implemented ability to "extend" Clients viaclient.extend
& refactored Actions to accept a tree-shakable Client.
- #691
6e65789f
Thanks @aaronmgdr! - Added custom chain serializers viachain.serializers
.
90fd40ba
Thanks @jxom! - Fixed potential nullishchainId
conflict insendTransaction
(for Local Accounts).
- #672
e033f467
Thanks @sambacha! - Turned offesModuleInterop
&allowSyntheticDefaultImports
in tsconfig.
- #677
a0a2ebb
Thanks @hexcowboy! - Added ability to pass anAbiFunction
togetFunctionSelector
, andAbiEvent
togetEventSelector
.
- #576
7d42767
Thanks @jxom! - Breaking (edge case):decodeEventLog
no longer attempts to partially decode events. If the log does not conform to the ABI (mismatch between the number of indexed/non-indexed arguments to topics/data), it will throw an error.
- #576
7d42767
Thanks @jxom! - Breaking:logIndex
&transactionIndex
onLog
now return anumber
instead of abigint
-
#576
7d42767
Thanks @jxom! - Breaking: RemovedethersWalletToAccount
adapter.This adapter was introduced when viem did not have Private Key & HD Accounts. Since 0.2, viem provides all the utilities needed to create and import Private Key & HD Accounts.
If you still need it, you can copy + paste the old implementation.
- #657
af48368
Thanks @izayl! - FixedgetAbiItem
from returning mismatched type when overload with different lengths.
- #576
7d42767
Thanks @jxom! - Added support for labels larger than 255 bytes when resolving ENS names.
-
#576
7d42767
Thanks @jxom! - Added astrict
parameter togetLogs
,createEventFilter
&createContractEventFilter
.When
strict
mode is turned on, only logs that conform to the indexed/non-indexed arguments on the event definition/ABI (event
) will be returned. Whenstrict
mode is turned off (default), logs that do not conform to the indexed/non-indexed arguments on the event definition/ABI (event
) will be included, but theargs
property will beundefined
(as we cannot decode these events).
-
#610
06ee89c5
Thanks @jxom! - Added ability to hash data representation ofmessage
via araw
attribute insignMessage
,verifyMessage
,recoverMessageAddress
.await walletClient.signMessage({ message: { raw: "0x68656c6c6f20776f726c64" } });
- #619
73c7f498
Thanks @sakulstra! - Addedaddress
andabi
properties to Contract Instances.
- #598
baea299
Thanks @iuriiiurevich! - Fixed an issue inwithCache
where the promise cache would not clear upon rejection.
- #560
a5dd3c6
Thanks @Volchunovich! - Fixed docs links
0cb8f31
Thanks @jxom! - Fixed an issue wherewatchContractEvent
would throw a serialize error for bigint args.
- #540
0d8f154
Thanks @jxom! - Added proxy packages to support bundlers that are not compatible withpackage.json#exports
.
- #527
840d3d7
Thanks @jxom! - Fixedtrim
to trim trailing zero byte data instead of all trailing zeros.
- #475
64a2f51
Thanks @jxom! - Fixed `hashMessage` string conversion for messages that have same format as hex bytes.
- #470
be9501e
Thanks @jxom! - Fixed issue wherewaitForTransactionReceipt
would throw immediately for RPC Providers which may be slow to sync mined transactions.
- #320
6d6d092
Thanks @janek26! - Added support for Contract Wallet signature verification (EIP-6492) viapublicClient.verifyMessage
&publicClient.verifyTypedData
.
- #448
29cf036
Thanks @jxom! - Refactored inferred types onLog
(eventName, args, topics),getLogs
,getFilterLogs
&getFilterChanges
.
- #435
711cf94
Thanks @Raiden1411! - Updatedabitype
to0.8.2
and exported abitype errors.
- #445
9e096a9
Thanks @jxom! - Made "name" parameter (eventName
,functionName
, etc) optional on contract encoding/decoding utilities when only one ABI item is provided.
- #443
ca0cb85
Thanks @jxom! - Fixed eth_call & eth_estimateGas calls for nodes that conform to the older JSON-RPC spec.
- #436
72ed656
Thanks @jxom! - Fixed an issue wheremulticall
's return type was incorrectly flattening whenallowFailure: false
.
- #398
cbb4f1f
Thanks @jxom! - Added a newbatchSize
parameter tomulticall
which limits the size of each calldata chunk.
- #383
7e9731c
Thanks @Raiden1411! - Fixed an issue whereserializeTransaction
was incorrectly encoding zero-ish properties.
- #365
f4dcc33
Thanks @fubhy! - FixedgetAbiItem
to not use a generic type variable for the return type
- #355
b1acfc9
Thanks @jxom! - Breaking: RenamedRequestError
toRpcError
. Breaking: RemovedRpcRequestError
– useRpcError
instead. Breaking: RenamedRpcError
toRpcRequestError
.
-
#355
b1acfc9
Thanks @jxom! - AddedProviderRpcError
subclass.Added EIP-1193
UnauthorizedProviderError
,UnsupportedProviderMethodError
,ProviderDisconnectedError
, andChainDisconnectedError
.
- #349
b275811
Thanks @jxom! - Fixed an issue where Filter querying (eth_getFilterChanges
, etc) was not being scoped to the Transport that created the Filter.
- #343
579171d
Thanks @fubhy! - Fixed conditional types for poll options onwatchBlocks
&watchPendingTransactions
.
- #328
ee87fe7
Thanks @jxom! - Tweaked error inheritence forUserRejectedRequestError
&SwitchChainError
to be more friendly with custom errors.
- #326
c83616a
Thanks @jxom! - Fixed an issue where filtered logs that do not conform to the provided ABI would causegetLogs
,getFilterLogs
orgetFilterChanges
to throw – these logs are now skipped. See #323 for more info.
- #310
6dfc225
Thanks @jxom! - MadeGetValue
return{ value?: never }
instead ofunknown
for contract functions that are not payable.
- #304
8e1b712
Thanks @fubhy! - FixedgetTransactionType
to honorundefined
EIP-1559, EIP-2930 or Legacy attributes.
- #293
859352c
Thanks @TateB! - Fixed ENS address resolution for when resolver returns with a null address, or resolvers that do not supportaddr
.getEnsAddress
returnsnull
for these cases.
0.2.0 – Migration Guide
-
#229
098f342
Thanks @jxom! - Breaking: Removed thegetAccount
function.For JSON-RPC Accounts, use the address itself.
import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const address = '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2' const client = createWalletClient({ - account: getAccount(address), + account: address, chain: mainnet, transport: custom(window.ethereum) })
For Ethers Wallet Adapter, use
ethersWalletToAccount
.If you were using the Ethers Wallet adapter, you can use the
ethersWalletToAccount
function.Note: viem 0.2.0 now has a Private Key & Mnemonic Account implementation. You probably do not need this adapter anymore. This adapter may be removed in a future version.
import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' - import { getAccount } from 'viem/ethers' + import { ethersWalletToAccount } from 'viem/ethers' import { Wallet } from 'ethers' - const account = getAccount(new Wallet('0x...')) + const account = ethersWalletToAccount(new Wallet('0x...')) const client = createWalletClient({ account, chain: mainnet, transport: custom(window.ethereum) })
For Local Accounts, use
toAccount
.- import { createWalletClient, http, getAccount } from 'viem' + import { createWalletClient, http } from 'viem' + import { toAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' import { getAddress, signMessage, signTransaction } from './sign-utils' const privateKey = '0x...' - const account = getAccount({ + const account = toAccount({ address: getAddress(privateKey), signMessage(message) { return signMessage(message, privateKey) }, signTransaction(transaction) { return signTransaction(transaction, privateKey) }, signTypedData(typedData) { return signTypedData(typedData, privateKey) } }) const client = createWalletClient({ account, chain: mainnet, transport: http() })
-
#229
098f342
Thanks @jxom! - Breaking: RemovedassertChain
argument onsendTransaction
,writeContract
&deployContract
. If you wish to bypass the chain check (not recommended unless for testing purposes), you can passchain: null
.await walletClient.sendTransaction({ - assertChain: false, + chain: null, ... })
-
#229
098f342
Thanks @jxom! - Breaking: A chain is now required for thesendTransaction
,writeContract
,deployContract
Actions.You can hoist the Chain on the Client:
import { createWalletClient, custom, getAccount } from 'viem' import { mainnet } from 'viem/chains' export const walletClient = createWalletClient({ + chain: mainnet, transport: custom(window.ethereum) }) const account = getAccount('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266') const hash = await walletClient.sendTransaction({ account, to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n })
Alternatively, you can pass the Chain directly to the Action:
import { createWalletClient, custom, getAccount } from 'viem' import { mainnet } from 'viem/chains' export const walletClient = createWalletClient({ - chain: mainnet, transport: custom(window.ethereum) }) const account = getAccount('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266') const hash = await walletClient.sendTransaction({ account, + chain: mainnet, to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n })
-
#229
098f342
Thanks @jxom! - Breaking: Updated utility type names to reflect their purposes:ExtractErrorNameFromAbi
is nowInferErrorName
ExtractEventNameFromAbi
is nowInferEventName
ExtractFunctionNameFromAbi
is nowInferFunctionName
ExtractItemNameFromAbi
is nowInferItemName
ExtractConstructorArgsFromAbi
is nowGetConstructorArgs
ExtractErrorArgsFromAbi
is nowGetErrorArgs
ExtractEventArgsFromAbi
is nowGetEventArgs
ExtractEventArgsFromTopics
is nowGetEventArgsFromTopics
ExtractArgsFromAbi
is nowGetFunctionArgs
-
#229
098f342
Thanks @jxom! - Breaking: The following functions are nowasync
functions instead of synchronous functions:recoverAddress
recoverMessageAddress
verifyMessage
import { recoverMessageAddress } from 'viem' - recoverMessageAddress({ message: 'hello world', signature: '0x...' }) + await recoverMessageAddress({ message: 'hello world', signature: '0x...' })
-
#229
098f342
Thanks @jxom! - Added Local Account implementations:privateKeyToAccount
mnemonicToAccount
hdKeyToAccount
If you were previously relying on the
viem/ethers
wallet adapter, you no longer need to use this.- import { Wallet } from 'ethers' - import { getAccount } from 'viem/ethers' + import { privateKeyToAccount } from 'viem/accounts' const privateKey = '0x...' - const account = getAccount(new Wallet(privateKey)) + const account = privateKeyToAccount(privateKey) const client = createWalletClient({ account, chain: mainnet, transport: http() })
- #229
098f342
Thanks @jxom! - Added WebSocketeth_subscribe
supportwatchBlocks
,watchBlockNumber
, andwatchPendingTransactions
.
-
#229
098f342
Thanks @jxom! - Added the ability to hoist an Account to the Wallet Client.import { createWalletClient, http } from 'viem' import { mainnnet } from 'viem/chains' const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' }) const client = createWalletClient({ + account, chain: mainnet, transport: http() }) const hash = await client.sendTransaction({ - account, to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', value: parseEther('0.001') })
93e402d
Thanks @jxom! - Fixed adecodeAbiParameters
case where static arrays with a dynamic child would consume the size of the child instead of 32 bytes.
- #263
53fda1a
Thanks @fubhy! - Fixed issue where ABIs with constructors would throw fordecodeFunctionData
.
- #223
2e9c000
Thanks @jxom! - Added an assertion insendTransaction
&writeContract
to check that the client chain matches the wallet's current chain.
- #220
9a80fca
Thanks @jxom! - Fixed an issue wherewatchEvent
would not emit events on missed blocks for thegetLogs
fallback.
- #207
8e5768f
Thanks @jxom! - Added assertion inwatchBlocks
andwatchBlockNumber
to check that the next block number is higher than the previously seen block number.
- #209
ae3e0b6
Thanks @jxom! - AddedverifyMessage
,recoverAddress
,recoverMessageAddress
, andhashMessage
.
- #205
36fa97a
Thanks @jxom! - Added an assertion to check for existence of an event signature ontopics
fordecodeEventLog
- #198
e805e7e
Thanks @wighawag! - Added an assertion indecodeEventLog
to check for a mismatch between topics + indexed event parameters.
36c908c
Thanks @jxom! - Fixed an issue where empty strings were not being decoded properly indecodeAbiParameters
.
- #159
574ae22
Thanks @jxom! - Fixed issue where decoding error logs would break if constructor was in ABI.
- #141
450b612
Thanks @unholypanda! - FixedcreatePublicClient
to includegetTransactionCount
-
#139
304a436
Thanks @jxom! - Added the following chains:baseGoerli
boba
filecoinCalibration
flare
flareTestnet
harmonyOne
moonbaseAlpha
moonbeam
moonriver
okc
polygonZkEvmTestnet
shardeumSphinx
songbird
songbirdTestnet
telos
telosTestnet
zhejiang
-
#100
6bb8ce4
Thanks @jxom! - Breaking: RenamedrequestAccounts
Wallet Action torequestAddresses
Breaking: Renamed
getAccounts
Wallet Action togetAddresses
-
#100
6bb8ce4
Thanks @jxom! - Breaking: Thefrom
argument has been removed from Actions in favour ofaccount
to distinguish between Account types:+ import { getAccount } from 'viem' const [address] = await walletClient.requestAddresses() + const account = getAccount(address) const hash = await walletClient.sendTransaction({ - from: address, + account, to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n })
Affected actions:
call
estimateGas
sendTransaction
signMessage
estimateContractGas
multicall
readContract
simulateContract
writeContract
057e01e
Thanks @jxom! - -testClient.getTxPoolContent
→testClient.getTxpoolContent
testClient.getTxPoolStatus
→testClient.getTxpoolStatus
-
#85
2350d1a
Thanks @jxom! - Breaking: RenamedencodeAbi
&decodeAbi
toencodeAbiParameters
&decodeAbiParameters
, and modified API from named arguments to inplace arguments:import { - encodeAbi, - decodeAbi, + encodeAbiParameters, + decodeAbiParameters, } from 'viem' -const result = encodeAbi({ params, values }) +const result = encodeAbiParameters(params, values) -const result = decodeAbi({ params, data }) +const result = decodeAbiParameters(params, data)
1971e6a
Thanks @jxom! - Added assertion to check if addresses are valid forsendTransaction
,estimateGas
&call
.
- #91
0ac32c2
Thanks @jxom! - Breaking: RenamedgetFunctionSignature
andgetEventSignature
togetFunctionSelector
andgetEventSelector
.
- #81
eb572b0
Thanks @jxom! - Improved transaction & contract error messaging & coalesce error messages from nodes.
8ef068b
Thanks @jxom! - Added502
,503
and504
error codes as "non-deterministic" errors forfallback
transport & retries.
-
#77
d6a29f5
Thanks @jxom! - Decorated Clients with their respective Actions.Example:
import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' -import { getBlockNumber } from 'viem/public' const client = createPublicClient({ chain: mainnet, transport: http(), }) - const blockNumber = await getBlockNumber(client) + const blockNumber = await client.getBlockNumber()
Breaking: Renamed encoding utils.
encodeBytes
/decodeBytes
→toBytes
/fromBytes
encodeHex
/decodeHex
→toHex
/fromHex
encodeRlp
/decodeRlp
→toRlp
/fromRlp
-
#68
1be77b3
Thanks @jxom! - Breaking: Removed all public/wallet/test actions & utils from theviem
entrypoint to their respective entrypoints:viem
= Clients & Transport exportsviem/chains
= Chains exportsviem/contract
= Contract Actions & Utils exportsviem/ens
= ENS Actions & Utils exportsviem/public
= Public Actions exportsviem/test
= Test Actions exportsviem/utils
= Utils exportsviem/wallet
= Wallet Actions exports
- #56
3e90197
Thanks @jxom! - - Breaking: RenamedhumanMessage
toshortMessage
inBaseError
.- Added
multicall
. - Support overloaded contract functions.
- Added
5a6bdf8
Thanks @jxom! - Fixed an issue whereencodeAbi
couldn't encode dynamic bytes larger than 32 bytes"
a74d643
Thanks @jxom! - Breaking: Removed theviem/actions
export in favor ofviem/public
,viem/test
&viem/wallet
exports.
43700d9
Thanks @jxom! - Fixed issue where preinstall/postinstall scripts were being published to NPM.