Quick Example: Read Token Info
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://evmrpc.kasplex.org");
const FACTORY = "0x..."; // MemeFactory Contract Address
const FACTORY_ABI = [
"function getTokenInfo(address token) view returns (tuple(uint256 tokenId, address creator, address pool, uint256 tokenReserves, uint256 kasReserves, uint256 createdAt, bool fulfilled, bool graduated, string metadataUri, uint256 paramVersion))",
"function getCurrentPrice(address token) view returns (uint256)",
"function getBondingCurveProgress(address token) view returns (uint256)",
];
const factory = new ethers.Contract(FACTORY, FACTORY_ABI, provider);
const TOKEN = "0x..."; // token address
const info = await factory.getTokenInfo(TOKEN);
const price = await factory.getCurrentPrice(TOKEN);
const progress = await factory.getBondingCurveProgress(TOKEN);
console.log("Token ID:", info.tokenId.toString());
console.log("Reserves:", ethers.formatEther(info.kasReserves), "KAS");
console.log("Price:", ethers.formatEther(price), "KAS");
console.log("Progress:", Number(progress) / 100, "%");
console.log("Graduated:", info.graduated);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://evmrpc.kasplex.org"))
FACTORY = "0x..." # MemeFactory Contract Address
# Use full ABI from the Contract Reference section
factory = w3.eth.contract(address=FACTORY, abi=FACTORY_ABI)
TOKEN = "0x..." # token address
info = factory.functions.getTokenInfo(TOKEN).call()
price = factory.functions.getCurrentPrice(TOKEN).call()
progress = factory.functions.getBondingCurveProgress(TOKEN).call()
print(f"Reserves: {w3.from_wei(info[4], 'ether')} KAS")
print(f"Price: {w3.from_wei(price, 'ether')} KAS")
print(f"Progress: {progress / 100}%")
print(f"Graduated: {info[7]}")
Quick Example: Buy a Token
import { ethers } from "ethers";
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const FACTORY = "0x..."; // MemeFactory Contract Address
const FACTORY_ABI = [
"function buy(address token, uint256 minTokensOut) payable",
];
const factory = new ethers.Contract(FACTORY, FACTORY_ABI, signer);
const TOKEN = "0x...";
const kasAmount = ethers.parseEther("100"); // 100 KAS
const minTokensOut = 0n; // set proper slippage in production!
const tx = await factory.buy(TOKEN, minTokensOut, { value: kasAmount });
await tx.wait();
console.log("Buy tx:", tx.hash);
Always set a proper
minTokensOut for slippage protection. Using 0 means no slippage protection and is only safe for testing.Next Steps
Contract Overview
Understand the contract architecture
Buy & Sell
Learn how to trade tokens with slippage protection
Price Calculation
Understand the bonding curve math
ABI Reference
Full contract ABI reference