setPrivateKey <src>
Set a private key used with the TronWeb instance, used for obtaining the address, signing transactions, and getting balances.
❗️WARNING :
Do not use this with any web/user facing TronWeb instances. This will leak the private key.
Usage
TronWeb.setPrivateKey(private key);
Parameters
| Parameter | Description | Data Type |
|---|---|---|
| private key | The private key to be set. Since 6.4.0 a leading 0x prefix is accepted and stripped before storing. | String |
Returns
No return value
Example
tronWeb.setPrivateKey('AD71****7509');
tronWeb.defaultPrivateKey
'AD71****7509'
// Since 6.4.0 a leading `0x` prefix is accepted and stripped before storing
tronWeb.setPrivateKey('0xAD71****7509');
tronWeb.defaultPrivateKey
'AD71****7509'