Skip to content

@fuel-ts/program v0.94.1Docs


Class: ScriptRequest<TData, TResult>

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

Type Parameters

Type ParameterDefault typeDescription
TDatavoidType of the script data.
TResultvoidType of the script result.

Constructors

new ScriptRequest()

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

Creates an instance of the ScriptRequest class.

Parameters

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

Returns

ScriptRequest<TData, TResult>

Defined in

script-request.ts:205

Properties

PropertyTypeDescriptionDefined in
bytesUint8ArrayThe bytes of the script.script-request.ts:186
scriptDataEncoder(data: TData) => EncodedScriptCallA function to encode the script data.script-request.ts:191
scriptResultDecoder(scriptResult: ScriptResult) => TResultA function to decode the script result.script-request.ts:196

Methods

decodeCallResult()

decodeCallResult(callResult, logs): TResult

Decodes the result of a script call.

Parameters

ParameterTypeDefault 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

ParameterTypeDescription
dataTDataThe script data.

Returns

Uint8Array

The encoded data.

Defined in

script-request.ts:243


getScriptDataOffset()

getScriptDataOffset(maxInputs): number

Gets the script data offset.

Parameters

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

Returns

number

The script data offset.

Defined in

script-request.ts:233


getScriptDataOffsetWithScriptBytes()

static getScriptDataOffsetWithScriptBytes(byteLength, maxInputs): number

Gets the script data offset for the given bytes.

Parameters

ParameterTypeDescription
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