Installation And Setup
Installation
- Web
- Flutter
- npm
- Yarn
- Bun
- pnpm
npm install @fuseio/fusebox-web-sdk
yarn add @fuseio/fusebox-web-sdk
bun add @fuseio/fusebox-web-sdk
pnpm add @fuseio/fusebox-web-sdk
Install the FuseSDK using Dart or flutter.
dart pub add fuse_wallet_sdk
flutter pub add fuse_wallet_sdk
Once you have installed the package, you can import it into your code:
- Web
- Flutter
import {FuseSDK} from "@fuseio/fusebox-web-sdk";
import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';
Usage
To use the 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.
Whether you aim to fetch or create a smart wallet, relay an ERC20/FUSE transfer, relay an ERC721 transfer, relay a generic transaction, swap tokens, or stake tokens, the FuseSDK
class has you covered. Additionally, the SDK provides data features that allow you to get the list of tokens owned by an address, get token details, and get a smart wallet's token balance.
The following code initializes the Fuse SDK and creates an instance of the FuseSDK
class. The apiKey
variable should be set to your own API key.
- Web
- Flutter
import {ethers} from "ethers";
import {FuseSDK} from "@fuseio/fusebox-web-sdk";
const apiKey = "API_KEY";
const credentials = new ethers.Wallet("PRIVATE_KEY");
const fuseSDK = await FuseSDK.init(apiKey, credentials);
import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';
final apiKey = 'API_KEY';
final privateKey = EthPrivateKey.fromHex('YOUR_PRIVATE_KEY');
final fuseSDK = await FuseSDK.init(apiKey, privateKey);
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.