@b3dotfun/bondkit SDK

SDK for interacting with Bondkit smart contracts, allowing you to deploy and manage Bondkit tokens.
Installation
Install the package using npm or yarn:
npm install @b3dotfun/bondkit
yarn add @b3dotfun/bondkit
Dependencies
This SDK uses viem
as a peer dependency for interacting with the Ethereum blockchain. You will need to have viem
installed in your project.
npm install viem
yarn add viem
Basic Usage
Here's a quick example of how to use the SDK:
import {
BondkitTokenFactory,
BondkitToken,
getConfig,
} from '@b3dotfun/bondkit';
import { sepolia } from 'viem/chains';
import type { EIP1193Provider } from 'viem';
async function main() {
const chainId = sepolia.id;
const sdkConfig = getConfig(chainId);
console.log(`Using factory: ${sdkConfig.factoryAddress} on chain ${sdkConfig.chain.name}`);
const factory = new BondkitTokenFactory(chainId);
try {
const deployedTokens = await factory.getDeployedBondkitTokens();
console.log("Deployed Bondkit Tokens:", deployedTokens);
if (deployedTokens.length > 0) {
const firstTokenAddress = deployedTokens[0];
console.log(`\n--- Interacting with token: ${firstTokenAddress} ---`);
const token = new BondkitToken(chainId, firstTokenAddress as string);
const name = await token.name();
const symbol = await token.symbol();
const totalSupply = await token.totalSupply();
console.log(`Token Name: ${name}`);
console.log(`Token Symbol: ${symbol}`);
console.log(`Total Supply: ${totalSupply}`);
}
} catch (error) {
console.error("Error fetching deployed tokens or token details:", error);
}
}
main().catch(console.error);
Examples
Detailed examples can be found in the examples
directory of this repository:
examples/01-read-operations.ts
: Demonstrates read-only interactions, such as fetching token details, factory information, and bonding curve data.
examples/02-transactions-buy-sell.ts
: Shows how to perform transactions like buying and selling tokens. Requires a private key with test funds.
examples/03-deploy-token.ts
: Illustrates deploying a new Bondkit token using the factory. Requires a private key with deployer permissions and funds for gas.
To run these examples, you'll typically use a tool like ts-node
:
ts-node examples/01-read-operations.ts
ts-node examples/02-transactions-buy-sell.ts
ts-node examples/03-deploy-token.ts
Key Features
- Deploy New Tokens: Use
BondkitTokenFactory.deployBondkitToken()
.
- Manage Existing Tokens: Interact with token instances using the
BondkitToken
class.
- Read token details (name, symbol, totalSupply, owner, etc.).
- ERC20 operations:
balanceOf
, transfer
, approve
, allowance
.
- Bonding curve interactions:
buy
, sell
, getAmountOfTokensToBuy
, getAmountOfEthToSell
.
- Lifecycle management:
migrateToDex
, transferOwnership
.
- Configuration: Get chain-specific configurations using
getConfig()
.
Remember to replace placeholder addresses and values in the usage example with actual data for testing.