AbstractJS
SDK
AbstractJS
is the ultimate SDK for building solutions on top of smart accounts, enabling developers to effortlessly build
user friendly apps which leverage the latest innovations in blockchain execution, including chain abstraction,
gas sponsorships, managing smart account modules and much more...
Modern onchain app teams work in a multi-chain environment, where they have to interact with multiple chains, bridges and
intent solvers. AbstractJS
makes navigating this complex multi-chain hybrid execution environment a breeze, with a rich
library of multichain utilities. These include functions like:
- Getting a unified multichain balance,
- Handling smart account deployments across multiple chains,
- Executing intents,
- Effortessly building complex multi-chain sequences,
- Handling token deployements across multiple chains
Built on top of the industry-standard viem
SDK, AbstractJS enables developes to seamlessly interact with:
- Biconomy Superbundler and the Modular Execution Environment (MEE)
- ERC4337 Bundler & Paymaster infrastructure
AbstractJS
Highlight Features
npm install @biconomy/abstractjs viem
This is a high level overview of the features of AbstractJS
. To dive straight into coding with the SDK, check our
quickstart guides:
- Building a Chain Abstracted Application
- Executing Intents
- Sponsoring a Transaction with Paymasters
- Cross-Chain Gas Abstraction
- Working With Account Modules
Manage Smart Accounts
AbstractJS enables developers to deploy and manage Modular Smart Accounts. The SDK is vendor neutral and supports both Biconomy Nexus account as well as other smart account implementations. Click here for a list of supported providers.
Multichain Smart Account Management
Deploying and managing smart account deployments across multiple chains can be a pain. AbstractJS comes with buil-in utilities to handle smart account deployment on multiple chains
// Wraps a Nexus Smart Account deployment on Polygon, Optimism and Base
const mcNexus = await toMultichainNexusAccount({
chains: [polygon, optimism, base],
signer: signer,
});
Use Modular Execution Environments and Bundlers/Paymasters
AbstractJS supports transaction execution through Biconomy Modular Execution Environment or through ERC4337 Bundlers and Paymasters.
Modular Execution Environment (MEE)
Biconomy Modular Execution Environment (MEE) enables developers to execute complex transaction and intent sequences across multiple blockchains with a single user signature.
// Modular Execution Environment Client
const meeClient = createMeeClient({
account: mcNexus // Multichain Nexus account wrapper
})
// Get quote for execution
const quote = await getQuote(meeClient, {
instructions: [
{
calls: [ to: zeroAddress, gasLimit: 100_000n, value: 0n ],
chainId: optimism.id // Transaction on Optimism
},
{
calls: [ to: zeroAddress, gasLimit: 100_000n, value: 0n ],
chainId: base.id // Transaction on Base
},
],
feeToken: {
address: mcUSDC.deploymentOn(base.id).address, // USDC address on Base
chainId: base.id // Pay for gas on Base
}
})
// Execute entire sequence of actions across multiple
// blockchains with a single user signature.
const receipt = await executeQuote(meeClient, { quote })
ERC4337 Bundlers and Paymasters
Bundlers and Paymasters enable gas sponsorship, paying for gas with ERC20 tokens and single-chain batch execution
const nexusClient = await createSmartAccountClient({
signer: account,
chain: baseSepolia,
transport: http(),
bundlerTransport: http(bundlerUrl),
paymaster: createBicoPaymasterClient({ paymasterUrl }),
});
const hash = await nexusClient.sendTransaction({
calls: [
{
to: "0xf5715961C550FC497832063a98eA34673ad7C816",
value: parseEther("0"),
},
],
});
const receipt = await nexusClient.waitForTransactionReceipt({ hash });
Multichain Utilities
AbstractJS comes built-in with utility types and functions, making it easy for developers to work in a multichain environment.
Multichain Contract Mapping
AbstractJS exposes functions for wrapping smart contract deployments across multiple chains in a single object, enabling developers to quickly encode actions on any chain.
const mcAAVE = getMultichainContract({
abi: parseAbi([
"function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)",
]),
deployments: [
["0x794a61358D6845594F94dc1DB02A252b5b4814aD", optimism.id],
["0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", base.id],
],
});
Fetching Unified ERC20 Balance
A single function call to fetch a unified balance across all supported chains
const unifiedBalance = await getUnifiedERC20Balance({
multichainERC20: mcUSDC, // Your multichain token contract
multichainAccount: mcNexus // Your multichain account
});
Bridging Plugins
AbstractJS exposes pre-built plugins for interacting with bridges such as Across or LiFi. Utility functions can encode multiple bridging transactions at the same time - when users need to fetch funds from multiple chains.
Triggering an Across intent with a built-in plugin
import { AcrossPlugin } from "./plugins";
AcrossPlugin.encodeBridgeUserOp({
bridgingAmount: parseUnits('10', 6),
fromChain: optimism,
toChain: base,
multichainAccount: mcNexus,
multichainToken: mcUSDC
})
Calculating optimal bridging / intent routes
AbstractJS has utilities to help you calculate optimal routes for moving funds from one chain to another.
buildMultichainBridgingInstructions({
amount: parseUnits('10',6),
bridgingPlugins: [AcrossPlugin],
multichainAccount: mcNexus,
toChain: optimism,
unifiedBalance: await getUnifiedERC20Balance({
multichainAccount: mcNexus,
multichainERC20: mcUSDC
}),
isTxFeePaidWithTokenBeingBridged: false
})
Effortless Single-chain and Multi-chain Orchestration
What used to take thousands of lines of code, can be achieved in a dozen lines of code with AbstractJS. Let's check an example of a transaction which:
- Pays for gas with USDC on Base
- Moves USDC from multiple chains to Optimsim
- Approves AAVE to use USDC on Optimism
- Supplies to AAVE on Optimsim
const sTx = supertransaction({
account: mcNexus,
feeToken: mcUSDC.on(base),
instructions: [
await requireERC20Balance({
token: mcUSDC,
chain: optimism,
providedAmount: supplyAmount,
}),
mcUSDC.write({
chain: optimism,
functionName: "approve",
args: [mcAAVE.deploymentOn(optimism), inTimeBalanceOf(mcUSDC)],
}),
mcAAVE.write({
chain: optimism,
functionName: "supply",
args: [
mcUSDC.addressOn(optimism),
inTimeBalanceOf(mcUSDC),
zeroAddress,
0,
],
}),
],
});
Multichain Batch Execution for EOAs
AbstractJS comes with built-in support for the Biconomy Fusion module - enabling developers to execute batch transactions across multiple chains from user EOA accounts - with a single signature.
The Fusion Module gives regular EOAs the ability to batch execute transactions across one or multiple chains, while paying for gas on only one chain!
Before Fusion
❌ Three user signatures
❌ User needs to have gas on two chains
❌ User needs to wait for the bridge to finish before signing the second tx
After Fusion
✅ One user signature
✅ Needs gas on only one chain
✅ Set and forget: User signs and all transactions are executed fully
const signedFusionQuote = await signFusionQuote(meeClient, {
// Transfer required funds from EOA to Companion SCA
trigger: mcUSDC.on(optimism.id).transfer([
mcNexus.deploymentOn(optimism.id).address, // smart account instance on Base
transactionUsedAmount, // amount used by the batch execute
]),
// After receiving funds, execute batch transactions
// across one or more chains
quote: await getQuote(meeClient, {
instructions: instructions, // e.g. bridge from Optimism to Base, then supply to Morpho pool
feeToken: {
// Pay for extra execution in any token
address: paymentToken,
chainId: paymentChain.id,
},
}),
});