The SDK provides methods to mint positions as ERC-20 tokens directly on-chain, query token information, and manage wallet integration.
Minting & Burning
executeMintFlow
Withdraw position tokens from the exchange to your wallet as ERC-20 tokens.
async executeMintFlow(params: {
walletClient: WalletClient;
publicClient: PublicClient;
userAddress: `0x${string}`;
chain: string;
marketId: string;
side: 'yes' | 'no';
number: number;
}): Promise<{ txHash: `0x${string}` }>
Example
// Withdraw 20 YES position tokens from exchange to wallet
const result = await client.executeMintFlow({
walletClient,
publicClient,
userAddress: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
chain: 'base',
marketId: 'KXFEDDECISION-26JAN-T425',
side: 'yes',
number: 20,
});
console.log('Tokens minted! Transaction:', result.txHash);
executeBurnFlow
Deposit position tokens from your wallet back to the exchange as tradeable positions.
async executeBurnFlow(params: {
walletClient: WalletClient;
publicClient: PublicClient;
userAddress: `0x${string}`;
chain: string;
marketId: string;
side: 'yes' | 'no';
number: number;
}): Promise<{ txHash: `0x${string}` }>
Example
// Deposit 15 NO position tokens from wallet back to exchange
const result = await client.executeBurnFlow({
walletClient,
publicClient,
userAddress: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
chain: 'base',
marketId: 'KXFEDDECISION-26JAN-T425',
side: 'no',
number: 15,
});
console.log('Tokens burned! Transaction:', result.txHash);
Token Queries
getCreatedTokens
Retrieve information about position tokens that have been created on-chain.
async getCreatedTokens(chain?: 'base' | 'bsc'): Promise<GetCreatedTokensResponse>
Parameters
Optional chain identifier ("base" or "bsc").
Returns
List of created position tokens with their contract addresses and market information.
Example
const { tokens } = await client.getCreatedTokens('base');
console.log('Created tokens:');
tokens.forEach(token => {
console.log(`Market: ${token.marketId}`);
console.log(` Side: ${token.side}`);
console.log(` Token address: ${token.tokenAddress}`);
});
getPositionTokenAddress
Get the on-chain token address for a specific market position.
async getPositionTokenAddress(params: {
publicClient: PublicClient;
chain: 'base' | 'bsc';
marketId: string;
side: 'yes' | 'no';
}): Promise<`0x${string}` | null>
Parameters
Viem public client for reading from the blockchain
Chain identifier ("base" or "bsc")
Position side: "yes" or "no"
Returns
Token address if the position has been minted, null otherwise.
Example
import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';
const publicClient = createPublicClient({
chain: base,
transport: http(),
});
const tokenAddress = await client.getPositionTokenAddress({
publicClient,
chain: 'base',
marketId: 'KXBTC-100K-DEC31',
side: 'yes',
});
if (tokenAddress) {
console.log('YES token address:', tokenAddress);
} else {
console.log('Position tokens not yet minted');
}
getTokenBalance
Get the balance of an ERC20 token for a specific address.
async getTokenBalance(params: {
publicClient: PublicClient;
tokenAddress: `0x${string}`;
userAddress: `0x${string}`;
}): Promise<bigint>
Parameters
Viem public client for reading from the blockchain
ERC20 token contract address
Wallet address to check balance for
Returns
Token balance as a bigint. Position tokens have 0 decimals.
Example
const tokenAddress = await client.getPositionTokenAddress({
publicClient,
chain: 'base',
marketId: 'KXBTC-100K-DEC31',
side: 'yes',
});
if (tokenAddress) {
const balance = await client.getTokenBalance({
publicClient,
tokenAddress,
userAddress: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
});
console.log(`Balance: ${balance} YES tokens`);
}
Wallet Integration
addTokenToWallet
Add a position token to the user’s wallet (e.g., MetaMask).
async addTokenToWallet(params: {
tokenAddress: `0x${string}`;
marketId: string;
side: 'yes' | 'no';
}): Promise<boolean>
Parameters
Position token contract address
Market ticker (used for token symbol)
Position side: "yes" or "no"
Returns
true if the user accepted the request, false otherwise.
Example
const tokenAddress = await client.getPositionTokenAddress({
publicClient,
chain: 'base',
marketId: 'KXBTC-100K-DEC31',
side: 'yes',
});
if (tokenAddress) {
try {
const added = await client.addTokenToWallet({
tokenAddress,
marketId: 'KXBTC-100K-DEC31',
side: 'yes',
});
if (added) {
console.log('Token added to wallet successfully');
} else {
console.log('User declined to add token');
}
} catch (error) {
console.error('Failed to add token:', error);
}
}
This method requires a browser environment with an injected Web3 wallet (like MetaMask). It will throw an error if called in a non-browser environment or if no wallet is detected.
Important Notes
- Token addresses are only available after positions have been minted on-chain
- Position tokens have 0 decimals - quantities represent whole tokens
- Token symbols are automatically generated from the market ID (first 7 chars) and side