Account & IntentBuilder Setup

In the intents.js SDK, the IntentBuilder and Account make it easy to interact with DeFi protocols across multiple blockchains, removing the complexity of handling the technical details.

Install the SDK
  • IntentBuilder: constructs, formats, and executes intents, simplifying complex cross-chain operations.

  • Account: represents a unified wallet that works across multiple blockchains. It is attached to a signer (the user’s authentication method) and manages interactions securely across chains. This removes the need for multiple wallets or private keys while ensuring full control over assets in a non-custodial way.

Both IntentBuilder and Account use chain configurations (chainConfigs) to define the blockchains available for use. Each blockchain has its own bundler to manage operations, and only chains specified in chainConfigs will be accessible for operations

Below, we demonstrate how to instantiate the IntentBuilder and Account, essential for executing cross-chain operations.

import { Account, IntentBuilder } from 'intents.js';
import { ethers } from 'ethers';

// Set supported chains
const chainConfigs = {
  1: { rpcUrl: 'YOUR_ETH_RPC_URL', bundlerUrl: 'https://eth.bundler.balloondogs.network' },
  56: { rpcUrl: 'YOUR_BNB_RPC_URL', bundlerUrl: 'https://bsc.bundler.balloondogs.network' },
};

// Create an instance of IntentBuilder
const intentBuilder = await IntentBuilder.createInstance(chainConfigs);

// Create an ethers.js signer for transaction signing
const signer = new ethers.Wallet('your private key');

// Create an account instance with the provided signer and chain configurations
const account = await Account.createInstance(signer, chainConfigs);

Last updated