Skip to content

Class: ScriptRequest<TData, TResult>

@fuel-ts/program.ScriptRequest

ScriptRequest provides functionality to encode and decode script data and results.

Type parameters

NameTypeDescription
TDatavoidType of the script data.
TResultvoidType of the script result.

Constructors

constructor

new ScriptRequest<TData, TResult>(bytes, scriptDataEncoder, scriptResultDecoder): ScriptRequest<TData, TResult>

Creates an instance of the ScriptRequest class.

Type parameters

NameType
TDatavoid
TResultvoid

Parameters

NameTypeDescription
bytesBytesLikeThe bytes of the script.
scriptDataEncoder(data: TData) => EncodedScriptCallThe script data encoder function.
scriptResultDecoder(scriptResult: ScriptResult) => TResultThe script result decoder function.

Returns

ScriptRequest<TData, TResult>

Defined in

script-request.ts:205

Properties

bytes

bytes: Uint8Array

The bytes of the script.

Defined in

script-request.ts:186


scriptDataEncoder

scriptDataEncoder: (data: TData) => EncodedScriptCall

A function to encode the script data.

Type declaration

▸ (data): EncodedScriptCall

Parameters
NameType
dataTData
Returns

EncodedScriptCall

Defined in

script-request.ts:191


scriptResultDecoder

scriptResultDecoder: (scriptResult: ScriptResult) => TResult

A function to decode the script result.

Type declaration

▸ (scriptResult): TResult

Parameters
NameType
scriptResultScriptResult
Returns

TResult

Defined in

script-request.ts:196

Methods

decodeCallResult

decodeCallResult(callResult, logs?): TResult

Decodes the result of a script call.

Parameters

NameTypeDefault valueDescription
callResultCallResultundefinedThe CallResult from the script call.
logsany[][]Optional logs associated with the decoding.

Returns

TResult

The decoded result.

Defined in

script-request.ts:262


encodeScriptData

encodeScriptData(data): Uint8Array

Encodes the data for a script call.

Parameters

NameTypeDescription
dataTDataThe script data.

Returns

Uint8Array

The encoded data.

Defined in

script-request.ts:243


getScriptDataOffset

getScriptDataOffset(maxInputs): number

Gets the script data offset.

Parameters

NameTypeDescription
maxInputsnumberThe maxInputs value from the chain's consensus params.

Returns

number

The script data offset.

Defined in

script-request.ts:233


getScriptDataOffsetWithScriptBytes

getScriptDataOffsetWithScriptBytes(byteLength, maxInputs): number

Gets the script data offset for the given bytes.

Parameters

NameTypeDescription
byteLengthnumberThe byte length of the script.
maxInputsnumberThe maxInputs value from the chain's consensus params.

Returns

number

The script data offset.

Defined in

script-request.ts:222