Links

Get Started

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

Description

The Metafi JS SDK offers you the option to completely white-label and customise the UI of the wallet experience for your users. Please refer to the steps below to begin integration , and additionally, please post any other questions on our Discord channel.
To view a sample integration, please refer to our demo application.

Step 1: Install the library

First, install the library via your terminal.
1
# install via Yarn
2
yarn add @metafi/metafi-js-package
3
4
# or via NPM
5
npm install @metafi/metafi-js-package

Step 2: Setup User Login

Go to your project page in 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.
import { Login } from '@metafi/metafi-js-package';
import { getLoginToken } from './controllers/login'
function App() {
const handleLogin = async () => {
var email = "[email protected]";
var jwtToken = getLoginToken(email); // your logic to login user
var result = await Login(
email,
jwtToken,
"YOUR-API-KEY",
"YOUR-SECRET-KEY"
);
console.log("Login results", result);
}
return (
<div>
<button onClick={handleLogin}>Handle login</button>
</div>
);
}
export default App;

Step 3: Function Invocation

You're done! You can now invoke the functions that you need.
1
import stakeContractAbi from './contracts/abi/stakeContract.json'
2
import {
3
CallGenericWriteFunction,
4
ConvertNumberToBigNumber,
5
chains
6
} from '@metafi/metafi-js-package';
7
8
function App() {
9
const stakeTokens = () => {
10
CallGenericWriteFunction({
11
chain: chains.eth,
12
contractAddress: "0xF5C9F957705bea56a7e806943f98F7877B995826",
13
functionABI: stakeContractAbi.abi,
14
functionName: "stake",
15
value: ConvertNumberToBigNumber(1, 18),
16
params: [],
17
callback: (res) => {
18
console.log(res);
19
}
20
},
21
"YOUR-API-KEY"
22
);
23
}
24
25
return (
26
<div>
27
<button onClick={stakeTokens}>stakeTokens</button>
28
</div>
29
);
30
}
31
32
export default App;
33