Function to Caclulate Calldata Gas

Given a `data` input: - Count how many zeo bytes - Count how many nonzero bytes Calldata gas = 16 * nonzero_bytes + 4* zero+bytes Formula in DuneSQL format is here: ``` 16 * ( bytearray_length(data) - (length(from_utf8(data)) - length(replace(from_utf8(data), chr(0), ''))) ) --nonzero bytes + 4 * ( (length(from_utf8(data)) - length(replace(from_utf8(data), chr(0), ''))) ) AS calldata_gas ``` It could be formatted like `get_calldata_gas(data)`

Please authenticate to join the conversation.

Upvoters
Status

Open

Board

Feature Requests

Date

Almost 3 years ago

Author

Michael S

Subscribe to post

Get notified by email when there are changes.