# smooth otc operator
A secure, decentralized escrow application for safe in-person swaps between Japanese Yen (JPY) and cryptocurrency on Base blockchain.
## motivation
When I was using ZKP2P, my Wise account was banned. I realized that tools and services that don't rely on centralized services are necessary. So now, I have started doing in-person OTC trades with my friends.
However, the user experience (UX) is cumbersome, involving things like calculating and agreeing on exchange rates, and the act of sharing a wallet address on Telegram. Also, even though they are friends, it's natural to get nervous when trading large sums of money.
Smooth OTC Operator was born to improve this UX.
As for future additions, I am thinking of implementing a more secure and cypherpunk UX with features such as a privacy pool.
## Project Description
Base Escrow dApp is a demo-only application designed for hackathon purposes that enables secure peer-to-peer transactions between cash (JPY) and cryptocurrency. The platform provides a trustless escrow service where users can safely exchange physical cash for digital assets without the need for a trusted third party.
### Key Features
- **Secure Escrow System**: Smart contract-based escrow with automatic refund capabilities
- **Multi-Asset Support**: ETH, USDC, and USDT support
- **Real-time Price Feeds**: CoinMarketCap API integration for accurate JPY-to-crypto conversions
- **One-Time Code (OTC) System**: Secure verification mechanism for in-person transactions
- **Mobile-First Design**: Optimized for mobile devices with intuitive UX
- **Farcaster Integration**: Mini App support for seamless social interactions
### How It Works
1. **Maker** creates an escrow by depositing cryptocurrency and specifying JPY amount
2. **Taker** receives a QR code with OTC for the transaction
3. **In-person exchange**: Physical cash is exchanged for the OTC code
4. **Release**: Maker releases funds using the OTC code
5. **Automatic Refund**: If not released within deadline, funds are automatically returned
## Technologies Used
### Smart Contracts
- **Solidity 0.8.24**: Smart contract development
- **Hardhat**: Development environment and testing framework
- **OpenZeppelin**: Security-focused smart contract libraries
- ReentrancyGuard for protection against reentrancy attacks
- Ownable for access control
- SafeERC20 for secure token operations
### Frontend
- **Next.js 15.5.3**: React framework with App Router
- **TypeScript**: Type-safe development
- **Tailwind CSS**: Utility-first CSS framework
- **Wagmi + Viem**: Ethereum wallet integration
- **OnchainKit**: Coinbase wallet integration
- **React Hot Toast**: User notifications
### Blockchain & APIs
- **Base Sepolia**: Test network for development
- **CoinMarketCap API**: Real-time cryptocurrency price data
- **ERC-20 Tokens**: USDC and USDT support
### Development Tools
- **Playwright**: End-to-end testing
- **ESLint**: Code linting
- **Vercel**: Deployment platform
## Basic Architecture
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Smart │ │ External │
│ (Next.js) │ │ Contract │ │ Services │
│ │ │ (Escrow.sol) │ │ │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ • Wallet Connect│◄──►│ • Escrow Logic │ │ • CoinMarketCap │
│ • Price Display │ │ • OTC System │ │ API │
│ • QR Code Gen │ │ • Auto Refund │ │ • Base Network │
│ • Mobile UI │ │ • Multi-token │ │ • Farcaster │
└─────────────────┘ └─────────────────┘ └─────────────────┘
```
### Smart Contract Architecture
The `Escrow.sol` contract implements:
- **Escrow Management**: Create, release, and refund operations
- **Security Features**: Reentrancy protection, access controls
- **Multi-Token Support**: ETH, USDC, USDT with proper ERC-20 handling
- **OTC Verification**: Cryptographic verification of one-time codes
- **Deadline Management**: Automatic refund after expiration
### Frontend Architecture
- **Pages**: Home, New Escrow, Session Management, Logs
- **Components**: Modular UI components for reusability
- **Hooks**: Custom React hooks for blockchain interactions
- **API Routes**: CoinMarketCap proxy for CORS handling
## Source Code
- **Repository**: [GitHub Repository](https://github.com/your-username/base-escrow-dapp)
- **License**: MIT License (Open Source)
- **Smart Contract**: `contracts/Escrow.sol`
- **Frontend**: `src/` directory with Next.js structure
## Deployment
### Demo Deployment
- **Live Demo**: [https://escrow-app-seven.vercel.app](https://escrow-app-seven.vercel.app)
- **Farcaster Mini App**: Available on Farcaster platform
- **Network**: Base Sepolia Testnet
### Contract Addresses
- **Escrow Contract**: `0xA755f4c3e56c5ea2815c0013843fe9cf6d1762D4`
- **USDC**: `0x036CbD53842c5426634e7929541eC2318f3dCF7e`
- **USDT**: `0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb`
### Local Development
1. **Clone the repository**
```bash
git clone https://github.com/your-username/base-escrow-dapp.git
cd base-escrow-dapp
```
2. **Install dependencies**
```bash
npm install
# or
pnpm install
```
3. **Set up environment variables**
```bash
cp .env.example .env.local
# Edit .env.local with your API keys and contract addresses
```
4. **Compile smart contracts**
```bash
npx hardhat compile
```
5. **Deploy contracts**
```bash
npx hardhat run scripts/deploy.cjs --network baseSepolia
```
6. **Start development server**
```bash
npm run dev
```
### Testing
- **Smart Contract Tests**: `npx hardhat test`
- **E2E Tests**: `npx playwright test`
- **Coverage**: `npx hardhat coverage`
## Security Considerations
- **Demo Only**: This application is designed for hackathon demonstration purposes
- **Testnet Only**: Currently deployed on Base Sepolia testnet
- **Price Oracle**: Uses CoinMarketCap API (not decentralized)
- **OTC System**: One-time codes provide basic security for in-person transactions
## Future Enhancements
- **Chainlink Integration**: Decentralized price feeds
- **Multi-chain Support**: Expand to other EVM-compatible chains
- **Advanced Security**: Multi-signature requirements
- **Mobile App**: Native mobile application
- **Analytics**: Transaction analytics and reporting
## Contributing
This is a hackathon project. For production use, additional security audits and testing would be required.
## License
MIT License - see LICENSE file for details.
# Base Escrow dApp
Baseブロックチェーン上で日本円(JPY)と暗号通貨の安全な対面取引を実現する分散型エスクローアプリケーション
## プロジェクト概要・背景
私はZKP2Pを使っていたら、WiseのアカウントをBANされました。中央集権的なサービスを介さないツール、サービスが必要だということに私は気づきました。そこで私はいま個人的に友達と対面式のOTCをするようになりました。しかし、レートの計算と合意、wallet addressをテレグラムで共有すること、などUXは煩雑です。また友人とはいえ、大金の取引をするときは緊張するものです。これらのUXを改善するためにSmooth OTC Operatorは生まれました。
今後の追加機能としてプライバシープールなど、よりセキュアでサイファーパンクなUXを実装していきたいと考えています。
Base Escrow dAppは、ハッカソン用に設計されたデモ専用アプリケーションで、現金(日本円)と暗号通貨の安全なピアツーピア取引を可能にします。信頼できる第三者を必要とせずに、物理的な現金とデジタルアセットを安全に交換できるトラストレスなエスクローサービスを提供します。
### 主要機能
- **セキュアなエスクローシステム**: 自動返金機能付きのスマートコントラクトベースのエスクロー
- **マルチアセット対応**: ETH、USDC、USDTのサポート
- **リアルタイム価格フィード**: 正確なJPY-暗号通貨変換のためのCoinMarketCap API統合
- **ワンタイムコード(OTC)システム**: 対面取引のための安全な検証メカニズム
- **モバイルファーストデザイン**: 直感的なUXでモバイルデバイスに最適化
- **Farcaster統合**: シームレスなソーシャルインタラクションのためのMini Appサポート
### 動作の流れ
1. **Maker**が暗号通貨を預け入れ、日本円の金額を指定してエスクローを作成
2. **Taker**がOTCコード付きのQRコードを受け取る
3. **対面取引**: 物理的な現金とOTCコードを交換
4. **Release**: MakerがOTCコードを使用して資金を解放
5. **自動返金**: 期限までに解放されない場合、資金は自動的に返金される
## 使用技術
### スマートコントラクト
- **Solidity 0.8.24**: スマートコントラクト開発
- **Hardhat**: 開発環境とテストフレームワーク
- **OpenZeppelin**: セキュリティ重視のスマートコントラクトライブラリ
- ReentrancyGuard: リエントランシー攻撃からの保護
- Ownable: アクセス制御
- SafeERC20: 安全なトークン操作
### フロントエンド
- **Next.js 15.5.3**: App Router付きReactフレームワーク
- **TypeScript**: 型安全な開発
- **Tailwind CSS**: ユーティリティファーストCSSフレームワーク
- **Wagmi + Viem**: イーサリアムウォレット統合
- **OnchainKit**: Coinbaseウォレット統合
- **React Hot Toast**: ユーザー通知
### ブロックチェーン・API
- **Base Sepolia**: 開発用テストネットワーク
- **CoinMarketCap API**: リアルタイム暗号通貨価格データ
- **ERC-20トークン**: USDCとUSDTのサポート
### 開発ツール
- **Playwright**: エンドツーエンドテスト
- **ESLint**: コードリンティング
- **Vercel**: デプロイメントプラットフォーム
## 基本アーキテクチャ
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ フロントエンド │ │ スマート │ │ 外部サービス │
│ (Next.js) │ │ コントラクト │ │ │
│ │ │ (Escrow.sol) │ │ │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ • ウォレット接続 │◄──►│ • エスクローロジック│ │ • CoinMarketCap │
│ • 価格表示 │ │ • OTCシステム │ │ API │
│ • QRコード生成 │ │ • 自動返金 │ │ • Baseネットワーク│
│ • モバイルUI │ │ • マルチトークン │ │ • Farcaster │
└─────────────────┘ └─────────────────┘ └─────────────────┘
```
### スマートコントラクトアーキテクチャ
`Escrow.sol`コントラクトは以下を実装:
- **エスクロー管理**: 作成、解放、返金操作
- **セキュリティ機能**: リエントランシー保護、アクセス制御
- **マルチトークンサポート**: 適切なERC-20処理によるETH、USDC、USDT
- **OTC検証**: ワンタイムコードの暗号学的検証
- **期限管理**: 期限切れ後の自動返金
### フロントエンドアーキテクチャ
- **ページ**: ホーム、新規エスクロー、セッション管理、ログ
- **コンポーネント**: 再利用性のためのモジュラーUIコンポーネント
- **フック**: ブロックチェーン操作のためのカスタムReactフック
- **APIルート**: CORS処理のためのCoinMarketCapプロキシ
## ソースコード
- **リポジトリ**: [GitHubリポジトリ](https://github.com/your-username/base-escrow-dapp)
- **ライセンス**: MITライセンス(オープンソース)
- **スマートコントラクト**: `contracts/Escrow.sol`
- **フロントエンド**: Next.js構造の`src/`ディレクトリ
## デプロイメント
### デモデプロイ
- **ライブデモ**: [https://escrow-app-seven.vercel.app](https://escrow-app-seven.vercel.app)
- **Farcaster Mini App**: Farcasterプラットフォームで利用可能
- **ネットワーク**: Base Sepoliaテストネット
### コントラクトアドレス
- **エスクローコントラクト**: `0xA755f4c3e56c5ea2815c0013843fe9cf6d1762D4`
- **USDC**: `0x036CbD53842c5426634e7929541eC2318f3dCF7e`
- **USDT**: `0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb`
### ローカル開発
1. **リポジトリのクローン**
```bash
git clone https://github.com/your-username/base-escrow-dapp.git
cd base-escrow-dapp
```
2. **依存関係のインストール**
```bash
npm install
# または
pnpm install
```
3. **環境変数の設定**
```bash
cp .env.example .env.local
# .env.localを編集してAPIキーとコントラクトアドレスを設定
```
4. **スマートコントラクトのコンパイル**
```bash
npx hardhat compile
```
5. **コントラクトのデプロイ**
```bash
npx hardhat run scripts/deploy.cjs --network baseSepolia
```
6. **開発サーバーの起動**
```bash
npm run dev
```
### テスト
- **スマートコントラクトテスト**: `npx hardhat test`
- **E2Eテスト**: `npx playwright test`
- **カバレッジ**: `npx hardhat coverage`
## セキュリティ考慮事項
- **デモ専用**: このアプリケーションはハッカソン実演用に設計されています
- **テストネットのみ**: 現在はBase Sepoliaテストネットにのみデプロイされています
- **価格オラクル**: CoinMarketCap APIを使用(分散化されていない)
- **OTCシステム**: ワンタイムコードは対面取引の基本的なセキュリティを提供
## 今後の拡張計画
- **Chainlink統合**: 分散化された価格フィード
- **マルチチェーンサポート**: 他のEVM互換チェーンへの拡張
- **高度なセキュリティ**: マルチシグ要件
- **モバイルアプリ**: ネイティブモバイルアプリケーション
- **アナリティクス**: 取引分析とレポート
## 貢献
これはハッカソンプロジェクトです。本番環境での使用には、追加のセキュリティ監査とテストが必要です。
## ライセンス
MITライセンス - 詳細はLICENSEファイルを参照してください。