Metafi React SDK
Developer PortalMore Docs ⏷About Us ⏷Help & Resources ⏷
v1.2.8 (Latest)
v1.2.8 (Latest)
  • What's new in this version?
  • Get Started
  • SDK Reference
    • Provider Initialisation
    • Login
    • ShowWallet
    • HideWallet
    • TransferTokens
    • CallGenericReadFunction
    • CallGenericWriteFunction
    • CallGaslessFunction
    • Checkout
    • RegisterToken
    • RetrieveUser
    • Disconnect
  • Constants
    • Chain
    • Asset
  • UI Customization
Powered by GitBook
On this page
  • Demo
  • Step 1: Install the library
  • Step 2a: Initialise Metafi Component
  • Step 2b: Setup User Login
  • Step 3: Function Invocation

Get Started

PreviousWhat's new in this version?NextSDK Reference

Last updated 2 years ago

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

Demo

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

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>
    );
};

Step 2b: Setup User Login

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

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>
        </>
    );
};

Refer to the section on for more information on MetafiProvider.

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

Go to the projects page of the 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 section of our documentation.

Developer Portal
demo application
Discord
Provider Initialisation
UI Customisation
Developer Portal
Login