Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Overview
The global wallet interface does not provide a way to export the wallet key. If you’d like users to be able to export their global wallet key, you can provide an easy interface for them to log into their wallet and export the key.You should prompt the user to log in with exactly the same credentials as they use to log in to the global wallet.
Pre-requisites
- Check the ‘default wallet version’ in the embedded wallet section of the dashboard
- Ensure you are using the same environment ID as you do for your global wallet implementation.
Steps
- V3 Wallets
- V2 Wallets
Use the
exportPrivateKey method- Get the primary wallet
- Guard against no primary wallet or no embedded wallet
- Get the connector
- Define the display container
- Export the private key