ensureBytecodePrefix

Ensures that the given bytecode has the correct prefix. If the bytecode already starts with "0x", it is returned as is. Otherwise, the prefix "0x" is added to the bytecode.

Example

import { ensureBytecodePrefix } from "thirdweb/utils/bytecode/prefix";
const bytecode =
"363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3";
const prefixedBytecode = ensureBytecodePrefix(bytecode);
console.log(prefixedBytecode);
function ensureBytecodePrefix(bytecode: string): Hex;

Parameters

The bytecode to ensure the prefix for.

Type

let bytecode: string;

Returns

let returnType: `0x${string}`;

The bytecode with the correct prefix.