diff --git a/packages/data/src/types/index.ts b/packages/data/src/types/index.ts index 4e003526b..2d3a38c0a 100644 --- a/packages/data/src/types/index.ts +++ b/packages/data/src/types/index.ts @@ -1,4 +1,4 @@ -import { Chain, Transport } from "viem" +import { Chain, PublicClient, Transport } from "viem" export type EthersNetwork = | "mainnet" @@ -65,4 +65,5 @@ export type ViemOptions = { transport?: Transport // Transport from viem chain?: Chain // Chain from viem apiKey?: string + publicClient?: PublicClient } diff --git a/packages/data/src/viem.ts b/packages/data/src/viem.ts index 283209075..e1d397836 100644 --- a/packages/data/src/viem.ts +++ b/packages/data/src/viem.ts @@ -117,7 +117,6 @@ export default class SemaphoreViem { throw new Error(`Network '${networkOrEthereumURL}' needs a Semaphore contract address`) } - // Create the public client let transport: Transport if (options.transport) { @@ -131,10 +130,12 @@ export default class SemaphoreViem { this._options = options // Create the public client - this._client = createPublicClient({ - transport, - chain: options.chain as Chain - }) + this._client = + options.publicClient ?? + createPublicClient({ + transport, + chain: options.chain as Chain + }) // Create the contract instance this._contract = getContract({