Installation And Setup
Install the FuseBox JS SDK:
npm install ethers @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.
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 Console Dashboard.
If you don’t want to enable Paymaster
set it to false. It is default false
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.