Skip to content

Multi-Signature Transfer

Overview

For this section, you may refer to General Transfer

Prerequisite: The DApp connection has been authorized via eth_requestAccounts (see Start Developing).

Query active permissions

multiSign requires a valid permissionId for an active permission on the signing account. Active permissions are returned by tronWeb.trx.getAccount(address) under the active_permission[] field; each entry exposes id, permission_name, threshold, and the keys[] array (address + weight). Owner permissions have a fixed id of 0 and are exposed under owner_permission separately.

const tronweb = window.tron.tronWeb;
const account = await tronweb.trx.getAccount(tronweb.defaultAddress.base58);
// account.active_permission is the array — pick the id whose keys[] includes
// the address you intend to sign with, and whose weight + threshold allow the tx.
const activePermissions = account.active_permission ?? [];
console.log(activePermissions.map(p => ({ id: p.id, name: p.permission_name, threshold: p.threshold })));

Use the resulting id as permissionId below.

Specification

Example

const tronweb = window.tron.tronWeb;
const toAddress = "TRKb2nAnCBfwxnLxgoKJro6VbyA6QmsuXq";
// fromAddress = the account whose active permission controls the funds (the tx owner).
// It is not necessarily the connected signer: if the connected account is only a
// co-signer listed in that permission's keys[], set fromAddress to the controlled account.
const fromAddress = tronweb.defaultAddress.base58;
const activePermissionId = 2; // obtained via tronWeb.trx.getAccount(fromAddress).active_permission
const tx = await tronweb.transactionBuilder.sendTrx(
  toAddress, 10, fromAddress,
  { permissionId: activePermissionId }
); // Step 1
try {
  const signedTx = await tronweb.trx.multiSign(tx, undefined, activePermissionId); // Step 2
  const res = await tronweb.trx.sendRawTransaction(signedTx); // Step 3
  if (!res.result) {
    // Node rejections are returned, not thrown — see Errors below.
    console.error(res.code, res.message && tronweb.toUtf8(res.message));
  }
} catch (e) {}

If the user chooses “Reject” in the pop-up window, an exception will be thrown, which the developer can catch for further processing. If the user chooses “Sign” in the pop-up window, the DApp receives and broadcasts the signed transaction.

Note that the broadcast only collects one signature in this call — a fully signed multi-sig tx requires the threshold to be met across multiple multiSign calls (one per co-signer). Track the partially-signed transaction off-chain (or via the MCP tl_multisig_* tools) until the threshold is reached, then broadcast.

Errors

Error shape: On the TronLink-injected tronWeb (extension 4.0.0 and later), when the user rejects trx.sign, trx.multiSign, or trx.signMessageV2, the promise rejects with the plain string 'Confirmation declined by user' — not an Error object, and without a numeric code. The { code: 4001, message: 'User rejected the request.' } object is returned only by window.tron.request(...) methods such as eth_requestAccounts. Other failures (locked wallet, invalid payload, watch-only account) use other values — see Handling rejections. Do not automatically retry signing.

Code Meaning Where it comes from Retryable?
'Confirmation declined by user' (string) User clicked Reject in the signing popup tronWeb.trx.multiSign(...) No — user declined
code: 'SIGERROR', message decodes to Validate signature error: permission isn't exit permissionId does not exist on fromAddress (wrong or revoked). sendTrx does not validate the permission — the node rejects at broadcast Return value of sendRawTransaction(...) (not thrown) No — re-query getAccount(fromAddress).active_permission and rebuild the transaction
code: 'SIGERROR', other Validate signature error: … messages Signatures do not satisfy the permission — e.g. total weight below threshold, or a signer that is not in its keys[] Return value of sendRawTransaction(...) (not thrown) No — collect the missing signatures (one multiSign call per co-signer)
REVERT / OUT_OF_ENERGY / FAILED Broadcast succeeded but execution failed on-chain getTransactionInfo(txid) No — the tx is final; never auto-retry

message in a sendRawTransaction result is hex-encoded; decode it with tronweb.toUtf8(res.message). To check before broadcasting, call tronweb.trx.getSignWeight(signedTx): result.code is PERMISSION_ERROR when the permission does not exist and NOT_ENOUGH_PERMISSION while the signatures are still below threshold.

For cross-surface translation see the Error Code Map.