axolotl-evm
v1.0.0
Published
SDK for interacting with Tokena bonding curve smart contracts on EVM chains
Maintainers
Readme
Axolotl
SDK for interacting with Tokena bonding curve smart contracts on EVM chains.
Create, trade, and manage bonding curve tokens with a single npm package. Works in Node.js, browsers, and React apps.
Install
npm install axolotl-evmPeer dependency: ethers ^6.0.0 (you must install it separately)
npm install ethersQuick Start — Node.js / Backend
import { Axolotl } from 'axolotl-evm';
import { Wallet, JsonRpcProvider } from 'ethers';
// Initialize SDK
const axolotl = new Axolotl({ chainKey: 'sepolia' });
// Connect a wallet
const provider = new JsonRpcProvider('https://ethereum-sepolia-rpc.publicnode.com');
const wallet = new Wallet(process.env.PRIVATE_KEY!, provider);
// Read token state
const state = await axolotl.getTokenState('0xYourToken...');
console.log(`Price: ${state.currentPriceEth} ETH`);
console.log(`Progress: ${(state.ethBalance / state.ethThreshold * 100).toFixed(1)}%`);
// Get a buy quote
const quote = await axolotl.quoteBuy('0xYourToken...', 0.5);
console.log(`You'll get ~${quote.tokensOut.toLocaleString()} tokens`);
// Execute a buy
const tx = await axolotl.buy(
{ tokenAddress: '0xYourToken...', ethAmount: '0.5' },
wallet
);
console.log(`Bought! TX: ${tx.txHash}`);
// Check & claim fees
const pending = await axolotl.getPendingFees('0xYourToken...', wallet.address);
if (pending > 0) {
const claim = await axolotl.claimFees('0xYourToken...', wallet);
console.log(`Claimed ${pending} ETH! TX: ${claim.txHash}`);
}Quick Start — React
import { AxolotlProvider, useAxolotlWallet, usePoolState, useTrade } from 'axolotl-evm/react';
function App() {
return (
<AxolotlProvider chainKey="sepolia">
<TradingPanel tokenAddress="0xYourToken..." />
</AxolotlProvider>
);
}
function TradingPanel({ tokenAddress }: { tokenAddress: string }) {
const { address, connect, getSigner } = useAxolotlWallet();
const { state, isLoading } = usePoolState(tokenAddress);
const { quoteBuy, buy, loading, error } = useTrade();
const handleBuy = async () => {
const signer = await getSigner();
if (!signer) return;
const result = await buy({ tokenAddress, ethAmount: '0.1' }, signer);
if (result) alert(`Bought! TX: ${result.txHash}`);
};
if (isLoading) return <p>Loading...</p>;
return (
<div>
<p>Price: {state?.currentPriceEth} ETH</p>
<p>Reserve: {state?.ethBalance} / {state?.ethThreshold} ETH</p>
{!address ? (
<button onClick={connect}>Connect Wallet</button>
) : (
<button onClick={handleBuy} disabled={loading}>
{loading ? 'Buying...' : 'Buy 0.1 ETH'}
</button>
)}
{error && <p style={{ color: 'red' }}>{error}</p>}
</div>
);
}API Reference
new Axolotl(config)
| Option | Type | Description |
|---|---|---|
| chainKey | string | Default chain (e.g. "sepolia", "ethereum", "bsc") |
| chains | Record<string, ChainConfig> | Custom chain configs to add or override |
| factoryAddress | string | Override factory address for the default chain |
Core Methods
| Method | Description |
|---|---|
| getTokenState(addr) | Read full on-chain state (price, reserves, threshold, tax) |
| getTokenBalance(token, wallet) | Get wallet's token balance |
| createToken(params, signer) | Deploy a new bonding curve token |
| getCreationFee() | Get the factory's creation fee |
| getFactoryConfig() | Get all factory settings |
| quoteBuy(token, ethAmount) | Estimate tokens out for an ETH amount |
| quoteSell(token, tokenAmount, slippage) | Estimate ETH out for a token amount |
| buy(params, signer) | Buy tokens |
| sell(params, signer) | Sell tokens |
| getPendingFees(token, wallet) | Check claimable fees |
| claimFees(token, signer) | Claim accumulated fees |
| getClaimHistory(token, wallet) | Scan historical claim events |
React Hooks (axolotl-evm/react)
| Hook | Description |
|---|---|
| useAxolotlWallet(targetChain?) | MetaMask connection + chain switching |
| usePoolState(tokenAddr) | Auto-polling token state (10s interval) |
| useTrade(chainKey?) | Buy/sell with loading & error state |
| useClaimFees(tokens, wallet) | Multi-token fee management |
| useAxolotl() | Access the raw SDK instance from context |
Supported Chains
| Chain | Key | Factory |
|---|---|---|
| Sepolia Testnet | sepolia | 0x109d869521d668F8b3e93610D7BC794981d28EA4 |
| Ethereum | ethereum | Coming soon |
| BNB Chain | bsc | Coming soon |
| Base | base | Coming soon |
| Arbitrum | arbitrum | Coming soon |
Custom Chains
const axolotl = new Axolotl({
chainKey: 'mychain',
chains: {
mychain: {
chainId: 31337,
name: 'My Local Chain',
shortName: 'LOCAL',
rpcUrl: 'http://localhost:8545',
explorerUrl: 'http://localhost:4000',
nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },
factoryAddress: '0x...',
},
},
});License
MIT
