Skip to content

Add a helper for the conversion: bytecode file contents -> Vec<u8> #1950

@Dhaiwat10

Description

@Dhaiwat10

We need a helper function to read bytecode from a file and convert that to a bytearray that users can pass into our sway-libs functions related to bytecode: https://github.com/FuelLabs/sway-libs/tree/master/libs/bytecode

This conversion is required because the bytecode from a file is a string, but the type that these Sway functions accept for the bytecode is a Vec<u8> - which in JavaScript-land is a Vec<BigNumberish>.

This helper would convert the string to the proper type and ensure all the data is correctly packed.

Possible API

const bytecodeFromFile = readFile(pathToBytecode); // string

const bytecodeVec = generateBytecodeVecFromString(bytecodeFromFile); // our helper -> returns `Vec<BigNumberish>`

await contract.functions.verify_bytecode(bytecodeVec);

Incoming from feedback from the development work being done on the Fuelnaut project: FuelLabs/docs-hub#203

The Fuelnaut project is blocked for now until we figure this out.

Metadata

Metadata

Assignees

Labels

featIssue is a feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions