@clawshi/sdk
v0.2.0
Published
TypeScript SDK for Clawshi prediction markets with Circle Programmable Wallets integration
Maintainers
Readme
@clawshi/sdk
TypeScript SDK for Clawshi prediction markets with Circle Programmable Wallets integration.
Stake USDC on prediction markets powered by community sentiment.
Installation
npm install @clawshi/sdkQuick Start
import { ClawshiClient } from '@clawshi/sdk';
// Read-only mode
const client = new ClawshiClient();
const markets = await client.markets.list();
// With wallet
const client = new ClawshiClient({
privateKey: process.env.PRIVATE_KEY,
});
// Stake 10 USDC on YES
await client.stake(19, 'YES', '10');Features
- List and query prediction markets
- Stake USDC on market outcomes (YES/NO)
- Create new markets with Chainlink or manual resolution
- Claim winnings from resolved markets
- MetaMask / Browser wallet support
- Circle Programmable Wallets support
API Reference
Initialize Client
// Read-only (no wallet)
const client = new ClawshiClient();
// With private key
const client = new ClawshiClient({
privateKey: '0x...',
rpcUrl: 'https://base.publicnode.com', // optional
});
// With Circle wallet
const client = new ClawshiClient({
circle: {
apiKey: 'CIRCLE_API_KEY',
walletId: 'wallet-id',
},
});
// With MetaMask (browser)
import { BrowserProvider } from 'ethers';
const provider = new BrowserProvider(window.ethereum);
await provider.send('eth_requestAccounts', []);
const signer = await provider.getSigner();
const client = new ClawshiClient({
signer: signer,
});Markets
// List all markets
const markets = await client.markets.list();
// Get market by ID
const market = await client.markets.get(19);
console.log(market.question, market.yesPool, market.noPool);
// Get odds
const odds = await client.markets.getOdds(19);
console.log(`YES: ${odds.yes}% | NO: ${odds.no}%`);
// Get active/resolved markets
const active = await client.markets.getActive();
const resolved = await client.markets.getResolved();Staking
// Approve USDC (one-time)
await client.approveUsdc();
// Stake on YES
await client.stake(19, 'YES', '10'); // 10 USDC
// Stake on NO
await client.stake(19, 'NO', '5'); // 5 USDC
// Check my stake
const stake = await client.getMyStake(19);
console.log(stake.amount, stake.isYes, stake.claimed);
// Calculate potential payout
const estimate = await client.calculatePayout(19, 'YES', '10');
console.log(estimate.potentialPayout, estimate.odds);Resolution & Claims
// Check if market can be resolved
const canResolve = await client.canResolve(19);
// Resolve market (anyone can call after deadline)
await client.resolve(19);
// Claim winnings
await client.claim(19);Create Market
// Chainlink-resolved market
const marketId = await client.createMarket({
question: 'Will BTC reach $150k by June 2026?',
resolver: 'chainlink',
resolverParams: {
asset: 'BTC',
targetPrice: 150000,
isGreaterThan: true,
},
deadline: Math.floor(Date.now() / 1000) + 86400 * 90,
creatorFeeBps: 100, // 1%
});Circle Wallet
import { CircleWallet } from '@clawshi/sdk';
// Create new wallet
const wallet = await CircleWallet.create({
apiKey: process.env.CIRCLE_API_KEY,
userId: 'user-123',
});
// Get balances
const usdc = await wallet.getUsdcBalance();
const eth = await wallet.getEthBalance();Contract Addresses (Base Mainnet)
| Contract | Address |
|----------|---------|
| MarketFactory | 0xc0DeBCEa2F1BcB268b01777ff9c8E3BB4dA85559 |
| ChainlinkResolver | 0xDEbe4E62bEE1DA1657008480e6d91a3f1E3CCaeC |
| ManualResolver | 0x3602D8989920B9A9451BF9D9562Bb97BA7cEd1bb |
| USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
License
MIT
