Skip to main content
Version: 6.4.0

updateWitness <src>

Added in 6.4.0.

Create an unsigned WitnessUpdateContract transaction that updates the node URL of an existing witness (Super Representative). The owner account must already be a witness — see applyForSR to register one.

Usage

// Format
const transaction = await tronWeb.transactionBuilder.updateWitness(address, url, options);

Parameters

ArgumentDescriptionType
addressThe witness owner address (hexstring or base58). Defaults to the instance's defaultAddress.hex.string
urlThe new witness node URL. Must be a valid URL and at most 256 characters.string
optionsOptional. See the fields below.{ permissionId?: number, blockHeader?: object }
  • permissionId — permission id for multi-signature.
  • blockHeader — a partial transaction raw_data (e.g. ref_block_bytes, ref_block_hash, expiration) that pins the reference block, typically obtained from await tronWeb.trx.getCurrentRefBlockParams().

An invalid or over-long (> 256 chars) URL throws Invalid url provided.

Returns

Unsigned transaction object. It is not broadcast — sign and send it with tronWeb.trx.sign and tronWeb.trx.sendRawTransaction for it to take effect on-chain.

Example

const transaction = await tronWeb.transactionBuilder.updateWitness(
'TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY',
'https://xtron-updated.network'
);
console.log(transaction);
{
visible: false,
txID: 'b8d...e0c9',
raw_data: {
contract: [
{
parameter: {
value: {
owner_address: '41928c9af0651632157ef27a2cf17ca72c575a4d21',
update_url: '68747470733a2f2f7874726f6e2d757064617465642e6e6574776f726b'
},
type_url: 'type.googleapis.com/protocol.WitnessUpdateContract'
},
type: 'WitnessUpdateContract'
}
],
ref_block_bytes: '...',
ref_block_hash: '...',
expiration: 1718000000000,
timestamp: 1717999940000
},
raw_data_hex: '...'
}