Skip to content

getAddress

Get the wallet addresses for all supported chains.

Usage

ts
const addresses = await Turing.getAddress();

Parameters

This method takes no parameters.

Returns

ts
interface GetAddressResponse {
  tbcAddress?: string;   // TBC chain address (BVM account)
  btcAddress?: string;   // BTC chain address (BVM account)
  ethAddress?: string;   // Ethereum address (EVM account)
  bnbAddress?: string;   // BSC address (EVM account)
}

The returned fields depend on the user's account type:

Account TypeFields
BVM accounttbcAddress, btcAddress
EVM accountethAddress, bnbAddress
All accountstbcAddress, btcAddress, ethAddress, bnbAddress

Error Handling

ts
try {
  const addresses = await Turing.getAddress();
  console.log("TBC:", addresses.tbcAddress);
  console.log("BTC:", addresses.btcAddress);
  console.log("ETH:", addresses.ethAddress);
  console.log("BNB:", addresses.bnbAddress);
} catch (error) {
  console.error("Failed to get addresses:", error);
}

Subscribe to changes

When the user switches the active account inside the wallet, the dapp receives a TuringAccountChanged event with the new addresses, so there is no need to poll getAddress().

ts
window.addEventListener("TuringAccountChanged", (event) => {
  const { addresses } = event.detail;
  // `addresses` has the same shape as Turing.getAddress()
});
ts
interface TuringAccountChangedDetail {
  addresses: GetAddressResponse;
}

The event only fires while the dapp is connected, and only on changes after the initial connect() (the initial addresses are returned by Turing.connect() directly).

Live Example

Live Example

Turing.getAddress()

Unknown
Use the wallet control in the top navigation before running this example.

This method does not require parameters.

Code Preview
const addresses = await Turing.getAddress();
console.log(addresses);
Make sure the browser extension is enabled, or open this page inside Turing Wallet on mobile.