diff --git a/src/call.ts b/src/call.ts index ada637e..987d2b8 100644 --- a/src/call.ts +++ b/src/call.ts @@ -7,6 +7,7 @@ export async function all( calls: ContractCall[], multicallAddress: string, provider: ethers.providers.Provider, + blockTag?: number, ): Promise { const multicall = new ethers.Contract(multicallAddress, multicallAbi, provider); const callRequests = calls.map(call => { @@ -16,7 +17,9 @@ export async function all( callData, }; }); - const response = await multicall.aggregate(callRequests); + const response = await multicall.aggregate(callRequests, { + blockTag: blockTag, + }); const callCount = calls.length; const callResult = [] as T; for (let i = 0; i < callCount; i++) { diff --git a/src/provider.ts b/src/provider.ts index cbedcfb..a47d2e5 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -24,11 +24,11 @@ export class Provider { return getEthBalance(address, this._multicallAddress); } - public async all(calls: ContractCall[]) { + public async all(calls: ContractCall[], blockTag?: number) { if (!this._provider) { throw new Error('Provider should be initialized before use.'); } - return all(calls, this._multicallAddress, this._provider); + return all(calls, this._multicallAddress, this._provider, blockTag); } }