import type { Abi } from "abitype"; import type * as ethers5 from "ethers5"; import type { Chain } from "../chains/types.js"; import type { ThirdwebClient } from "../client/client.js"; import { type ThirdwebContract } from "../contract/contract.js"; import type { Account } from "../wallets/interfaces/wallet.js"; type Ethers5 = typeof ethers5; /** * The ethers5 adapter provides a way to convert between Thirdweb contracts, accounts, and providers. * @example * * ### Converting a Thirdweb account to an ethers.js signer * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const signer = await ethers5Adapter.signer.toEthers({ client, chain, account }); * ``` * * ### Converting an ethers.js signer into a Thirdweb account * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const account = await ethers5Adapter.signer.fromEthers({ signer }); * ``` * * ### Converting a Thirdweb contract to an ethers.js Contract * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const ethersContract = await ethers5Adapter.contract.toEthers({ thirdwebContract }); * ``` * * ### Converting a Thirdweb client and chain ID into an ethers.js provider * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const provider = ethers5Adapter.provider.toEthers({ client, chain }); * ``` */ export declare const ethers5Adapter: { /** * Converts a ThirdwebContract to an ethers.js Contract or the other way around. * @example * * ### toEthers * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const ethersContract = await ethers5Adapter.contract.toEthers({ * thirdwebContract, * }); * ``` * * ### fromEthers * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * * const twContract = await ethers5Adapter.contract.fromEthers({ * client, * ethersContract, * chain: defineChain(1), // Replace with your chain * }); * ``` * */ contract: { /** * Creates a ThirdwebContract instance from an ethers.js contract. * @param options - The options for creating the ThirdwebContract instance. * @returns A promise that resolves to a ThirdwebContract instance. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * * const twContract = await ethers5Adapter.contract.fromEthers({ * client, * ethersContract, * chain: defineChain(1), // Replace with your chain * }); * ``` */ fromEthers: (options: FromEthersContractOptions) => Promise>>; /** * Converts a ThirdwebContract to an ethers.js Contract. * @param options - The options for converting the ThirdwebContract to an ethers.js Contract. * @param options.thirdwebContract - The ThirdwebContract to convert. * @returns A Promise that resolves to an ethers.js Contract. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const ethersContract = await ethers5Adapter.contract.toEthers({ * thirdwebContract, * }); * ``` * * Once you have converted a thirdweb Contract to an ethers contract, * you can interact with it: * ```ts * // Estimate gas * const gasLimit = await contract.estimateGas["functionName"]( * ...params, * ); * * // Send a transaction * const tx = await contract["functionName"](...params, { gasLimit }); * ``` * */ toEthers: (options: { thirdwebContract: ThirdwebContract; }) => Promise; }; /** * Converts a Thirdweb client and chain ID into an ethers.js provider. * @param options - The options for converting the Thirdweb client and chain ID into an ethers.js provider. * @param options.client - The Thirdweb client. * @param options.chain - The chain. * @returns The ethers.js provider. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const provider = ethers5Adapter.provider.toEthers({ client, chainId }); * ``` * * Once you have converted a thirdweb Client to ethers Provider, * you can use it like any other ethers provider: * ```ts * const blockNumber = await provider.getBlockNumber(); * ``` */ provider: { /** * Converts a Thirdweb client and chain ID into an ethers.js provider. * @param options - The options for converting the Thirdweb client and chain ID into an ethers.js provider. * @param options.client - The Thirdweb client. * @param options.chain - The chain. * @returns The ethers.js provider. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const provider = ethers5Adapter.provider.toEthers({ client, chainId }); * ``` * * Once you have converted a thirdweb Client to ethers Provider, * you can use it like any other ethers provider: * ```ts * const blockNumber = await provider.getBlockNumber(); * ``` */ toEthers: (options: { client: ThirdwebClient; chain: Chain; }) => ethers5.ethers.providers.Provider; }; /** * Converts an ethers5 Signer into a Wallet object or the other way around. * @example * * ### fromEthers * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const wallet = await ethers5Adapter.signer.fromEthers({ signer }); * ``` * * ### toEthers * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const signer = await ethers5Adapter.signer.toEthers({ client, chain, account }); * ``` */ signer: { /** * Converts an ethers5 Signer into a Wallet object. * @param options - The options for converting the ethers5 Signer into a Wallet object. * @param options.signer - The ethers5 Signer object. * @returns - A Promise that resolves to aa Wallet object. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const wallet = await ethers5Adapter.signer.fromEthersSigner({ signer }); * ``` */ fromEthers: (options: { signer: ethers5.Signer; }) => Promise; /** * Converts a Thirdweb wallet to an ethers.js signer. * @param options - The options for converting the Thirdweb wallet to an ethers.js signer. * @param options.client - The thirdweb client. * @param options.chain - The chain. * @param options.account - The account. * @returns A promise that resolves to an ethers.js signer. * @example * ```ts * import { ethers5Adapter } from "thirdweb/adapters/ethers5"; * const signer = await ethers5Adapter.signer.toEthers({ client, chain, account }); * ``` * * Once you have the signer, you can perform different tasks using ethers.js as usual: * ```ts * // Sign message * const signature = await signer.signMessage(message); * * // Get balance * const balance = await signer.getBalance(); * ``` * */ toEthers: (options: { client: ThirdwebClient; chain: Chain; account: Account; }) => Promise<{ /** * @internal */ getAddress(): Promise; /** * @internal */ signMessage(message: string | Uint8Array): Promise; /** * @internal */ signTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; /** * @internal */ sendTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; _signTypedData(domain: ethers5.ethers.TypedDataDomain, types: Record, value: Record): Promise; /** * @internal */ connect(): ethers5.ethers.Signer; readonly provider?: ethers5.ethers.providers.Provider; readonly _isSigner: boolean; getBalance(blockTag?: ethers5.ethers.providers.BlockTag): Promise; getTransactionCount(blockTag?: ethers5.ethers.providers.BlockTag): Promise; estimateGas(transaction: ethers5.ethers.utils.Deferrable): Promise; call(transaction: ethers5.ethers.utils.Deferrable, blockTag?: ethers5.ethers.providers.BlockTag): Promise; getChainId(): Promise; getGasPrice(): Promise; getFeeData(): Promise; resolveName(name: string): Promise; checkTransaction(transaction: ethers5.ethers.utils.Deferrable): ethers5.ethers.utils.Deferrable; populateTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; _checkProvider(operation?: string): void; }>; }; }; /** * Converts a Thirdweb client and chain ID into an ethers.js provider. * @param ethers - The ethers.js library instance. * @param client - The Thirdweb client. * @param chain - The chain. * @returns The ethers.js provider. * @internal */ export declare function toEthersProvider(ethers: Ethers5, client: ThirdwebClient, chain: Chain): ethers5.providers.Provider; /** * Converts a ThirdwebContract to an ethers.js Contract. * @param ethers - The ethers.js instance. * @param twContract - The ThirdwebContract to convert. * @returns A Promise that resolves to an ethers.js Contract. * @internal */ export declare function toEthersContract(ethers: Ethers5, twContract: ThirdwebContract): Promise; type FromEthersContractOptions = { client: ThirdwebClient; ethersContract: ethers5.Contract; chain: Chain; }; /** * Creates a ThirdwebContract instance from an ethers.js contract. * @param options - The options for creating the ThirdwebContract instance. * @returns A promise that resolves to a ThirdwebContract instance. * @internal */ export declare function fromEthersContract(options: FromEthersContractOptions): Promise>; /** * Converts an ethers5 Signer into an Account object. * @param signer - The ethers5 Signer object. * @returns - A Promise that resolves to an Account object. * @internal */ export declare function fromEthersSigner(signer: ethers5.Signer): Promise; /** * @internal */ export declare function toEthersSigner(ethers: Ethers5, client: ThirdwebClient, account: Account, chain: Chain): Promise<{ /** * @internal */ getAddress(): Promise; /** * @internal */ signMessage(message: string | Uint8Array): Promise; /** * @internal */ signTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; /** * @internal */ sendTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; _signTypedData(domain: ethers5.ethers.TypedDataDomain, types: Record, value: Record): Promise; /** * @internal */ connect(): ethers5.ethers.Signer; readonly provider?: ethers5.ethers.providers.Provider; readonly _isSigner: boolean; getBalance(blockTag?: ethers5.ethers.providers.BlockTag): Promise; getTransactionCount(blockTag?: ethers5.ethers.providers.BlockTag): Promise; estimateGas(transaction: ethers5.ethers.utils.Deferrable): Promise; call(transaction: ethers5.ethers.utils.Deferrable, blockTag?: ethers5.ethers.providers.BlockTag): Promise; getChainId(): Promise; getGasPrice(): Promise; getFeeData(): Promise; resolveName(name: string): Promise; checkTransaction(transaction: ethers5.ethers.utils.Deferrable): ethers5.ethers.utils.Deferrable; populateTransaction(transaction: ethers5.ethers.utils.Deferrable): Promise; _checkProvider(operation?: string): void; }>; export {}; //# sourceMappingURL=ethers5.d.ts.map