Boop SDK
The Boop SDK is a TypeScript library for interaction with the Boop account abstraction stack.
It provides easy type-safe access to the Boop Submitter's REST API as well as useful functions when working with boops.
Installation
To install the Boop SDK in your project, use your preferred package manager:
npm
npm install @happy.tech/boop-sdkExample
Here's an example that shows you how to create an account and send a transaction using the SDK. Refer to the API reference for more details.
We use the viem library to provide auxiliary functions.
import { BoopClient } from "@happy.tech/boop-sdk"
import { encodeFunctionData, zeroAddress } from "viem"
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"
import { parseAbi } from "viem/utils"
const ownerPrivateKey = generatePrivateKey()
const owner = privateKeyToAccount(ownerPrivateKey)
const boopClient = new BoopClient({
submitterUrl: "https://submitter.happy.tech",
rpcUrl: "https://rpc.testnet.happy.tech/http",
})
const { address, description: error1 }
= await boopClient.createAccount({ owner: owner.publicKey })
if (address) {
console.log("Your account address is: ", address)
} else {
throw Error("Could not create account: " + error1)
}
// TODO make fields optional in SDK:
// gas fields, nonceTrack, value, extraData, validatorData
const unsignedBoop = {
// mock ERC20 contract deployed on HappyChain Sepolia
dest: 0x02206fac6469b2f59fc2bb9d3bc181fbe703f8b7,
account: address,
nonceValue: 0n, // first one!
payer: zeroAddress, // the HappyChain submitter will pay for it
callData: encodeFunctionData({
abi: parseAbi(["function mint(address _account, uint256 _amount)"]),
functionName: "mint",
args: [address, 100n],
}),
} as Boop // TODO
// TODO needs hash
const boop = await owner.sign({ hash: boopClient.encode(unsignedBoop) })
// No need to estimate gas or simulate — the submitter takes care of it!
const { receipt, description: error2 } = await boopClient.execute({ boop })
if (receipt) {
console.log(
"You are now 100 MockTokenA richer! " +
"Here's a receipt to prove it: ", receipt)
} else {
throw Error("Could not execute boop: " + error2)
}Methods Overview
TODO
simulategetNonceexecutesubmitwaitForReceiptgetStategetPending