Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

Switches the private key.

exchange.IO(k, key)

Examples

Switch the private key used by the exchange object.

javascript
function main() { // "Private Key" represents the private key string, which needs to be filled in specifically exchange.IO("key", "Private Key") }

Arguments

NameTypeRequiredDescription

k

string

Yes

Function of exchange.IO(). When set to key, it indicates that the function is used to switch private keys.

key

string

Yes

Private key string.

See Also

Remarks

The exchange.IO() function supports private key switching functionality, allowing operations on multiple wallet addresses. You can also add multiple exchange objects (refer to: exchanges) to operate multiple wallet addresses.

For private key switching operations: exchange.IO("key", "xxx"), concurrent switching is not supported.

The private key is a hex string with an optional 0x prefix. An invalid key is reported as an error and nothing is switched. The key is only kept in memory and never written to the log; after switching, getting the address, signing and sending transactions all use the new key.