Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

viem

wevm2.3mMIT2.22.13TypeScript support: included

TypeScript Interface for Ethereum

eth, ethereum, dapps, wallet, web3, typescript

readme


<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/viem/main/.github/gh-logo-dark.svg"> viem logo </picture>

TypeScript Interface for Ethereum

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/viem?colorA=21262d&colorB=21262d&style=flat"> Version </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/codecov/c/github/wevm/viem?colorA=21262d&colorB=21262d&style=flat"> Code coverage </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/l/viem?colorA=21262d&colorB=21262d&style=flat"> MIT License </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/viem?colorA=21262d&colorB=21262d&style=flat"> Downloads per month </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/endpoint?colorA=21262d&colorB=21262d&style=flat&url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=wevm%2Fviem%26since=daily"> Best of JS </picture>


Features

  • Abstractions over the JSON-RPC API to make your life easier
  • First-class APIs for interacting with Smart Contracts
  • Language closely aligned to official Ethereum terminology
  • Import your Browser Extension, WalletConnect or Private Key Wallet
  • Browser native BigInt, instead of large BigNumber libraries
  • Utilities for working with ABIs (encoding/decoding/inspection)
  • TypeScript ready (infer types from ABIs and EIP-712 Typed Data)
  • First-class support for Anvil, Hardhat & Ganache
  • Test suite running against forked Ethereum network

... and a lot more.

Overview

// 1. Import modules.
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

// 2. Set up your client with desired chain & transport.
const client = createPublicClient({
  chain: mainnet,
  transport: http(),
});

// 3. Consume an action!
const blockNumber = await client.getBlockNumber();

Documentation

Head to the documentation to read and learn more about viem.

Community

Check out the following places for more viem-related content:

Support

Sponsors

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/paradigm-dark.svg"> paradigm logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/ithaca-dark.svg"> ithaca logo </picture>
<picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/family-dark.svg"> family logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/context-dark.svg"> context logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/walletconnect-dark.svg"> WalletConnect logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/partydao-dark.svg"> PartyDAO logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/dynamic-dark.svg"> Dynamic logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sushi-dark.svg"> Sushi logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/stripe-dark.svg"> Stripe logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/privy-dark.svg"> Privy logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pancake-dark.svg"> pancake logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/celo-dark.svg"> celo logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/rainbow-dark.svg"> rainbow logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/pimlico-dark.svg"> pimlico logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zora-dark.svg"> zora logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/lattice-dark.svg"> lattice logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/supa-dark.svg"> supa logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/zksync-dark.svg"> ZKsync logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/syndicate-dark.svg"> syndicate logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/reservoir-dark.svg"> reservoir logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/linea-dark.svg"> linea logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/uniswap-dark.svg"> uniswap logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/b0276d897be98a4c94ad1d1c72ce99a1020eeb58/content/sponsors/biconomy-dark.svg"> biconomy logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/thirdweb-dark.svg"> thirdweb logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/polymarket-dark.svg"> polymarket logo </picture> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/routescan-dark.svg"> routescan logo </picture>

Contributing

If you're interested in contributing, please read the contributing docs before submitting a pull request.

Authors

License

MIT License



Powered by Vercel

changelog

viem

2.22.13

Patch Changes

2.22.12

Patch Changes

2.22.11

Patch Changes

2.22.10

Patch Changes

2.22.9

Patch Changes

2.22.8

Patch Changes

2.22.7

Patch Changes

2.22.6

Patch Changes

2.22.5

Patch Changes

2.22.4

Patch Changes

2.22.3

Patch Changes

2.22.2

Patch Changes

2.22.1

Patch Changes

2.22.0

Minor Changes

Patch Changes

2.21.60

Patch Changes

2.21.59

Patch Changes

2.21.58

Patch Changes

2.21.57

Patch Changes

2.21.56

Patch Changes

2.21.55

Patch Changes

2.21.54

Patch Changes

2.21.53

Patch Changes

2.21.52

Patch Changes

2.21.51

Patch Changes

2.21.50

Patch Changes

2.21.49

Patch Changes

2.21.48

Patch Changes

2.21.47

Patch Changes

2.21.46

Patch Changes

2.21.45

Patch Changes

2.21.44

Patch Changes

2.21.43

Patch Changes

2.21.42

Patch Changes

2.21.41

Patch Changes

2.21.40

Patch Changes

2.21.39

Patch Changes

2.21.38

Patch Changes

2.21.37

Patch Changes

2.21.36

Patch Changes

2.21.35

Patch Changes

2.21.34

Patch Changes

2.21.33

Patch Changes

2.21.32

Patch Changes

2.21.31

Patch Changes

2.21.30

Patch Changes

2.21.29

Patch Changes

2.21.28

Patch Changes

2.21.27

Patch Changes

2.21.26

Patch Changes

2.21.25

Patch Changes

2.21.24

Patch Changes

2.21.23

Patch Changes

2.21.22

Patch Changes

2.21.21

Patch Changes

2.21.20

Patch Changes

2.21.19

Patch Changes

2.21.18

Patch Changes

2.21.17

Patch Changes

2.21.16

Patch Changes

2.21.15

Patch Changes

2.21.14

Patch Changes

  • c7c737a4 Thanks @jxom! - Added delegate parameter to signAuthorization.

2.21.13

Patch Changes

2.21.12

Patch Changes

2.21.11

Patch Changes

2.21.10

Patch Changes

2.21.9

Patch Changes

  • 312160a Thanks @jxom! - Fixed issue where watchBlock would not respect the emitOnBegin property for WebSocket Transports.

  • b509c6e Thanks @jxom! - Fixed mnemonicToAccount options type.

2.21.8

Patch Changes

2.21.7

Patch Changes

  • 644f72d Thanks @jxom! - Fixed an issue where hashAuthorization & serializeAuthorizationList did not RLP-serialize zeroish nonces correctly.

  • #2719 7fdb149 Thanks @sammdec! - Added parentBeaconBlockRoot to Block type.

  • #2722 0b5c7b6 Thanks @coffeexcoin! - Added multicall3 contract for Abstract Testnet.

2.21.6

Patch Changes

2.21.5

Patch Changes

2.21.4

Patch Changes

  • 9de10f8 Thanks @jxom! - Account Abstraction: Updated getPaymasterData + getPaymasterStubData return types to match ERC-7677 specification.

  • #2659 24bdc50 Thanks @owen-reorg! - Added OP Stack addresses to opBNB Chain.

  • #2708 6dfadec Thanks @0x-jj! - Updated Shape Sepolia definition.

2.21.3

Patch Changes

2.21.2

Patch Changes

2.21.1

Patch Changes

2.21.0

Minor Changes

  • #2665 2e05c52 Thanks @jxom! - Added built-in support for Linea gas & fee estimations.

  • #2665 2e05c52 Thanks @jxom! - Deprecated chain.fees.defaultPriorityFee, use chain.fees.maxPriorityFeePerGas instead.

Patch Changes

2.20.1

Patch Changes

2.20.0

Minor Changes

  • #2641 89d11ed Thanks @jxom! - Experimental: Deprecated writeContracts. Use sendCalls instead.

  • #2641 89d11ed Thanks @jxom! - Experimental: Updated sendCalls to match the updated EIP-5792 spec (chainId per call).

  • #2641 89d11ed Thanks @jxom! - Experimental: Updated sendCalls to also accept contract function interface.

Patch Changes

  • #2638 9cbd082 Thanks @jxom! - Added `nonceKeyManager` as a property to `toSmartAccount`.

  • #2638 9cbd082 Thanks @jxom! - Added ability to pass full-formed User Operations to sendUserOperation and estimateUserOperationGas.

  • #2639 9a1c6ab Thanks @jxom! - OP Stack: Tweaked proof submitter logic.

2.19.9

Patch Changes

2.19.8

Patch Changes

  • #2631 b36cb2db Thanks @jxom! - OP Stack: Handled case for InvalidGameType error on getWithdrawalStatus

2.19.7

Patch Changes

2.19.6

Patch Changes

2.19.5

Patch Changes

2.19.4

Patch Changes

2.19.3

Patch Changes

2.19.2

Patch Changes

  • d22855b Thanks @jxom! - Exported deploylessCallViaBytecodeBytecode, deploylessCallViaFactoryBytecode, universalSignatureValidatorByteCode.

  • #2593 2aa381d Thanks @zongzheng123! - Added multicall configuration for iotex testnet.

  • 8ef99aa Thanks @jxom! - Experimental: Deprecated soladyActions in favor of erc7739Actions.

  • #2594 4b3c1e6 Thanks @kirillovmr! - Fixed websocket ping request not conforming to jsonrpc schema.

  • a6d087e Thanks @jxom! - Fixed ABI inference on prepareEncodeFunctionData

  • #2589 171ede1 Thanks @venables! - Added multicall to X Layer chain.

2.19.1

Patch Changes

  • 91aafc0 Thanks @jxom! - Added name to ResourceNotFoundRpcErrorType

2.19.0

Minor Changes

  • #2570 fee80a9a Thanks @jxom! - Experimental: Added EIP-7702 Extension. See Docs

  • #2586 0b1693aa Thanks @tmm! - Renamed "zkSync" to "ZKsync":

    • Context: "zkSync" was officially renamed to "ZKsync" a while ago.
    • Variable names: zkSync -> zksync (for simplicity and consistency between folder/file names and variables).
    • Types: ZkSync -> Zksync.
    • Old naming still remains in Viem, however is marked as @deprecated and will be removed in the next major release.

    Removed deprecated zkSyncTestnet chain.

  • #2583 b5aa9651 Thanks @jxom! - Added ability for consumer (libraries built on top of Viem) to globally configure properties on BaseError.

    import { setErrorConfig } from 'viem'
    
    setErrorConfig({
      getDocsUrl({ name }) {
        return `https://examplelib.com?error=${name}`
      }
      version: 'examplelib@1.2.3'
    })

Patch Changes

  • #2581 837507f6 Thanks @cygaar! - Added ZKsync config to Abstract Testnet chain.

  • #2561 1c5d64a3 Thanks @Yuripetusko! - Fixed #2560: infer the correct payable value type on function overloads by matching function against args.

2.18.8

Patch Changes

2.18.7

Patch Changes

2.18.6

Patch Changes

2.18.5

Patch Changes

2.18.4

Patch Changes

  • 5a528d9b Thanks @jxom! - Propagated message + cause to root Error instance.

2.18.3

Patch Changes

2.18.2

Patch Changes

  • #2516 44281e8 Thanks @izayl! - Added keepAlive property to webSocket transport to send keep-alive ping messages (defaults to true).

2.18.1

Patch Changes

2.18.0

Minor Changes

2.17.11

Patch Changes

2.17.10

Patch Changes

2.17.9

Patch Changes

  • b71e656e Thanks @jxom! - Exported types required for inference.

2.17.8

Patch Changes

  • 690cb9a7 Thanks @jxom! - Exported types required for inference.

2.17.7

Patch Changes

  • 7d3d505 Thanks @jxom! - Allow override of Content-Type header on http transport.

2.17.6

Patch Changes

  • aa42f47 Thanks @jxom! - Updated Darwinia chain explorer URL.

  • 759e34d Thanks @jxom! - Enforced r and s hex values on Signature to be always padded to 32 bytes.

2.17.5

Patch Changes

2.17.4

Patch Changes

2.17.3

Patch Changes

  • ec3b0e0 Thanks @jxom! - Added fallback verification in verifyHash.

2.17.2

Patch Changes

2.17.1

Patch Changes

2.17.0

Minor Changes

  • #2335 3fce1c3 Thanks @aaronmgdr! - Added support for serializing and parsing OP deposit transactions on Celo.

Patch Changes

2.16.5

Patch Changes

2.16.4

Patch Changes

  • #2445 8aa20a1 Thanks @radchukd! - Added lyra chain

  • 62b7a9d Thanks @tmm! - Bumped ABIType version

  • 7e95377 Thanks @jxom! - Bumped dependencies:

    • @noble/curves: 1.2.01.4.0
    • @noble/hashes: 1.3.21.4.0
    • @scure/bip32: 1.3.21.4.0
    • @scure/bip39: 1.2.11.3.0
  • 95753c1 Thanks @jxom! - Added cause in HttpRequestError.

2.16.3

Patch Changes

2.16.2

Patch Changes

2.16.1

Patch Changes

  • fa494359 Thanks @jxom! - Added chainId as a parameter to eth_sendTransaction.

  • #2429 3781bbb8 Thanks @jxom! - Fixed an issue where getAction would ignore nullish return values from a synchronous Client Action.

  • ed5c70e0 Thanks @jxom! - Experimental: Added Solady utilities:

    • hashMessage
    • hashTypedData
    • wrapTypedDataSignature

2.16.0

Minor Changes

  • #2424 4b929790 Thanks @jxom! - Stabilized ERC-6492 utilities:

    • isErc6492Signature
    • parseErc6492Signature
    • serializeErc6492Signature

    These utilities are no longer experimental, and can be imported from the viem entrypoint.

Patch Changes

2.15.1

Patch Changes

2.15.0

Minor Changes

  • #2418 6c36745 Thanks @jxom! - Added support for a Nonce Manager on Local Accounts via nonceManager.

Patch Changes

2.14.2

Patch Changes

2.14.1

Patch Changes

2.14.0

Minor Changes

2.13.10

Patch Changes

2.13.9

Patch Changes

2.13.8

Patch Changes

2.13.7

Patch Changes

2.13.6

Patch Changes

2.13.5

Patch Changes

2.13.4

Patch Changes

2.13.3

Patch Changes

2.13.2

Patch Changes

2.13.1

Patch Changes

2.13.0

Minor Changes

2.12.5

Patch Changes

2.12.4

Patch Changes

2.12.3

Patch Changes

2.12.2

Patch Changes

2.12.1

Patch Changes

2.12.0

Minor Changes

Patch Changes

2.11.1

Patch Changes

2.11.0

Minor Changes

2.10.11

Patch Changes

2.10.10

Patch Changes

2.10.9

Patch Changes

2.10.8

Patch Changes

2.10.7

Patch Changes

2.10.6

Patch Changes

2.10.5

Patch Changes

2.10.4

Patch Changes

2.10.3

Patch Changes

2.10.2

Patch Changes

2.10.1

Patch Changes

2.10.0

Minor Changes

2.9.32

Patch Changes

2.9.31

Patch Changes

2.9.30

Patch Changes

2.9.29

Patch Changes

2.9.28

Patch Changes

2.9.27

Patch Changes

2.9.26

Patch Changes

2.9.25

Patch Changes

2.9.24

Patch Changes

2.9.23

Patch Changes

2.9.22

Patch Changes

2.9.21

Patch Changes

2.9.20

Patch Changes

2.9.19

Patch Changes

2.9.18

Patch Changes

2.9.17

Patch Changes

2.9.16

Patch Changes

2.9.15

Patch Changes

2.9.14

Patch Changes

2.9.13

Patch Changes

2.9.12

Patch Changes

2.9.11

Patch Changes

2.9.10

Patch Changes

2.9.9

Patch Changes

2.9.8

Patch Changes

2.9.7

Patch Changes

2.9.6

Patch Changes

2.9.5

Patch Changes

2.9.4

Patch Changes

2.9.3

Patch Changes

2.9.2

Patch Changes

2.9.1

Patch Changes

2.9.0

Minor Changes

2.8.18

Patch Changes

2.8.17

Patch Changes

2.8.16

Patch Changes

2.8.15

Patch Changes

2.8.14

Patch Changes

2.8.13

Patch Changes

2.8.12

Patch Changes

2.8.11

Patch Changes

2.8.10

Patch Changes

2.8.9

Patch Changes

2.8.8

Patch Changes

2.8.7

Patch Changes

2.8.6

Patch Changes

2.8.5

Patch Changes

2.8.4

Patch Changes

2.8.3

Patch Changes

2.8.2

Patch Changes

2.8.1

Patch Changes

2.8.0

Minor Changes

Patch Changes

2.7.22

Patch Changes

2.7.21

Patch Changes

2.7.20

Patch Changes

2.7.19

Patch Changes

2.7.18

Patch Changes

2.7.17

Patch Changes

2.7.16

Patch Changes

2.7.15

Patch Changes

2.7.14

Patch Changes

2.7.13

Patch Changes

2.7.12

Patch Changes

2.7.11

Patch Changes

2.7.10

Patch Changes

2.7.9

Patch Changes

2.7.8

Patch Changes

2.7.7

Patch Changes

2.7.5

Patch Changes

2.7.4

Patch Changes

2.7.3

Patch Changes

2.7.2

Patch Changes

2.7.1

Patch Changes

2.7.0

Minor Changes

2.6.1

Patch Changes

2.6.0

Minor Changes

Patch Changes

2.5.1

Patch Changes

2.5.0

Minor Changes

2.4.1

Patch Changes

2.4.0

Minor Changes

  • #1716 0b4ee201219fe2fec8d6d33051603776765bed06 Thanks @jxom! - - Added toEventHash.
    • Added toFunctionHash.
    • Deprecated getEventSelector (use toEventSelector).
    • Deprecated getFunctionSelector (use toFunctionSelector).
    • Deprecated getEventSignature (use toEventSignature).
    • Deprecated getFunctionSignature (use toFunctionSignature).

2.3.1

Patch Changes

2.3.0

Minor Changes

Patch Changes

2.2.0

Minor Changes

2.1.1

Patch Changes

2.1.0

Minor Changes

  • 06105dfc Thanks @jxom! - Refactored ABI decoding implementation to use a cursor instead of array copies, and prevent excessive recursive pointers.

Patch Changes

2.0.10

Patch Changes

2.0.9

Patch Changes

2.0.8

Patch Changes

2.0.7

Patch Changes

2.0.6

Patch Changes

2.0.5

Patch Changes

2.0.4

Patch Changes

2.0.3

Patch Changes

  • fdd2435c Thanks @jxom! - Fixed issue where Viem would throw in environments that don't support the WebSocket API.

2.0.2

Patch Changes

2.0.1

Patch Changes

  • 61460900 Thanks @jxom! - Added proxy packages for viem/op-stack, viem/celo, viem/zksync.

  • #1644 95f0c596 Thanks @hbriese! - Fixed formatting of zkSync transaction request with customSignature

2.0.0

Major Changes

1.21.4

Patch Changes

1.21.3

Patch Changes

1.21.2

Patch Changes

1.21.1

Patch Changes

1.21.0

Minor Changes

Patch Changes

1.20.3

Patch Changes

1.20.2

Patch Changes

1.20.1

Patch Changes

1.20.0

Minor Changes

  • #1589 69cf2d05 Thanks @jxom! - Added ripemd160 and sha256 hashing functions (re-exported from @noble/hashes).

1.19.15

Patch Changes

  • #1586 f9bfa727 Thanks @jxom! - Fixed an issue where Viem could extract the wrong ABI item if ambiguity is detected within overload ABI items. Now, if ambiguity is detected, an error will be thrown.

1.19.14

Patch Changes

1.19.13

Patch Changes

  • 007fe124 Thanks @jxom! - Fixed issue where getEnsName was returning stale results for updated eth records.

1.19.12

Patch Changes

1.19.11

Patch Changes

  • 1218e977 Thanks @jxom! - Fixed BlockNotFoundError issue on waitForTransactionReceipt.

1.19.10

Patch Changes

  • #1547 571d9e5e Thanks @darwintree! - Added WebSocket endpoints for Conflux eSpace chain.

  • #1546 f5d1dbea Thanks @TateB! - Fixed an issue where if a CCIP-Read request returned with an undefined body, body.error would still attempt to be read causing an Cannot read properties of undefined error, instead of the status text.

  • #1547 571d9e5e Thanks @darwintree! - Added Conflux eSpace Testnet chain

  • #1541 b3f7c11d Thanks @aefhm! - Added Oasis Sapphire Mainnet and Testnet chains

1.19.9

Patch Changes

1.19.8

Patch Changes

1.19.7

Patch Changes

1.19.6

Patch Changes

1.19.5

Patch Changes

1.19.4

Patch Changes

1.19.3

Patch Changes

  • #1504 bfdaee74 Thanks @jxom! - Fixed an issue where some consumer minifiers (ie. Terser, SWC) would drop Function.prototype.name causing client action overrides to be ignored.

1.19.2

Patch Changes

1.19.1

Patch Changes

1.19.0

Minor Changes

Patch Changes

1.18.9

Patch Changes

  • #1464 32098af0 Thanks @jxom! - Fixed issue where getFunctionSignature/getFunctionSelector would not parse nested tuples in string-based signatures.

1.18.8

Patch Changes

  • 46213902 Thanks @jxom! - Fixed issue where chain.nativeCurrency could be undefined.

1.18.7

Patch Changes

  • 95991301 Thanks @jxom! - Fixed an issue where watchContractEvent fallback was not scoping events to the provided eventName.

  • #1453 e40006aa Thanks @0xRaghu! - Added Kava Testnet chain.

1.18.6

Patch Changes

1.18.5

Patch Changes

1.18.4

Patch Changes

1.18.3

Patch Changes

1.18.2

Patch Changes

1.18.1

Patch Changes

1.18.0

Minor Changes

1.17.2

Patch Changes

1.17.1

Patch Changes

1.17.0

Minor Changes

  • #1382 5ac4a631 Thanks @jxom! - Added ability for Actions (i.e. readContract) to infer their internal/dependant Actions (i.e. call) from the optionally extended Client.

    For instance, if an extended Client has overridden the call Action, then the readContract Action will use that instead of Viem's internal call Action.

Patch Changes

1.16.6

Patch Changes

  • #1356 0da9f886 Thanks @AmaxJ! - Removed trailing slash from arbiscan goerli blockexplorer url

  • 36ec87da Thanks @jxom! - Modified getAddresses to be compatible with Local Accounts.

1.16.5

Patch Changes

1.16.4

Patch Changes

1.16.3

Patch Changes

1.16.2

Patch Changes

1.16.1

Patch Changes

1.16.0

Minor Changes

1.15.5

Patch Changes

1.15.4

Patch Changes

1.15.3

Patch Changes

1.15.2

Patch Changes

1.15.1

Patch Changes

1.15.0

Minor Changes

  • #1260 408ebf49 Thanks @izayl! - Added utilities for EIP-2098 Compact Signatures:
    • compactSignatureToHex,
    • compactSignatureToSignature,
    • hexToCompactSignature,
    • signatureToCompactSignature

Patch Changes

1.14.0

Minor Changes

Patch Changes

1.13.2

Patch Changes

1.13.1

Patch Changes

1.13.0

Minor Changes

Patch Changes

1.12.2

Patch Changes

1.12.1

Patch Changes

1.12.0

Minor Changes

1.11.1

Patch Changes

1.11.0

Minor Changes

Patch Changes

1.10.14

Patch Changes

1.10.13

Patch Changes

1.10.12

Patch Changes

1.10.11

Patch Changes

1.10.10

Patch Changes

  • fa2d8794 Thanks @jxom! - Fixed an issue where waitForTransactionReceipt would throw an error if receipt.blockNumber was undefined.

  • #1194 347b1f40 Thanks @jxom! - Fixed baseFeeMultiplier calculation.

1.10.9

Patch Changes

1.10.8

Patch Changes

  • #1177 8d05e410 Thanks @jxom! - Fixed an issue where some environments would throw WebSocket.default is not a constructor.

1.10.7

Patch Changes

1.10.6

Patch Changes

1.10.5

Patch Changes

  • 8fe2467b Thanks @jxom! - Added estimateFeesPerGas and estimateMaxPriorityFeePerGas exports to viem/actions.

1.10.4

Patch Changes

1.10.3

Patch Changes

1.10.2

Patch Changes

1.10.1

Patch Changes

  • bf2f7ee1 Thanks @jxom! - Updated dependencies:

    • @adraffy/ens-normalize
    • @noble/curves
    • @noble/hashes
    • @scure/bip32
    • @scure/bip39
    • abitype
    • isomorphic-ws
    • ws

1.10.0

Minor Changes

Patch Changes

  • #1137 4159c997 Thanks @jxom! - Fixed an issue where non-standard "user rejected" errors where being coalesced into an UnknownNodeError.

  • 8605c1f1 Thanks @jxom! - Handle -32603 RPC error codes when deriving a ContractFunctionRevertedError.

  • #1109 0a242120 Thanks @jxom! - Removed hardcoded defaultPriorityFee on OP Stack chains in favor of fetching it from eth_maxPriorityFeePerGas.

  • #1112 7da52244 Thanks @RexCloud! - Added multicall3 for Scroll Sepolia

  • #1139 86230caf Thanks @jxom! - Fixed VerifyMessageParameters to accept a raw property.

  • #1138 101c94f2 Thanks @jxom! - Amended Base chain nativeCurreny.name to "Ether".

  • #1048 f33086ef Thanks @brianathere! - Converted isomorphic-ws to a synchronous import.

1.9.5

Patch Changes

1.9.4

Patch Changes

1.9.3

Patch Changes

  • #1087 ac3b7eab Thanks @jxom! - Append errors from aggregate3 to return results if allowFailure=true instead of throwing an error.

1.9.2

Patch Changes

  • 0b0167ef Thanks @jxom! - Fixed PrepareTransactionRequestReturnType type.

1.9.1

Patch Changes

1.9.0

Minor Changes

  • e14eeb3b Thanks @jxom! - Migrated @wagmi/chains into viem and removed the @wagmi/chains dependency.

1.8.1

Patch Changes

1.8.0

Minor Changes

  • #1058 533b5900 Thanks @jxom! - Added prepareTransactionRequest, signTransaction, and sendRawTransaction.

1.7.1

Patch Changes

  • da45ec2d Thanks @jxom! - Deduped block retrieval in estimateMaxPriorityFeePerGas.

1.7.0

Minor Changes

  • #1044 3daedbf5 Thanks @jxom! - Added estimateFeesPerGas & estimateMaxPriorityFeesPerGas Actions.

  • #1044 3daedbf5 Thanks @jxom! - Added estimateFeesPerGas & baseFeeMultiplier to the Chain Fees configuration (chain.fees).

1.6.6

Patch Changes

1.6.5

Patch Changes

  • #1041 fa3353e9 Thanks @jxom! - Fixed WebSocket instantiation in React Native environment.

1.6.4

Patch Changes

  • #1040 1e5bd4a0 Thanks @jxom! - Made value optional on writeContract/simulateContract for payable functions.

  • #1022 2eb56bc7 Thanks @Songkeys! - Fixed an issue where waitForTransactionReceipt would be infinitely pending when an error is thrown after a transaction has been replaced.

1.6.3

Patch Changes

1.6.2

Patch Changes

1.6.1

Patch Changes

1.6.0

Minor Changes

  • #984 e1032c7b Thanks @holic! - Added signTransaction & privateKeyToAddress exports to viem/accounts entrypoint.

  • #1006 7311e201 Thanks @jxom! - Added fees to chain config that includes a defaultPriorityFee 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 (format l1GasPrice, 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";

Patch Changes

1.5.4

Patch Changes

  • #1000 4bdbf15b Thanks @jxom! - Fixed docsPath value in estimateContractGas.

  • #999 de94d81f Thanks @jxom! - Support passing gasPrice for chains that include baseFeePerGas but do not support EIP-1559 Transactions (e.g. BSC).

1.5.3

Patch Changes

  • ae4ab844 Thanks @jxom! - Fixed performance bottleneck in ABI encoding for dynamic bytes.

1.5.2

Patch Changes

  • #974 11410bab Thanks @jxom! - Fixed issue where getFunctionSelector & getEventSelector were returning incorrect selectors for tuple parameters.

1.5.1

Patch Changes

  • #954 e98e2651 Thanks @jaxernst! - Added filter reinitialization logic for watchContractEvent and watchEvent 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.

1.5.0

Minor Changes

  • #847 1e5d4545 Thanks @jxom! - Narrowed getBlock, watchBlocks, getFilterChanges, getFilterLogs & getLogs return types for when blockTag or includeTransactions is provided.

    • When blockTag !== 'pending', the return type will now include some non-nullish properties if it were dependent on pending blocks. Example: For getBlock, the block.number type is now non-nullish since blockTag !== 'pending'.
    • On the other hand, when blockTag: 'pending', some properties will be nullish. Example: For getBlock, the block.number type is now null since blockTag === 'pending'.
    • When includeTransactions is provided, the return type of will narrow the transactions property type. Example: block.transactions will be Transaction[] when includeTransactions: true instead of Hash[] | 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
  • #847 1e5d4545 Thanks @jxom! - Type Change: TPending has been added to slot 2 of the Log 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,
    >
  • #958 f7976fd0 Thanks @jxom! - Added cacheTime as a parameter to getBlockNumber & createClient.

  • 28a82125 Thanks @jxom! - Exported number constants (ie. maxInt128, maxUint256, etc).

  • #951 c75d3b60 Thanks @jxom! - Added support for multiple events 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)",
      ]),
    });
  • #957 7950df80 Thanks @jxom! - Added hexToSignature & signatureToHex.

  • #847 1e5d4545 Thanks @jxom! - Type Change: TIncludeTransactions & TBlockTag has been added to slot 1 & 2 of the Block generics.

    type Block<
      TQuantity = bigint,
    + TIncludeTransactions extends boolean = boolean,
    + TBlockTag extends BlockTag = BlockTag,
      TTransaction = Transaction<
        bigint,
        number,
        TBlockTag extends 'pending' ? true : false
      >,
    >

1.4.2

Patch Changes

  • #941 12c685a1 Thanks @jxom! - Capture error signatures that do not exist on the ABI in ContractFunctionRevertedError.

  • #942 e26e356c Thanks @alexfertel! - Deprecated OnLogParameter & OnLogFn in favor of WatchEventOnLogParameter & WatchEventOnLogFn types. Added WatchContractEventOnLogParameter & WatchContractEventOnLogFn types.

1.4.1

Patch Changes

  • 789592dc Thanks @jxom! - Fixed an issue where calling encodePacked with an empty bytes[] array would return an Uint8Array instead of Hex value.

  • #922 71c9c933 Thanks @mikemcdonald! - Fixed an issue where parseUnits would throw Cannot convert to a BigInt for large numbers with a fraction component.

1.4.0

Minor Changes

Patch Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

1.2.15

Patch Changes

1.2.14

Patch Changes

1.2.13

Patch Changes

  • #874 a9bc9f6d Thanks @Alexsey! - Fixed BaseError.walk to return null if the predicate callback is not satisfied.

1.2.12

Patch Changes

  • #864 b851c41b Thanks @jxom! - Fixed an issue where dataSuffix was not being provided to the request returned from simulateTransaction.

1.2.11

Minor Changes

1.2.10

Patch Changes

1.2.9

Patch Changes

  • d24e5bc4 Thanks @jxom! - Fixed a race condition in waitForTransactionReceipt causing multiple parallel instances to not resolve.

1.2.8

Patch Changes

1.2.7

Patch Changes

1.2.6

Patch Changes

  • #808 7567f58e Thanks @jxom! - Fixed RpcTransaction type to not include typeHex.

  • #808 7567f58e Thanks @jxom! - Fixed an issue where TransactionRequest did not narrow based on type.

1.2.5

Patch Changes

1.2.4

Patch Changes

1.2.3

Patch Changes

1.2.2

Patch Changes

1.2.1

Patch Changes

1.2.0

Minor Changes

  • #791 98fd9172 Thanks @jxom! - Implemented ability to "extend" Clients via client.extend & refactored Actions to accept a tree-shakable Client.

1.1.8

Patch Changes

1.1.7

Patch Changes

1.1.6

Patch Changes

  • ec58ed1b Thanks @jxom! - Fixed type narrowing on EIP1474 schemas

1.1.5

Patch Changes

  • c4e996b8 Thanks @jxom! - Fixed errorneous type defition being generated by tsc.

1.1.4

Patch Changes

1.1.3

Patch Changes

  • #758 67b628df Thanks @jxom! - Added support for empty string in EIP712Domain name field.

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

Patch Changes

  • #709 043b2cba Thanks @jxom! - Refactored serializable/serialized transaction types.

  • #735 e7ee66c8 Thanks @holic! - Fixed block formatting in watchBlocks for WebSocket subscriptions.

  • 1f3f2834 Thanks @jxom! - Added typeHex to Transaction type.

1.0.7

Patch Changes

  • #707 3fc045d1 Thanks @tmm! - Made TypeScript requirement explicit (was missing previously).

1.0.6

Patch Changes

  • 90fd40ba Thanks @jxom! - Fixed potential nullish chainId conflict in sendTransaction (for Local Accounts).

1.0.5

Patch Changes

  • #699 79d1b4af Thanks @jxom! - Support custom transaction formatters on sendUnsignedTransaction.

1.0.4

Patch Changes

  • 8407fdcc Thanks @jxom! - Fixed fraction length overflow edge-case.

1.0.3

Patch Changes

1.0.2

Patch Changes

  • #677 a0a2ebb Thanks @hexcowboy! - Added ability to pass an AbiFunction to getFunctionSelector, and AbiEvent to getEventSelector.

1.0.1

Patch Changes

1.0.0

Migration Guide

Major Changes

  • #576 7d42767 Thanks @jxom! - Released v1.

  • #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 on Log now return a number instead of a bigint

  • #576 7d42767 Thanks @jxom! - Breaking: Removed ethersWalletToAccount 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.

Patch Changes

  • #576 7d42767 Thanks @jxom! - Added Batch JSON-RPC on http Transport.

  • #657 af48368 Thanks @izayl! - Fixed getAbiItem from returning mismatched type when overload with different lengths.

  • #576 7d42767 Thanks @jxom! - Upgraded ENS Universal Resolver contract address.

  • #576 7d42767 Thanks @jxom! - Added support for labels larger than 255 bytes when resolving ENS names.

  • #576 7d42767 Thanks @jxom! - Added a strict parameter to getLogs, 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. When strict 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 the args property will be undefined (as we cannot decode these events).

  • #576 7d42767 Thanks @jxom! - Refactored EIP1193 request fn types.

0.3.50

Patch Changes

0.3.49

Patch Changes

  • 0b92f3a Thanks @jxom! - Added more chains from @wagmi/chains.

0.3.47

Patch Changes

0.3.46

Patch Changes

0.3.45

Patch Changes

0.3.44

Patch Changes

  • #610 06ee89c5 Thanks @jxom! - Added ability to hash data representation of message via a raw attribute in signMessage, verifyMessage, recoverMessageAddress.

    await walletClient.signMessage({
      message: { raw: "0x68656c6c6f20776f726c64" },
    });

0.3.43

Patch Changes

0.3.42

Patch Changes

0.3.41

Patch Changes

  • 1b3f584 Thanks @jxom! - Fixed chainId type on Transaction types.

0.3.40

Patch Changes

0.3.39

Patch Changes

0.3.38

Patch Changes

0.3.37

Patch Changes

0.3.36

Patch Changes

0.3.35

Patch Changes

  • 1cc1dc2 Thanks @jxom! - Fixed account parameter type on readContract.

0.3.34

Patch Changes

  • 5c75ee5 Thanks @jxom! - Added EstimateContractGasParameters & EstimateContractGasReturnType types.

0.3.33

Patch Changes

  • 0cb8f31 Thanks @jxom! - Fixed an issue where watchContractEvent would throw a serialize error for bigint args.

0.3.32

Patch Changes

  • fb5b321 Thanks @jxom! - Allowed recovery id as v when recovering public key.

  • 9df44ce Thanks @jxom! - Added ganache as another mode for Test Client

0.3.31

Patch Changes

  • #540 0d8f154 Thanks @jxom! - Added proxy packages to support bundlers that are not compatible with package.json#exports.

0.3.30

Patch Changes

  • 228d949 Thanks @jxom! - Bumped waitForTransactionReceipt retry count.

0.3.29

Patch Changes

  • #527 840d3d7 Thanks @jxom! - Fixed trim to trim trailing zero byte data instead of all trailing zeros.

0.3.28

Patch Changes

  • ffee4f8 Thanks @jxom! - Bumped waitForTransactionReceipt exponential backoff scalar

0.3.27

Patch Changes

  • #519 2ab7b56 Thanks @jxom! - Batched websocket initialization.

  • #518 65a0896 Thanks @jxom! - Added strict option to isHex & optimized data utilities.

  • #515 c1b81dc Thanks @jxom! - Optimized getTransaction strategy in waitForTransactionReceipt.

0.3.26

Patch Changes

0.3.25

Patch Changes

0.3.24

Patch Changes

  • 9852bcd Thanks @jxom! - Fixed custom solidity errors with no args.

0.3.23

Patch Changes

  • #489 d130c72 Thanks @tmm! - Improved RpcError code types.

  • 670d825 Thanks @jxom! - Fixed `call` revert data for node clients that have nested error data.

  • #487 566e77d Thanks @kdembler! - fix encodeEventTopics for leading non-indexed args

0.3.22

Patch Changes

  • 9ae5eaa Thanks @jxom! - Fixed functionName type inference in SimulateContractReturnType.

0.3.21

Patch Changes

  • #475 64a2f51 Thanks @jxom! - Fixed `hashMessage` string conversion for messages that have same format as hex bytes.

  • #474 1886095 Thanks @jxom! - Exported assertCurrentChain util.

0.3.20

Patch Changes

  • #470 be9501e Thanks @jxom! - Fixed issue where waitForTransactionReceipt would throw immediately for RPC Providers which may be slow to sync mined transactions.

0.3.19

Patch Changes

  • #320 6d6d092 Thanks @janek26! - Added support for Contract Wallet signature verification (EIP-6492) via publicClient.verifyMessage & publicClient.verifyTypedData.

0.3.18

Patch Changes

  • #445 9e096a9 Thanks @jxom! - Refactored contract decoding utility types.

  • #448 29cf036 Thanks @jxom! - Refactored inferred types on Log (eventName, args, topics), getLogs, getFilterLogs & getFilterChanges.

  • #435 711cf94 Thanks @Raiden1411! - Updated abitype to 0.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.

0.3.17

Patch Changes

  • #443 ca0cb85 Thanks @jxom! - Fixed eth_call & eth_estimateGas calls for nodes that conform to the older JSON-RPC spec.

0.3.16

Patch Changes

  • 482aaa1 Thanks @jxom! - Wrapped slice offset out-of-bounds error in a BaseError.

0.3.15

Patch Changes

  • #436 72ed656 Thanks @jxom! - Fixed an issue where multicall's return type was incorrectly flattening when allowFailure: false.

0.3.14

Patch Changes

0.3.13

Patch Changes

  • eb32e6c Thanks @fubhy! - Fixed mine() to resolve to undefined instead of null.

0.3.12

Patch Changes

  • 6f8151c Thanks @jxom! - Flagged 403 as non-deterministic error for fallback Transport.

0.3.11

Patch Changes

  • #404 2c380cf Thanks @izayl! - Added support for EIP-1191 address checksum.

  • #398 cbb4f1f Thanks @jxom! - Added a new batchSize parameter to multicall which limits the size of each calldata chunk.

0.3.10

Patch Changes

0.3.9

Patch Changes

0.3.8

Patch Changes

  • 8371ad9 Thanks @jxom! - Fixed WebSocket import on Vite environments.

0.3.7

Patch Changes

0.3.6

Patch Changes

  • ae6d388 Thanks @jxom! - Fixed unpublished type declarations.

0.3.5

Patch Changes

  • 0d38807 Thanks @jxom! - Fixed batch config in createPublicClient.

0.3.4

Patch Changes

  • #387 230fcfd Thanks @jxom! - Added support for eth_call batch aggregation via multicall aggregate3.

  • #388 bc254d8 Thanks @jxom! - Added size as an argument to hex/bytes encoding/decoding utilities.

  • 03816ec Thanks @jxom! - Disabled fallback transport ranking by default.

0.3.3

Patch Changes

  • #383 7e9731c Thanks @Raiden1411! - Fixed an issue where serializeTransaction was incorrectly encoding zero-ish properties.

0.3.2

Patch Changes

0.3.1

Patch Changes

0.3.0

Minor Changes

  • #355 b1acfc9 Thanks @jxom! - Breaking: Renamed RequestError to RpcError. Breaking: Removed RpcRequestError – use RpcError instead. Breaking: Renamed RpcError to RpcRequestError.

Patch Changes

  • #355 b1acfc9 Thanks @jxom! - Added ProviderRpcError subclass.

    Added EIP-1193 UnauthorizedProviderError, UnsupportedProviderMethodError, ProviderDisconnectedError, and ChainDisconnectedError.

  • #349 b275811 Thanks @jxom! - Fixed an issue where Filter querying (eth_getFilterChanges, etc) was not being scoped to the Transport that created the Filter.

0.2.14

Patch Changes

0.2.13

Patch Changes

  • #331 cd7b642 Thanks @jxom! - Migrated to TypeScript 5. Migrated build process from tsup to tsc.

  • #343 579171d Thanks @fubhy! - Fixed conditional types for poll options on watchBlocks & watchPendingTransactions.

0.2.12

Patch Changes

  • #328 ee87fe7 Thanks @jxom! - Tweaked error inheritence for UserRejectedRequestError & SwitchChainError to be more friendly with custom errors.

0.2.11

Patch Changes

  • #326 c83616a Thanks @jxom! - Fixed an issue where filtered logs that do not conform to the provided ABI would cause getLogs, getFilterLogs or getFilterChanges to throw – these logs are now skipped. See #323 for more info.

0.2.10

Patch Changes

  • #322 ea019d7 Thanks @tmm! - Fixed properties passed to ethers adapter signTransaction

0.2.9

Patch Changes

  • #317 2720ba5 Thanks @jxom! - Fixed transports property type on FallbackTransport.

0.2.8

Patch Changes

  • #313 eb2280c Thanks @jxom! - Migrated from idna-uts46-hx to @adraffy/ens-normalize for normalize.

0.2.7

Patch Changes

  • #310 6dfc225 Thanks @jxom! - Made GetValue return { value?: never } instead of unknown for contract functions that are not payable.

0.2.6

Patch Changes

  • #295 9a15a61 Thanks @fubhy! - Return discrimated union type from decodeFunctionData

  • #304 8e1b712 Thanks @fubhy! - Fixed getTransactionType to honor undefined EIP-1559, EIP-2930 or Legacy attributes.

  • #302 c00a459 Thanks @fubhy! - Fixed forwarding of options to transport for wallet client

0.2.5

Patch Changes

0.2.4

Patch Changes

  • #293 859352c Thanks @TateB! - Fixed ENS address resolution for when resolver returns with a null address, or resolvers that do not support addr. getEnsAddress returns null for these cases.

0.2.3

Patch Changes

  • #290 ef2bbaf Thanks @holic! - Fixed ENS address resolution for "0x"-prefixed names.

0.2.2

Patch Changes

0.2.1

Patch Changes

  • #285 ab9fd12 Thanks @tmm! - Exported hdKeyToAccount and mnemonicToAccount.

0.2.0 – Migration Guide

Minor Changes

  • #229 098f342 Thanks @jxom! - Breaking: Removed the getAccount 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: Removed assertChain argument on sendTransaction, writeContract & deployContract. If you wish to bypass the chain check (not recommended unless for testing purposes), you can pass chain: null.

    await walletClient.sendTransaction({
    - assertChain: false,
    + chain: null,
      ...
    })
  • #229 098f342 Thanks @jxom! - Breaking: A chain is now required for the sendTransaction, 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 now InferErrorName
    • ExtractEventNameFromAbi is now InferEventName
    • ExtractFunctionNameFromAbi is now InferFunctionName
    • ExtractItemNameFromAbi is now InferItemName
    • ExtractConstructorArgsFromAbi is now GetConstructorArgs
    • ExtractErrorArgsFromAbi is now GetErrorArgs
    • ExtractEventArgsFromAbi is now GetEventArgs
    • ExtractEventArgsFromTopics is now GetEventArgsFromTopics
    • ExtractArgsFromAbi is now GetFunctionArgs
  • #229 098f342 Thanks @jxom! - Breaking: The following functions are now async 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...' })

Patch Changes

  • #229 098f342 Thanks @jxom! - Added getEnsText & getEnsAvatar

  • #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 WebSocket eth_subscribe support watchBlocks, watchBlockNumber, and watchPendingTransactions.

  • #229 098f342 Thanks @jxom! - Updated Client types.

  • #229 098f342 Thanks @jxom! - Added verifyTypedData, hashTypedData, recoverTypedDataMessage

  • #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')
    })
  • #229 098f342 Thanks @jxom! - Added getEnsResolver

0.1.26

Patch Changes

  • 93e402d Thanks @jxom! - Fixed a decodeAbiParameters case where static arrays with a dynamic child would consume the size of the child instead of 32 bytes.

0.1.25

Patch Changes

  • #263 53fda1a Thanks @fubhy! - Fixed issue where ABIs with constructors would throw for decodeFunctionData.

0.1.24

Patch Changes

0.1.23

Patch Changes

  • #251 153e97e Thanks @tmm! - Fixed signTypedData inference for primaryType field.

0.1.22

Patch Changes

  • 07000b6 Thanks @jxom! - Removed unnecessary trimming of decoded RLP hex value

0.1.21

Patch Changes

  • #223 2e9c000 Thanks @jxom! - Added an assertion in sendTransaction & writeContract to check that the client chain matches the wallet's current chain.

0.1.20

Patch Changes

  • #220 9a80fca Thanks @jxom! - Fixed an issue where watchEvent would not emit events on missed blocks for the getLogs fallback.

0.1.19

Patch Changes

  • 74f8e1d Thanks @jxom! - Added missing recoverMessageAddress and verifyMessage exports.

0.1.18

Patch Changes

  • 9c45397 Thanks @jxom! - Fixed signTypedData support for Ethers.js v5 wallets

0.1.17

Patch Changes

  • #213 46f823a Thanks @jxom! - Fixed return type for allowFailure: false on multicall

  • 1339b20 Thanks @jxom! - Exported Extract*FromAbi types

  • c3d932a Thanks @jxom! - Fixed signTypedData support for Ethers.js v5 Wallets

0.1.16

Patch Changes

  • #207 8e5768f Thanks @jxom! - Added assertion in watchBlocks and watchBlockNumber to check that the next block number is higher than the previously seen block number.

  • #209 ae3e0b6 Thanks @jxom! - Added verifyMessage, recoverAddress, recoverMessageAddress, and hashMessage.

0.1.15

Patch Changes

  • #205 36fa97a Thanks @jxom! - Added an assertion to check for existence of an event signature on topics for decodeEventLog

0.1.14

Patch Changes

  • #198 e805e7e Thanks @wighawag! - Added an assertion in decodeEventLog to check for a mismatch between topics + indexed event parameters.

0.1.13

Patch Changes

0.1.12

Patch Changes

0.1.11

Patch Changes

0.1.10

Patch Changes

0.1.9

Patch Changes

  • #170 35a7508 Thanks @jxom! - Added inference for multicall address from client chain.

0.1.8

Patch Changes

  • 36c908c Thanks @jxom! - Fixed an issue where empty strings were not being decoded properly in decodeAbiParameters.

0.1.7

Patch Changes

  • #159 574ae22 Thanks @jxom! - Fixed issue where decoding error logs would break if constructor was in ABI.

0.1.6

Patch Changes

  • #153 bbb998a Thanks @jxom! - Formatted undefined values from RPC as null to conform to EIP-1474.

0.1.5

Patch Changes

0.1.4

Patch Changes

  • #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

0.1.3

Patch Changes

0.1.2

Patch Changes

0.1.1

Patch Changes

0.1.0

Minor Changes

0.0.1-alpha.39

Patch Changes

  • 68c3816 Thanks @jxom! - Added encodePacked.

  • 68c3816 Thanks @jxom! - Made keccak256 accept a hex value (as well as byte array).

0.0.1-alpha.38

Patch Changes

0.0.1-alpha.37

Patch Changes

  • e07f212 Thanks @jxom! - Breaking: Renamed formatUnit and parseUnit to formatUnits and parseUnits.

0.0.1-alpha.36

Patch Changes

  • #100 6bb8ce4 Thanks @jxom! - Breaking: Renamed requestAccounts Wallet Action to requestAddresses

    Breaking: Renamed getAccounts Wallet Action to getAddresses

  • #100 6bb8ce4 Thanks @jxom! - Added support for Externally Owned Accounts.

  • #100 6bb8ce4 Thanks @jxom! - Breaking: The from argument has been removed from Actions in favour of account 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

0.0.1-alpha.35

Patch Changes

  • 057e01e Thanks @jxom! - - testClient.getTxPoolContenttestClient.getTxpoolContent

    • testClient.getTxPoolStatustestClient.getTxpoolStatus
  • #85 2350d1a Thanks @jxom! - Breaking: Renamed encodeAbi & decodeAbi to encodeAbiParameters & 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)

0.0.1-alpha.34

Patch Changes

  • e1634b5 Thanks @jxom! - Fixed ABI encoding dynamic tuple child derivation

0.0.1-alpha.33

Patch Changes

  • 1971e6a Thanks @jxom! - Added assertion to check if addresses are valid for sendTransaction, estimateGas & call.

0.0.1-alpha.32

Patch Changes

  • 7243744 Thanks @jxom! - Added support for 4001 & 4902 RPC error codes.

0.0.1-alpha.31

Patch Changes

  • #89 3e45853 Thanks @jxom! - Added fetchOptions to the http transport.

  • #91 0ac32c2 Thanks @jxom! - Breaking: Renamed getFunctionSignature and getEventSignature to getFunctionSelector and getEventSelector.

0.0.1-alpha.30

Patch Changes

  • #81 eb572b0 Thanks @jxom! - Improved transaction & contract error messaging & coalesce error messages from nodes.

0.0.1-alpha.29

Patch Changes

  • 6bdee9c Thanks @jxom! - Fixed issue where fallback transport was not falling back on timeouts

0.0.1-alpha.28

Patch Changes

  • 8ef068b Thanks @jxom! - Added 502, 503 and 504 error codes as "non-deterministic" errors for fallback transport & retries.

  • #79 db9caa9 Thanks @jxom! - Added timeout as a config option to the http and webSocket Transports.

  • #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()

0.0.1-alpha.26

Patch Changes

Breaking: Renamed encoding utils.

  • encodeBytes/decodeBytestoBytes/fromBytes
  • encodeHex/decodeHextoHex/fromHex
  • encodeRlp/decodeRlptoRlp/fromRlp

0.0.1-alpha.26

Patch Changes

  • 7d9a241 Thanks @jxom! - Added estimateContractGas.

  • 7d9a241 Thanks @jxom! - Added retryCount and retryDelay config to Transports.

0.0.1-alpha.25

Patch Changes

  • 6c902f8 Thanks @jxom! - Added decodeEventLog.

  • #68 1be77b3 Thanks @jxom! - Breaking: Removed all public/wallet/test actions & utils from the viem entrypoint to their respective entrypoints:

    • viem = Clients & Transport exports
    • viem/chains = Chains exports
    • viem/contract = Contract Actions & Utils exports
    • viem/ens = ENS Actions & Utils exports
    • viem/public = Public Actions exports
    • viem/test = Test Actions exports
    • viem/utils = Utils exports
    • viem/wallet = Wallet Actions exports
  • #66 f19fc32 Thanks @tmm! - Added ENS actions getEnsAddress and getEnsName.

0.0.1-alpha.24

Patch Changes

  • #63 7473582 Thanks @tmm! - Exported missing watchContractEvent and watchEvent actions.

0.0.1-alpha.23

Patch Changes

0.0.1-alpha.22

Patch Changes

  • #57 40c76e3 Thanks @jxom! - support Panic & custom contract errors

  • #56 3e90197 Thanks @jxom! - - Breaking: Renamed humanMessage to shortMessage in BaseError.

    • Added multicall.
    • Support overloaded contract functions.

0.0.1-alpha.21

Patch Changes

  • 5a6bdf8 Thanks @jxom! - Fixed an issue where encodeAbi couldn't encode dynamic bytes larger than 32 bytes"

0.0.1-alpha.20

Patch Changes

  • ebf1dc8 Thanks @jxom! - Added watchEvent

  • ebf1dc8 Thanks @jxom! - Added watchContractEvent

  • ae90357 Thanks @jxom! - Made watchBlocks more type safe with the includeTransactions arg.

0.0.1-alpha.19

Patch Changes

0.0.1-alpha.18

Patch Changes

0.0.1-alpha.17

Patch Changes

0.0.1-alpha.16

Patch Changes

0.0.1-alpha.15

Patch Changes

  • a74d643 Thanks @jxom! - Breaking: Removed the viem/actions export in favor of viem/public, viem/test & viem/wallet exports.

0.0.1-alpha.14

Patch Changes

0.0.1-alpha.13

Patch Changes

0.0.1-alpha.12

Patch Changes

0.0.1-alpha.11

Patch Changes

  • #37 32e2b76 Thanks @jxom! - Support CJS

  • 43700d9 Thanks @jxom! - Fixed issue where preinstall/postinstall scripts were being published to NPM.

0.0.1-alpha.10

Patch Changes

0.0.1-alpha.9

Patch Changes

0.0.1-alpha.8

Patch Changes

0.0.1-alpha.7

Patch Changes

0.0.1-alpha.6

Patch Changes

0.0.1-alpha.5

Patch Changes

0.0.1-alpha.4

Patch Changes

0.0.1-alpha.3

Patch Changes

  • 849653f Thanks @jxom! - - Breaking: Renamed encodeFunctionParams to encodeFunctionData.
    • Added decodeFunctionData.

0.0.1-alpha.2

Patch Changes

0.0.1-alpha.1

Patch Changes

  • d722728 Thanks @jxom! - - Breaking: Renamed ethereumProvider Transport to custom.
    • Breaking: Refactored Transport APIs.
    • Breaking: Flattened sendTransaction, call & estimateGas APIs.
    • Added encodeAbi & decodeAbi.
    • Added fallback Transport.
    • Added getFilterLogs.