Skip to main content
Version: 6.3.0

toHex <src>

Convert any value to HEX.

Note: This function does not convert TRON address to Hex. If you wish to specifically convert TRX addresses to HEX, please use TronWeb.address.toHex instead.

Usage

TronWeb.toHex(value);

Parameters

ParameterDescriptionData Type
valueThe value to be converted to HEX.String, Number, Object, Array or BigNumber

Returns

String - The hexadecimal value of the passed in value.

Example


TronWeb.toHex("abcABC")
"0x616263414243"
// If it is an object or array type, it will first be converted to a string using JSON.stringify.
TronWeb.toHex({ abc: "ABC" })
"0x7b22616263223a22414243227d"