Get Started

You will need an API Key to get started. Get your key by signing up on the Developer Portal.

Demo

To view a sample integration, please refer to our demo application. Alternatively, please post any other questions on our Discord.

Step 1: Install the library

First, install the library via your terminal.

# install via Yarn
yarn add @metafi/metafi-react-package

# or via NPM
npm install @metafi/metafi-react-package

Step 2a: Initialise Metafi Component

Next, wrap your top level component as follows with the Metafi provider.

import { MetafiProvider, chains } from '@metafi/metafi-react-package';

function App() {
    return (
    <MetafiProvider 
        apiKey={apiKey} 
        secretKey={secretKey} 
        supportedChains={supportedChains}
        customTokens={customTokens}
        options={options}
        metafiSSO={metafiSSO}
    >
        <YourComponents>
        ...
        </YourComponents>
    </MetafiProvider>
    );
};

Refer to the section on Provider Initialisation for more information on MetafiProvider.

For more information on customising your wallet interface, please refer to the section on UI Customisation.

Step 2b: Setup User Login

This step is only required if you are using your own login/authentication mechanism

Go to the projects page of the Developer Portal and navigate to Settings. There you can update the URL which we will use to authenticate your user token. Once this URL is updated, you can create a wallet for a user by passing in their userIdentifier and jwtToken into our SDK.

More information on this can be found in the Login section of our documentation.

Step 3: Function Invocation

You're done! You can now invoke the functions that you need.

import { useMetafi } from '@metafi/metafi-react-package';

function displayWallet(userIdentifier) {
    const { ShowWallet } = useMetafi();
    
    return (
        <>
           <button onClick={()=>ShowWallet()}>Show Wallet</button>
        </>
    );
};

Last updated