Skip to main content

TRON (tron-sign-request)

ur:tron-sign-requestur:tron-signatureraw_data protobufTIP-191

BitTool Signer uses the public Keystone TRON UR types. Do not send TronLink or TokenPocket action JSON, URL schemes or the old keystone-sign-request; they are rejected.

tron-sign-request​

KeyFieldTypeContent
1request-id37(bytes)Exactly 16 random bytes
2sign-databytesdata-type 1: the raw_data protobuf bytes · data-type 2: the message bytes
3data-typeuint1 transaction · 2 personal message
4derivation-path304(crypto-keypath)m/44'/195'/0'/0/i with master fingerprint
5addressbytes (21)0x41 ‖ 20-byte account ID: the Base58Check-decoded address, not the text
6origintextShown to the user

data-type 1: transactions​

sign-data is the transaction's raw_data serialized as protobuf: the bytes of raw_data_hex, as returned by TronWeb or the /wallet/createtransaction and /wallet/triggersmartcontract APIs. Not the whole Transaction message (which wraps raw_data and signature), not hex text, and not the txID.

The signer computes txID = SHA-256(raw_data) and signs that digest. Rules:

RuleDetail
One contractExactly one entry in raw_data.contract.
Timing fieldsref_block_bytes (2 bytes), ref_block_hash (8 bytes), timestamp > 0 and expiration > timestamp.
Fee limitRequired (> 0) for TriggerSmartContract. A high fee limit is shown as a warning.
PermissionPermission_id 0 (owner) or an active permission ID; 1 (witness) is rejected.
Strict protobufUnknown fields, duplicate fields and non-canonical varints are rejected.
TRC-10Not supported, including call_token_value in contract calls.

Supported contracts:

TypeContractReview
1TransferContractTRX amount and recipient
31TriggerSmartContractTRC-20, TRC-721 and TRC-1155 transfers and approvals are decoded (e.g. USDT transfer); other calls are shown as raw calldata and need explicit consent
46AccountPermissionUpdateContractOwner/active permissions, keys, weights, thresholds; always high risk
54–59Stake 2.0 and resources: FreezeBalanceV2, UnfreezeBalanceV2, WithdrawExpireUnfreeze, DelegateResource, UnDelegateResource, CancelAllUnfreezeV2Amounts, resource type, receiver, lock

data-type 2: messages​

sign-data is the message bytes (1–8,192). The signer follows TIP-191, the scheme of TronWeb's signMessageV2:

digest = Keccak-256( 0x19 ‖ "TRON Signed Message:\n" ‖ decimal(length of message) ‖ message )

Text is displayed as text; other bytes are shown as hex, marked opaque, and need explicit consent.

tron-signature​

tron-signature = {
1: 37(request-id bytes),
2: signature ; 65 bytes: r (32) ‖ s (32) ‖ recovery id (0 or 1)
}

The recovery byte is 0 or 1, not 27/28. For transactions, append the 65 bytes as hex to the transaction's signature array, keep raw_data and raw_data_hex unchanged, and broadcast with /wallet/broadcasttransaction (TronWeb: trx.sendRawTransaction).

For messages, many TRON tools (TronWeb's verifyMessageV2, dApps over WalletConnect) expect the last byte as 27/28: add 27 when you hand the signature on. Do not change the transaction signature format.

Code​

TRON has no widely used UR registry library, so this sample writes the CBOR directly with cborg, using the keypath helper:

examples/tron.mjs
import { randomBytes } from 'node:crypto';
import { UR, UREncoder, URDecoder } from '@ngraveio/bc-ur';
import { base58check } from '@scure/base';
import { sha256 } from '@noble/hashes/sha2.js';
import { encode, decode, Tagged } from 'cborg';
import { SigningKey, computeAddress } from 'ethers';
import { keypath } from './keypath.mjs';

const b58 = base58check(sha256);

// `tx` is an unsigned transaction from TronWeb / the TRON HTTP API: { txID, raw_data, raw_data_hex }
export function buildTronRequest(tx, { path, masterFingerprint, address }) {
const requestId = randomBytes(16);
const cbor = encode(new Map([
[1, new Tagged(37, requestId)], // request-id (uuid)
[2, Buffer.from(tx.raw_data_hex, 'hex')], // raw_data protobuf bytes
[3, 1], // data-type: 1 transaction, 2 message
[4, keypath(path, masterFingerprint)], // "m/44'/195'/0'/0/0"
[5, b58.decode(address)], // 21 bytes: 0x41 ‖ 20-byte account ID
[6, 'BitTool Wallet'], // origin
]));
const encoder = new UREncoder(new UR(Buffer.from(cbor), 'tron-sign-request'), 400);
const frames = [];
for (let i = 0; i < encoder.fragmentsLength; i++) frames.push(encoder.nextPart().toUpperCase());
return { requestId, frames };
}
examples/tron.mjs
const tags = { 37: (decode) => decode() }; // tag 37 (uuid): keep the raw bytes

export function attachTronSignature(frames, tx, { requestId, address }) {
const decoder = new URDecoder();
for (const frame of frames) decoder.receivePart(frame);
if (!decoder.isSuccess()) throw new Error('Incomplete or invalid QR');
const ur = decoder.resultUR();
if (ur.type !== 'tron-signature') throw new Error(`Expected tron-signature, got ${ur.type}`);
const response = decode(ur.cbor, { useMaps: true, tags, strict: true });
if (!Buffer.from(response.get(1)).equals(requestId)) throw new Error('Signature is for another request');

const sig = Buffer.from(response.get(2)); // r (32) ‖ s (32) ‖ recovery id (0 or 1)
if (sig.length !== 65 || sig[64] > 1) throw new Error('Unexpected signature format');
const txID = Buffer.from(sha256(Buffer.from(tx.raw_data_hex, 'hex'))).toString('hex');
if (txID !== tx.txID) throw new Error('txID does not match raw_data');

const evmStyle = { r: '0x' + sig.subarray(0, 32).toString('hex'), s: '0x' + sig.subarray(32, 64).toString('hex'), v: 27 + sig[64] };
const recovered = computeAddress(SigningKey.recoverPublicKey('0x' + txID, evmStyle)); // 0x + 20 bytes
if (b58.encode(Buffer.from('41' + recovered.slice(2), 'hex')) !== address) throw new Error('Signed by an unexpected key');

return { ...tx, signature: [...(tx.signature ?? []), sig.toString('hex')] }; // broadcast with sendRawTransaction
}

Test vectors​

All from m/44'/195'/0'/0/0 (TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH) of the test phrase. The reference block, timestamps and txIDs are synthetic; the transactions were never broadcast.

Send 1.5 TRX (1,500,000 sun) to TJRabPrwbZy45sbavfcjinPJC18kjpRTv8.

Unsigned transaction (from your node or TronWeb)
{
"txID": "b396c11e25482bc348d39e620000ef16290d0d17b7649cb94fee63d0203695eb",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"amount": 1500000,
"owner_address": "41c8599111f29c1e1e061265b4af93ea1f274ad78a",
"to_address": "415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb"
},
"type_url": "type.googleapis.com/protocol.TransferContract"
},
"type": "TransferContract"
}
],
"ref_block_bytes": "a1b2",
"ref_block_hash": "0123456789abcdef",
"expiration": 1792310460000,
"timestamp": 1792310400000
},
"raw_data_hex": "0a02a1b222080123456789abcdef40e0fc9cf094345a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a1541c8599111f29c1e1e061265b4af93ea1f274ad78a1215415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb18e0c65b7080a899f09434"
}

Request (your wallet → BitTool Signer)

tron-sign-request2 frames
UR:TRON-SIGN-REQUEST/1-2/LPADAOCSURCYBDFNCLLAHDJOOLADTPDAGDHECKNDDWKIFTGLJLLEBDCEDPFMGWHTAYAOHDLPBKAOOYPRCPAYADCNFEIOLDPYSNWSFZVTZTNSWTMWEEHTIOAYADBGIABKDPJYKKJOIHDMIOJLJLIOJZIHHSJOINJKDMIAJLJNDLJOJPJLJYJLIAJLJZDMGHJPHSJTJKIYIHJPFXJLJTJYJPHSIAJYBGEYBKBZFPSPHKMEBYWZNSCKCKAMKIYKMUHK
1 / 2
CBOR fields
{
"1 request-id": {
"uuid (tag 37)": "5f1e9b2c7d3a4e6f8a0b1c2d3e4f5a08"
},
"2 sign-data": "0a02a1b222080123456789abcdef40e0fc9cf094345a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a1541c8599111f29c1e1e061265b4af93ea1f274ad78a1215415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb18e0c65b7080a899f09434",
"3 data-type": 1,
"4 derivation-path": {
"crypto-keypath (tag 304)": {
"1 components": [
44,
true,
195,
true,
0,
true,
0,
false,
0,
false
],
"2 source-fingerprint": 1942346250
}
},
"5 address": "41c8599111f29c1e1e061265b4af93ea1f274ad78a",
"6 origin": "BitTool Wallet"
}
Show the QR text and raw CBOR
QR text · ur:tron-sign-request
UR:TRON-SIGN-REQUEST/1-2/LPADAOCSURCYBDFNCLLAHDJOOLADTPDAGDHECKNDDWKIFTGLJLLEBDCEDPFMGWHTAYAOHDLPBKAOOYPRCPAYADCNFEIOLDPYSNWSFZVTZTNSWTMWEEHTIOAYADBGIABKDPJYKKJOIHDMIOJLJLIOJZIHHSJOINJKDMIAJLJNDLJOJPJLJYJLIAJLJZDMGHJPHSJTJKIYIHJPFXJLJTJYJPHSIAJYBGEYBKBZFPSPHKMEBYWZNSCKCKAMKIYKMUHK
UR:TRON-SIGN-REQUEST/2-2/LPAOAOCSURCYBDFNCLLAHDJOBGIHQZPEMUWDCTDIGETSLEBGBZFPHHRYTPIMDLPDUOGRUTTPPDYNNTRDFDHGDMWPATZOCSVTSWHPJOLAPDNLWTMWEEAXADAATAADDYOEADLECSDWYKCSSRYKAEYKAEWKAEWKAOCYJKSKTNBKAHGOFPSPHKMEBYWZNSCKCKAMBGIHQZPEMUWDCTDIGETSLEAMJTFWINJYGHJLJLJZCXHGHSJZJZIHJYAECEGYGWVW
UR CBOR (hex)
a601d825505f1e9b2c7d3a4e6f8a0b1c2d3e4f5a080258850a02a1b222080123456789abcdef40e0fc9cf094345a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a1541c8599111f29c1e1e061265b4af93ea1f274ad78a1215415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb18e0c65b7080a899f09434030104d90130a2018a182cf518c3f500f500f400f4021a73c5da0a055541c8599111f29c1e1e061265b4af93ea1f274ad78a066e426974546f6f6c2057616c6c6574

Response (BitTool Signer → your wallet)

Decoded response · ur:tron-signature
{
"request-id": {
"uuid": "5f1e9b2c7d3a4e6f8a0b1c2d3e4f5a08"
},
"signature": "32c82fe12ddef67b967c836692f7a729003481e6b0f070b1ac6ee7742ac27e18611174e6a54efb7f5f5e14adfbb9118bb137f064881777316ed593ea5da4a25d01"
}
Show the QR text and raw CBOR
QR text · ur:tron-signature
UR:TRON-SIGNATURE/OEADTPDAGDHECKNDDWKIFTGLJLLEBDCEDPFMGWHTAYAOHDFPEYSPDLVYDPUEYNKGMTKELSIYMOYLOSDTAEEELYVAPFWTJOPAPSJTVDJYDRSAKBCSHSBYJYVAONGLZOLBHEHYBBPMZORHBYLUPAEMWTIELOCHKTEHJTTLMUWDHLOXOEHLADEEFEIELE
UR CBOR (hex)
a201d825505f1e9b2c7d3a4e6f8a0b1c2d3e4f5a0802584132c82fe12ddef67b967c836692f7a729003481e6b0f070b1ac6ee7742ac27e18611174e6a54efb7f5f5e14adfbb9118bb137f064881777316ed593ea5da4a25d01

Assembled by your wallet

signedTransaction
{
"txID": "b396c11e25482bc348d39e620000ef16290d0d17b7649cb94fee63d0203695eb",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"amount": 1500000,
"owner_address": "41c8599111f29c1e1e061265b4af93ea1f274ad78a",
"to_address": "415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb"
},
"type_url": "type.googleapis.com/protocol.TransferContract"
},
"type": "TransferContract"
}
],
"ref_block_bytes": "a1b2",
"ref_block_hash": "0123456789abcdef",
"expiration": 1792310460000,
"timestamp": 1792310400000
},
"raw_data_hex": "0a02a1b222080123456789abcdef40e0fc9cf094345a67080112630a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412320a1541c8599111f29c1e1e061265b4af93ea1f274ad78a1215415cbdd86a2fa8dc4bddd8a8f69dba48572eec07fb18e0c65b7080a899f09434",
"signature": [
"32c82fe12ddef67b967c836692f7a729003481e6b0f070b1ac6ee7742ac27e18611174e6a54efb7f5f5e14adfbb9118bb137f064881777316ed593ea5da4a25d01"
]
}

Multisig accounts​

For an account with multisig permissions, each member signs separately:

  • Put the member's path and address in keys 4 and 5. The account in owner_address may be a different address, and BitTool Signer never picks a signer just because it appears as owner or as a permission member.
  • Set Permission_id in the contract to the permission being used.
  • BitTool Signer only sees raw_data. Your wallet keeps the signatures already collected, adds each new one, removes duplicates, and checks the on-chain permission (members, weights, threshold, operations) before broadcasting. The signer cannot verify current on-chain permissions offline.