Skip to main content

Installation And Setup

Install the FuseBox JS SDK:

npm install @fuseio/fusebox-web-sdk

Once you have installed the package, you can import it into your JS code:

import { FuseSDK } from "@fuseio/fusebox-web-sdk";

Usage

To use the FuseBox JS SDK in your project, you must create an instance of the FuseSDK class. This class is the key to interacting with the Fuse API using the SDK. Fortunately, the FuseSDK class provides a range of instance methods, allowing you to execute various operations with the API.

Using the SDK requires the use of the EthersJS library. We require the EthersJS library methods for creating Wallets.

npm install ethers

The following code initializes the Fuse SDK and creates an instance of the FuseSDK class. The publicApiKey variable should be set to your own API key.

Replace YOUR_API_KEY with your actual API key obtained from the Fuse Developer Dashboard. To enable Paymaster, set it as the third argument in the init() method. withPaymaster: true . It is default false where the argument is not provided.

import { ethers } from 'ethers';
import { FuseSDK } from '@fuseio/fuse-web-sdk';

const publicApiKey = 'YOUR_API_KEY';
const credentials = new ethers.Wallet(process.env.PRIVATE_KEY as string);
const fuse = await FuseSDK.init(publicApiKey, credentials);

Once you have created an instance of the FuseSDK class, you can use its instance methods to interact with the Fuse API. In the following section, we will cover the available methods of the SDK.

Was this page helpful?