The SDK and above ships with Viem by default as it is much lighter than Ethers and is generally more performant.

We have also made viem a peerDependency to avoid bundling it multiple times, as other other packages such as wagmi also need it.

For the above reason, viem will be installed as a peerDependency when you install the SDK with npm, even if you want to use Ethers.

If you are using yarn instead of npm, even if you want to use Ethers, you will need to install viem manually:

yarn i viem

In order to use Ethers, we have provided an extension:

npm i @dynamic-labs/ethers-v5

If you want to use Ethers V6 instead of V5, it’s as simple as using @dynamic-labs/ethers-v6 instead of @dynamic-labs/ethers-v5.

import { EthersExtension } from "@dynamic-labs/ethers-v5";

return (
  <DynamicContextProvider
    settings={{
      environmentId: "XXXXX",
      walletConnectorExtensions: [EthersExtension],
    }}
  >
    <App />
  </DynamicContextProvider>
);

You can then access the signer like so:

const signer = await primaryWallet.connector.ethers?.getSigner();

We have more examples in the wallet interactions section!