diff --git a/web3.js/src/layout.ts b/web3.js/src/layout.ts index 8c35d589a4..c4d161e04d 100644 --- a/web3.js/src/layout.ts +++ b/web3.js/src/layout.ts @@ -152,6 +152,9 @@ export function getAlloc(type: any, fields: any): number { if (Array.isArray(field)) { return field.length * getItemAlloc(item.elementLayout); } + } else if ('fields' in item) { + // This is a `Structure` whose size needs to be recursively measured. + return getAlloc({layout: item}, fields[item.property]); } // Couldn't determine allocated size of layout return 0;