These docs are for v1.7. Click to read the latest docs for v2.1.

Export Wallet

Export a user's custodial wallets to non-custodial wallet, to do so, retrieve mnemonics.

Before you begin

Let's start 🚀

  1. Use the /wallet/export with an RSA key in the body.
const keyPair = await window.crypto.subtle.generateKey(
    {
      name: 'RSA-OAEP',
      modulusLength: 4096,
      publicExponent: new Uint8Array([1, 0, 1]),
      hash: 'sha-256'
    },
  true,
  ['encrypt', 'decrypt']
);

const privateKey = keyPair.privateKey;
const pubKey = await window.crypto.subtle.exportKey('jwk', keyPair.publicKey);
{
  "pubKey": 
    {"alg":"RSA-OAEP-256",
    "e":"AQAB",
    "ext":true,
    "key_ops":["encrypt"],
    "kty":"RSA",
     "n":"zLd3GbxqykWHqxb2i_8SGmMJsuB7gQ97gwSI8iPW8o6xn3G4Mrcxg4yVi96cF_vcP2Pfpp9OsQZtikRGyTU9yl0yPF2x22voCr-iREcx3WB98BajCp60lAJ0VEw1g3qy-L1PMF7tGP5ItYC6SExYBeCj76RtJ4iutI6xqbHW7TosCEcZ2D3xAkG1alKh6G-fz02eAMFQ4X_zsnuiA5lfLYn6UpfJoITG0rYfu_wK8koKVsEccBeqfAJaYzXRXRm5YpF9tS4FiNkOSMPbt_V8qcq4F8mJqiERcJ1htyPzML2wZBzFvIXAcPlFVAUuUunbrP9N0iCTJkfCwMbFIw0Snqx8nzu2iakjUml4Yv-O_Rl-0p3KLVq38de10QMz1s5u3floeCqKK8GNyd5MVazXX-nbYaySLpS_Q90gCYPZpUYCV2QU640Ff_frHOIkhrQK4c40eUYPqX6Rf8KUixzQ3tPpVBipkEO1k60G6umyhJcbdcVmKgAiKWu7IHYNBK6A2d9gEJh1JaM22o_Dj7nzXcGJp9KnlsHQeHrT_6jlaWeoib9U9JjRySuL3gYzyb8xxI8XfMT02ceRAWWjFcBiUKoCpf-pMxURuY56nNWkFlfcceq2rfZW6MuIhWJZ9cjWLrDxmYpoqG7IkWdK58l4fNV4sZkHDMKO4134YAccgtc"}

}

📌

Pair of keys is used: a public key and a private key. The public key is used to encrypt data, while the private key is used to decrypt it.

Result:

httpCodeDescription
200Mnemonics are returned.
400Not authorized. You must be authenticated.
{
    "cipher": "xk4WXPNHaTq7fnXP8pv25zCCiPsv52WTxH3IVzmKd8UC5XlWJbE2+HCrxoEskZNmWDLViO7ErQhTZH6t9PX/8dgS224LGBO6s9ODwgpcraBQsn6A0mtkQIQVB/2nOp8WGb9aRCVUEGLTUdIFGQUTPcEGHiXkxfT6kpyAz0k5TDPk08bhmEXCl10s/6p7Sx6NfQx2CzE1yfvcwcg/cj9RbmdAoMYHq4lpaM0m4DFrwGUVIOhsuAtfRoQen6zUnbhCf+Kiu/GdvBoxI0sK9OLxCgBnkwTxnw8C23j6jsXsZNpY1rVnop0nzSWfQwoAW1+p1YVJh/ovZla2oH/nrBzT3l/aWn62ZSXAIWorY2GepLl/G2mu7NoX6OZFshQNEm9sogRdowxN9BX4ktaQvgm+yix6wzLVEDzhuWoJS7pY0G5y+lH4SC1j2+yGIksNKJjZB6dTpfzKZ1xLHYRxeNVEDb2/1May0H7z2AE78KHAhNJgZ8k9SB02zdMjf/0j+A4Py4+1FGAjP7O5JKe762D2jAcZs5fRLieyCuklDnngozbM971sRWgxnrSkK/Be2AcPAAiBqsW8G2poaaMmx9mIIuasJemDJXRA135mMpXsJnZoR8LHJQLafcVA5K9dZZySyHMAUT+aZn9ym5QEjoBou4g34OtvcKxd4wdh/pjnBy0="
}
{
  "message": "no bearer token found in header authorization or not well formated"
}
  1. Decode cipher.
const mnemonicBuff = await window.crypto.subtle.decrypt(
  { name: 'RSA-OAEP' },
  privateKey,
  Buffer.from(exportRes.cipher, 'base64')
);

const dataView = new DataView(mnemonicBuff);
const mnemonic = new TextDecoder('utf-8').decode(dataView);