@fuel-ts/program .ScriptRequest
ScriptRequest
provides functionality to encode and decode script data and results.
Name | Type | Description |
---|---|---|
TData | void | Type of the script data. |
TResult | void | Type of the script result. |
• new ScriptRequest<TData
, TResult
>(bytes
, scriptDataEncoder
, scriptResultDecoder
): ScriptRequest
<TData
, TResult
>
Creates an instance of the ScriptRequest class.
Name | Type |
---|---|
TData | void |
TResult | void |
Name | Type | Description |
---|---|---|
bytes | BytesLike | The bytes of the script. |
scriptDataEncoder | (data : TData ) => EncodedScriptCall | The script data encoder function. |
scriptResultDecoder | (scriptResult : ScriptResult ) => TResult | The script result decoder function. |
ScriptRequest
<TData
, TResult
>
• bytes: Uint8Array
The bytes of the script.
• scriptDataEncoder: (data
: TData
) => EncodedScriptCall
▸ (data
): EncodedScriptCall
A function to encode the script data.
Name | Type |
---|---|
data | TData |
EncodedScriptCall
• scriptResultDecoder: (scriptResult
: ScriptResult
) => TResult
▸ (scriptResult
): TResult
A function to decode the script result.
Name | Type |
---|---|
scriptResult | ScriptResult |
TResult
▸ decodeCallResult(callResult
, logs?
): TResult
Decodes the result of a script call.
Name | Type | Default value | Description |
---|---|---|---|
callResult | CallResult | undefined | The CallResult from the script call. |
logs | any [] | [] | Optional logs associated with the decoding. |
TResult
The decoded result.
▸ encodeScriptData(data
): Uint8Array
Encodes the data for a script call.
Name | Type | Description |
---|---|---|
data | TData | The script data. |
Uint8Array
The encoded data.
▸ getScriptDataOffset(maxInputs
): number
Gets the script data offset.
Name | Type | Description |
---|---|---|
maxInputs | number | The maxInputs value from the chain's consensus params. |
number
The script data offset.
▸ getScriptDataOffsetWithScriptBytes(byteLength
, maxInputs
): number
Gets the script data offset for the given bytes.
Name | Type | Description |
---|---|---|
byteLength | number | The byte length of the script. |
maxInputs | number | The maxInputs value from the chain's consensus params. |
number
The script data offset.