A Next.js application demonstrating 1inch API integration for DeFi token swaps and quotes. This project provides a clean interface to fetch real-time token prices and swap quotes across multiple blockchain networks.
- Multi-chain Support: Ethereum, Polygon, BNB Chain, and Arbitrum
- Real-time Token Data: Fetch available tokens and their details
- Swap Quotes: Get accurate quotes for token swaps using 1inch API
- Modern UI: Clean, responsive interface with Tailwind CSS
- TypeScript: Full TypeScript support for type safety
- Framework: Next.js 15 with App Router
- Styling: Tailwind CSS v4
- Language: TypeScript
- Icons: Lucide React
- API: 1inch DeFi API integration
- Node.js 18+
- pnpm (recommended) or npm/yarn
- Clone the repository:
git clone <repository-url>
cd catalyst-yield- Install dependencies:
pnpm install
# or
npm install- Start the development server:
pnpm dev
# or
npm run dev- Open http://localhost:3000 in your browser.
Navigate to /oneinch to access the 1inch API demo interface where you can:
- Select a blockchain network (Ethereum, Polygon, BNB Chain, or Arbitrum)
- Choose tokens from the available token list for each network
- Enter an amount in wei (e.g., 1000000000000000000 for 1 ETH)
- Get real-time quotes for your token swaps
The project includes a comprehensive 1inch API client in /lib/1inch/:
- client.ts: Core API client with request handling
- types.ts: TypeScript interfaces for API responses
- hooks.ts: React hooks for easy integration (
useTokens,useQuote) - index.ts: Main exports and ChainId constants
catalyst-yield/
├── app/
│ ├── oneinch/
│ │ └── page.tsx # 1inch demo page
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/
│ └── OneInchDemo.tsx # Main demo component
├── lib/
│ └── 1inch/ # 1inch API integration
│ ├── client.ts
│ ├── hooks.ts
│ ├── types.ts
│ └── index.ts
├── public/ # Static assets
└── package.json
pnpm dev- Start development serverpnpm build- Build for productionpnpm start- Start production serverpnpm lint- Run ESLint
const { tokens } = useTokens(chainId);Fetches available tokens for a given chain ID.
const { quote, loading, error } = useQuote(chainId, {
fromTokenAddress: string,
toTokenAddress: string,
amount: string
});Fetches swap quotes for the specified token pair and amount.
- Ethereum Mainnet (Chain ID: 1)
- Polygon (Chain ID: 137)
- BNB Chain (Chain ID: 56)
- Arbitrum (Chain ID: 42161)
To add support for additional networks:
- Update the
ChainIdtype in/lib/1inch/types.ts - Add the new chain to the dropdown in
/components/OneInchDemo.tsx - Ensure the 1inch API supports the new chain
Currently, no API keys are required as the 1inch API is publicly accessible. However, for production deployments, you may want to:
- Add rate limiting
- Implement API key management
- Add error handling and retries
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.