UNPKG

@0xfacet/sdk

Version:

A toolkit for Facet blockchain integration.

19 lines (18 loc) 593 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calculateInputGasCost = void 0; /** * Calculates the gas cost of input data based on EVM gas rules. * Each zero byte costs 4 gas, while each non-zero byte costs 16 gas. * * @param input - The input data as a Uint8Array * @returns The total gas cost as a BigInt */ const calculateInputGasCost = (input) => { let totalGasCost = 0n; input.forEach((byte) => { totalGasCost += byte === 0 ? 4n : 16n; }); return totalGasCost; }; exports.calculateInputGasCost = calculateInputGasCost;