You can securely export the private key for a WaaS wallet account. For that, you’ll need to specify an HTML element to be used to inject an iframe containing the private key.

Usage

import { exportWaasPrivateKey } from '@dynamic-labs-sdk/client/waas';
import { isDynamicWaasConnector } from "@dynamic-labs/wallet-connector-core";

const exportPrivateKey = async (primaryWallet) => {
  if (!isDynamicWaasConnector(primaryWallet?.connector)) {
    return;
  }

  await primaryWallet?.connector.exportPrivateKey({
    accountAddress: primaryWallet.address,
    displayContainer: document.getElementById('display-container'),
  });
};

// Add a container in your UI to inject the iframe
// E.g: <div id="display-container"></div>

Error Handling

  • If the specified wallet account is not a WaaS WalletAccount, it will throw an NotWaasWalletAccountError error.