A Go implementation of the FiatConnect API specification, providing a standardized interface for cash-in/cash-out (CICO) operations between fiat and cryptocurrency.
This is a port of the TypeScript fiatconnect-api to Go, using the Gin web framework.
- SIWE Authentication: Sign-In with Ethereum (SIWE) for secure, wallet-based authentication
- Session Management: Secure session handling with cookie-based storage
- FiatConnect Compliance: Full implementation of the FiatConnect v1.0.0 specification
- Modular Architecture: Clean separation of concerns with middleware, routes, and types
- Error Handling: Comprehensive error types matching the FiatConnect specification
- Docker Support: Ready-to-deploy Docker configuration
The implementation follows a clean architecture pattern:
fiatconnect-go/
βββ cmd/
β βββ server/ # Application entry point
βββ internal/
β βββ config/ # Configuration management
β βββ errors/ # Error types and handling
β βββ middleware/ # HTTP middleware (auth, sessions, errors)
β βββ routes/ # Route handlers
β β βββ auth.go # Authentication endpoints
β β βββ accounts.go # Fiat account management
β β βββ kyc.go # KYC endpoints
β β βββ quote.go # Quote endpoints
β β βββ transfer.go # Transfer endpoints
β βββ types/ # Type definitions
βββ go.mod
POST /login- Authenticate with SIWE message and signatureDELETE /logout- Clear sessionGET /clock- Get server time
POST /in- Get quote for cash-in (fiat β crypto)POST /out- Get quote for cash-out (crypto β fiat)
Requires authentication
POST /- Add fiat accountGET /- List fiat accountsDELETE /:fiatAccountId- Delete fiat account
Requires authentication
POST /:kycSchema- Submit KYC dataGET /:kycSchema/status- Get KYC statusDELETE /:kycSchema- Delete KYC data
Requires authentication
POST /in- Initiate cash-in transferPOST /out- Initiate cash-out transferGET /:transferId/status- Get transfer status
- Go 1.21 or higher
- (Optional) Docker and Docker Compose
# Clone the repository
git clone <repository-url>
cd fiatconnect-go
# Install dependencies
make installCreate a .env file in the project root (or copy from .env.example):
# Server Configuration
PORT=3000
HOST=localhost
# Session Configuration
SESSION_SECRET=your-secret-key-here
# SIWE Configuration
SIWE_REQUIRED=false
SIWE_DOMAIN=localhost:3000
SIWE_MAX_EXPIRATION_HOURS=4
# Provider Configuration
PROVIDER_ID=your-provider-id| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
HOST |
Server host | localhost |
SESSION_SECRET |
Secret key for session encryption | Required |
SIWE_REQUIRED |
Require SIWE authentication for all endpoints | false |
SIWE_DOMAIN |
Expected domain in SIWE messages | localhost:3000 |
SIWE_MAX_EXPIRATION_HOURS |
Maximum allowed SIWE message expiration | 4 |
PROVIDER_ID |
Your provider identifier | Required |
# Run with auto-reload
make dev
# Or run directly
make run# Build the binary
make build
# Run the binary
./bin/fiatconnect-server# Build and run with Docker Compose
docker-compose up -d
# Or build Docker image
docker build -t fiatconnect-go .
docker run -p 3000:3000 --env-file .env fiatconnect-gomake build# Run all tests
make test
# Run tests with coverage
make test-coverage# Format code
make fmt
# Run go vet
make vet
# Run linter (requires golangci-lint)
make lint- Project structure and configuration
- Error types and handling
- Session management
- SIWE authentication middleware
- All route handlers with placeholders
- Docker support
The following business logic needs to be implemented in the route handlers:
- Nonce validation and storage (prevent replay attacks)
- Domain and URI validation
- Quote calculation logic (exchange rates, fees)
- Quote storage and expiration
- Quote validation
- Fiat account schema validation
- Account storage and retrieval
- Account ownership verification
- KYC schema validation
- KYC data storage
- KYC verification process integration
- KYC status tracking
- Transfer creation and storage
- Quote validation for transfers
- Crypto address generation (for cash-out)
- Transfer status updates
- Blockchain integration
- Framework: Gin - Fast HTTP web framework
- Sessions: gorilla/sessions - Session management
- SIWE: spruceid/siwe-go - Sign-In with Ethereum
- Validation: validator/v10 - Struct validation
- Environment: godotenv - Environment variable loading
| Feature | TypeScript | Go |
|---|---|---|
| Framework | Express.js | Gin |
| Validation | Zod | validator/v10 + manual |
| Sessions | express-session | gorilla/sessions |
| SIWE | siwe | siwe-go |
| Type Safety | TypeScript | Go types |
| Performance | Node.js runtime | Native Go binary |
This implementation follows the FiatConnect Specification v1.0.0.
For detailed API documentation, request/response schemas, and integration guides, please refer to:
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
- fiatconnect-ts - TypeScript implementation
- FiatConnect Specification - Official specification
- FiatConnect Types - TypeScript type definitions