Calculating Buffer Size

ScriptyBuilder depends on DynamicBuffer to assemble fetched scripts.

The main intention of DynamicBuffer is to get rid of the repeated usage of abi.encodePacked (or similar) when stitching together scripts. To achieve this, scripty.sol needs to allocate enough space in memory.

Therefore, you need to know the size of stored scripts before requesting them. Good news is,ScriptyBuilder provides methods that you can use to find exact size of stored scripts:

getBufferSizeForHTMLInline(WrappedScriptRequest[])
getBufferSizeForHTMLWrapped(InlineScriptRequest[])
getBufferSizeForURLSafeHTMLWrapped(InlineScriptRequest[])

getBufferSizeForEncodedHTMLInline(WrappedScriptRequest[])
getBufferSizeForEncodedHTMLWrapped(InlineScriptRequest[])

These methods are intendend to be used off-chain

You can check examples to see how you can fetch the size of stored scripts.

Last updated