For the complete documentation index, see llms.txt. This page is also available as Markdown.

EthersSigner

Signer adapter that wraps an ethers Signer or EIP-1193 source for wallet operations.

Signer adapter that wraps an ethers Signer or EIP-1193 source for wallet operations. Implements GenericSigner.

Import

import { EthersSigner } from "@zama-fhe/sdk/ethers";

Usage

import { EthersSigner } from "@zama-fhe/sdk/ethers";

const signer = new EthersSigner({ ethereum: window.ethereum! });
import { Wallet, JsonRpcProvider } from "ethers";
import { EthersSigner } from "@zama-fhe/sdk/ethers";

const provider = new JsonRpcProvider(rpcUrl);
const wallet = new Wallet(privateKey, provider);

const signer = new EthersSigner({ signer: wallet });

You rarely need to instantiate EthersSigner directly. The ethers createConfig builds one from the configuration you pass. Use this class when constructing ZamaSDK manually or when using the generic createConfig.

Constructor

Pass exactly one of the two parameters below.

ethereum

EIP1193Provider

Raw EIP-1193 provider from the browser wallet (e.g. window.ethereum). Enables automatic credential cleanup on disconnect and account change.

const signer = new EthersSigner({ ethereum: window.ethereum! });

signer

ethers.Signer

Ethers signer for server-side or scripted use. subscribe() is not available in this mode.

Methods

All methods are inherited from GenericSigner.

Method
Browser
Node.js

walletAccount store

Works

Works

requireWalletAccount()

Works

Works

signTypedData()

Works

Works

writeContract()

Works

Works

Only the browser mode (passing ethereum) emits wallet account transitions. In Node.js mode, credentials are not automatically cleared on wallet changes.

Last updated