signMessageV1

Sign a hex formatted string. Deprecated. Suggest to use signMessageV2 to sign a hex formatted string

This interface is used to sign the Hex format string, and the signature verification uses verifyMessage interface.

❗️

WARNING

Do not use this in any web / user-facing applications. This will expose the private key.

Usage

// sign a Hex formatted string
tronWeb.trx.sign(str, privateKey)

Input Parameters

ParameterDescriptionData Type
strHex formatted stringString
privateKeyThe private key used for signing. Optional. The default value is the private key passed in when constructing tronweb object.String

Example

var str = "helloworld"; 
var HexStr = tronWeb.toHex(str);
var signedStr = await tronWeb.trx.sign(HexStr, privateKey);
console.log(signedStr)

>0xe89b777b011b678c9f52e464117f8a8a2193f2cb8d37cbb9e1bd7bd8905fb79046185ea458fab36ed387d60b0842b59b15c7a419797575986492d0271a91d9e71b