GET STARTED
↓

From install to first trade.

Connect a wallet, request a quote, and submit your first buy.

1. Install

Terminal
npm install @floor1/sdk viem

Use Node.js 20 or newer, or a modern browser. This package is ESM and includes TypeScript declarations. To build from source:

Terminal
git clone https://github.com/Floor1dotfun/floor1-sdk.git
cd floor1-sdk
npm ci
npm run build

2. Connect your wallet

Create a viem wallet client from your injected wallet. Configure Giwa Sepolia in the wallet first; the SDK checks chain ID 91342 before it requests a trade quote. The injected provider supplies the wallet connection.

TypeScript
import { createWalletClient, custom, defineChain } from 'viem';
import { createFloor1Client, giwaSepolia } from '@floor1/sdk';

const provider = window.ethereum;
if (!provider) throw new Error('Connect an EIP-1193 wallet');

const [account] = await provider.request({
  method: 'eth_requestAccounts',
});
const chain = defineChain({
  id: giwaSepolia.chainId,
  name: 'Giwa Sepolia',
  nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
  rpcUrls: { default: { http: [] } },
});
const wallet = createWalletClient({
  account, chain, transport: custom(provider),
});
const floor1 = createFloor1Client({ wallet });

3. Preview the trade

TypeScript
import { parseEther, formatUnits } from 'viem';

const token = '0x1111111111111111111111111111111111111111';
const quote = await floor1.quote({
  token, side: 'buy', amount: parseEther('0.01'),
});

console.log(formatUnits(BigInt(quote.amountOut), 18));

Replace the example address with an active Floor1 token. Amounts are atomic units, and quotes are exact input. The default slippage is 100 basis points (1%).

4. Submit a buy

TypeScript
const { hash, quote: executedQuote } = await floor1.buy({
  token,
  amount: parseEther('0.01'),
  slippageBps: 100,
});

console.log(hash, executedQuote.minimumOut);

The SDK requests a fresh quote and constructs the transaction locally. Your wallet presents the signing request. The returned hash means submission, so wait for a successful receipt through your existing wallet infrastructure before updating balances.