RetrievePrivateKey

Description

Downloads the user's private key as a .txt file. Please ensure that the user is made aware of the risks of exporting their private key before allowing them to pick this option.

Details

Signature

async RetrievePrivateKey(apiKey, walletAddress)

Arguments

ParameterTypeDefinition

apiKey

String

The API Key generated from the Developer Portal

walletAddress

String

The public wallet address for which you would like to export the private key. The wallet address can be retrieved from the RetrieveUser endpoint.

Return Value

This function returns a Promise that resolves to the following object:

{
    "statusCode": 1/0,
    "data": "data" // always null
    "error": "error" // error if any, else null
}

Example

import { RetrievePrivateKey } from '@metafi/metafi-js-package';

function App() {

    const handleRetrievePrivateKey = async () => {
        var result = await RetrievePrivateKey("WALLET-ADDRESS", "YOUR-API-KEY");
        console.log("result after retrieving private key", result);
    }
    
    return (
        <div>
	    <button onClick={handleRetrievePrivateKey}>Download Your Private Key</button>
        </div>
    );
}

export default App;

Last updated