Issues with Integrating ethers.js and @openzeppelin/defender-sdk on Next.js

I’m attempting to call a contract on Next.js (14.2.0) using ethers.js (v6) and @openzeppelin/defender-sdk (1.13.4), following the instructions from the URL below.

However, I’m encountering two issues:

  1. const erc20 = new ethers.Contract(ERC20_ADDRESS, ERC20_ABI, signer);
    I get an error saying: Argument of type 'Promise<DefenderRelaySigner | DefenderRelaySignerV5>' is not assignable to parameter of type 'ContractRunner'.
  2. When I try to compile, I receive an error: Module not found: Can't resolve '@aws-sdk/client-lambda'.

Could you help me resolve these issues?

Hi! For backwards compatibility between ethers v5 and ethers v6 we "promisified" the getSigner API, now if you want to use the Relayer as signer, you need to instantiate it as follows (default ethers version is v5 but you can optionally add the v6 flag):

  const provider = client.relaySigner.getProvider({ ethersVersion: 'v6' });
  const signer = await client.relaySigner.getSigner(provider, { ethersVersion: 'v6' });

About the second issue:
@aws-sdk/client-lambda is a peer dependency we use for Actions package, installing that dependency should fix the issue. But in case you just need relayer signer SDK APIs, you could just install @openzeppelin/defender-sdk-relay-signer-client instead of the whole SDK