HomeGuidesAPI ReferenceChangelog
GuidesAPI ReferenceCommunityDiscordBlogFAQBug BountyAnnouncementsChange Log
API Reference

signMessageV2

Sign a string

signMessageV2 can not only sign the Hex format string, but also sign a plaintext string. Please use the verifyMessageV2 interface for signature verification.

Usage

// Call directly,privatekey is needed in this way
TronWeb.Trx.signMessageV2(message, privateKey)

// Called via the instantiated tronWeb object
tronWeb.trx.signMessageV2(message, privateKey);

Parameters

ParameterDescriptionData Type
messageMessage to be signedBytes / String
privateKeyThe private key used for signing, optional parameter. Default to use the private key passed in when building tronweb object.String

Returns

String - the signature.

Example

var messge = 'hello world';
var signature = await tronWeb.trx.signMessageV2(messge);
console.log(signature);
>0x1d1b0779da653630d29fc4f1ea1e5a109a30d52e21e7657fa896d2fccc3b430b14089377e13b6ed35ef371a1c91873773d568219d1100fa8595e5f2eec39e3e41c