# From install to first trade.

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



## 1. Install

```ts
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:

```ts
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.

```ts
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

```ts
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

```ts
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.

Provider typesThe example assumes an injected EIP-1193 provider such as a browser wallet. Add your wallet provider’s TypeScript declarations for window.ethereum. A configured wallet client does not itself switch the user’s wallet network.

[NEXTSell tokens↗Set allowance, then request a fresh sell.

](/sell/)[NEXTMint a token↗Create a token using Arweave metadata.

](/mint/)
