diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 06d687785bc2ba..28555fbf3499c2 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -888,6 +888,8 @@ export type ParsedTransactionMeta = { err: TransactionError | null; /** The collection of addresses loaded using address lookup tables */ loadedAddresses?: LoadedAddresses; + /** The compute units consumed after processing the transaction */ + computeUnitsConsumed?: number; }; export type CompiledInnerInstruction = { @@ -917,6 +919,8 @@ export type ConfirmedTransactionMeta = { err: TransactionError | null; /** The collection of addresses loaded using address lookup tables */ loadedAddresses?: LoadedAddresses; + /** The compute units consumed after processing the transaction */ + computeUnitsConsumed?: number; }; /** @@ -1993,6 +1997,7 @@ const ConfirmedTransactionMetaResult = pick({ preTokenBalances: optional(nullable(array(TokenBalanceResult))), postTokenBalances: optional(nullable(array(TokenBalanceResult))), loadedAddresses: optional(LoadedAddressesResult), + computeUnitsConsumed: optional(number()), }); /** @@ -2017,6 +2022,7 @@ const ParsedConfirmedTransactionMetaResult = pick({ preTokenBalances: optional(nullable(array(TokenBalanceResult))), postTokenBalances: optional(nullable(array(TokenBalanceResult))), loadedAddresses: optional(LoadedAddressesResult), + computeUnitsConsumed: optional(number()), }); const TransactionVersionStruct = union([literal(0), literal('legacy')]); diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index 9ad1ebf36514e3..f32195ec99081f 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -4460,6 +4460,8 @@ describe('Connection', function () { readonly: [], writable: [lookupTableAddresses[0]], }); + expect(fetchedTransaction.meta?.computeUnitsConsumed).to.not.be + .undefined; expect( fetchedTransaction.transaction.message.addressTableLookups, ).to.eql(addressTableLookups); @@ -4489,6 +4491,8 @@ describe('Connection', function () { readonly: [], writable: [lookupTableAddresses[0]], }); + expect(parsedTransaction?.meta?.computeUnitsConsumed).to.not.be + .undefined; expect( parsedTransaction?.transaction.message.addressTableLookups, ).to.eql(addressTableLookups);