@fliidotdev/blinks-cli
v0.1.3
Published
CLI for Blinks SDK
Downloads
11
Readme
@fliidotdev/blinks-cli
Command-line interface for creating, managing, and deploying Solana Blinks. Build blockchain interactions from your terminal with powerful scaffolding and deployment tools.
Installation
Global Installation (Recommended)
npm install -g @fliidotdev/blinks-cli
# or
yarn global add @fliidotdev/blinks-cli
# or
pnpm add -g @fliidotdev/blinks-cliLocal Installation
npm install --save-dev @fliidotdev/blinks-cli
# or
yarn add -D @fliidotdev/blinks-cli
# or
pnpm add -D @fliidotdev/blinks-cliQuick Start
# Create a new Blink project
blinks init my-blink-app
# Navigate to project
cd my-blink-app
# Start development server
blinks dev
# Deploy to mainnet
blinks deploy --network mainnetCommands
blinks init [project-name]
Initialize a new Blinks project with boilerplate code and configuration.
blinks init my-project
# With options
blinks init my-project --template react --typescript --gitOptions:
--template, -t- Project template (react|vue|vanilla|next)--typescript, --ts- Use TypeScript (default: true)--git- Initialize git repository--install, -i- Install dependencies automatically--pm- Package manager (npm|yarn|pnpm)
blinks create [type]
Create new Blink components and actions.
# Create a new action
blinks create action transfer-sol
# Create a new component
blinks create component payment-button
# Create a new hook
blinks create hook use-balanceTypes:
action- Create a new Blink actioncomponent- Create a React componenthook- Create a custom React hookcontract- Create a Solana program template
blinks dev
Start the development server with hot reload.
blinks dev
# Custom port
blinks dev --port 4000
# With network
blinks dev --network devnetOptions:
--port, -p- Port number (default: 3000)--host, -h- Host address (default: localhost)--network, -n- Solana network (mainnet|devnet|testnet)--open, -o- Open browser automatically
blinks build
Build the project for production.
blinks build
# With optimization
blinks build --optimize
# Custom output directory
blinks build --out distOptions:
--out, -o- Output directory (default: build)--optimize- Enable optimization--analyze- Analyze bundle size--sourcemap- Generate source maps
blinks deploy
Deploy Blinks to Solana network.
# Deploy to devnet
blinks deploy --network devnet
# Deploy to mainnet with custom RPC
blinks deploy --network mainnet --rpc https://api.mainnet-beta.solana.com
# Deploy specific Blink
blinks deploy payment-blink --network mainnetOptions:
--network, -n- Target network (required)--rpc, -r- Custom RPC endpoint--keypair, -k- Path to keypair file--program-id- Program ID to deploy to--dry-run- Simulate deployment without executing
blinks test
Run tests for your Blinks.
# Run all tests
blinks test
# Run specific test
blinks test payment.test.ts
# With coverage
blinks test --coverage
# Watch mode
blinks test --watchOptions:
--coverage, -c- Generate coverage report--watch, -w- Run in watch mode--bail- Stop on first test failure--verbose, -v- Verbose output
blinks validate
Validate Blink configurations and actions.
# Validate all Blinks
blinks validate
# Validate specific Blink
blinks validate payment-blink
# Validate with network check
blinks validate --network devnetOptions:
--network, -n- Network to validate against--strict- Strict validation mode--fix- Auto-fix issues where possible
blinks list
List all Blinks in the current project.
# List all Blinks
blinks list
# List with details
blinks list --detailed
# Filter by type
blinks list --type actionOptions:
--detailed, -d- Show detailed information--type, -t- Filter by type--json- Output as JSON
blinks wallet
Manage wallet operations.
# Generate new wallet
blinks wallet generate
# Show wallet info
blinks wallet info
# Get balance
blinks wallet balance --network devnet
# Request airdrop (devnet only)
blinks wallet airdrop 2 --network devnetSubcommands:
generate- Generate new wallet keypairinfo- Display wallet informationbalance- Check wallet balanceairdrop- Request SOL airdrop (devnet/testnet)
blinks config
Manage CLI configuration.
# Show current config
blinks config
# Set default network
blinks config set network mainnet
# Set custom RPC
blinks config set rpc https://api.mainnet-beta.solana.com
# Get specific value
blinks config get networkSubcommands:
set [key] [value]- Set configuration valueget [key]- Get configuration valuereset- Reset to default configurationlist- List all configuration options
Configuration
Project Configuration
Create blinks.config.js in your project root:
module.exports = {
// Network configuration
network: 'devnet',
rpc: 'https://api.devnet.solana.com',
// Build configuration
build: {
outDir: 'dist',
sourcemap: true,
minify: true
},
// Development server
dev: {
port: 3000,
host: 'localhost',
open: true
},
// Blink defaults
defaults: {
commitment: 'confirmed',
preflightCommitment: 'processed'
},
// Custom paths
paths: {
actions: './src/actions',
components: './src/components',
contracts: './src/contracts'
}
};TypeScript Configuration
For TypeScript projects, use blinks.config.ts:
import { defineConfig } from '@fliidotdev/blinks-cli';
export default defineConfig({
network: 'mainnet',
rpc: process.env.SOLANA_RPC_URL,
build: {
target: 'es2020',
lib: ['esnext', 'dom']
}
});Environment Variables
Create .env file for environment-specific configuration:
# Network
SOLANA_NETWORK=devnet
SOLANA_RPC_URL=https://api.devnet.solana.com
# Wallet
WALLET_PRIVATE_KEY=your_private_key_here
# API Keys
HELIUS_API_KEY=your_helius_key
QUICKNODE_API_KEY=your_quicknode_key
# Development
DEV_PORT=3000
DEV_HOST=localhostTemplates
React Template
blinks init my-app --template react
# Includes:
# - React 18 with TypeScript
# - Solana wallet adapter
# - Pre-built components
# - Example actionsNext.js Template
blinks init my-app --template next
# Includes:
# - Next.js 14 with App Router
# - Server-side rendering
# - API routes for Blinks
# - Optimized for productionVue Template
blinks init my-app --template vue
# Includes:
# - Vue 3 with Composition API
# - TypeScript support
# - Pinia for state management
# - Vue RouterVanilla Template
blinks init my-app --template vanilla
# Includes:
# - Pure JavaScript/TypeScript
# - No framework dependencies
# - Minimal bundle size
# - Web ComponentsProgrammatic API
Use the CLI programmatically in your Node.js applications:
const { CLI } = require('@fliidotdev/blinks-cli');
const cli = new CLI();
// Initialize project
await cli.init('my-project', {
template: 'react',
typescript: true
});
// Create action
await cli.create('action', 'transfer', {
template: 'transfer'
});
// Deploy
await cli.deploy({
network: 'mainnet',
rpc: 'https://api.mainnet-beta.solana.com'
});Plugins
Extend CLI functionality with plugins:
// blinks.config.js
module.exports = {
plugins: [
'@fliidotdev/blinks-plugin-analytics',
'@fliidotdev/blinks-plugin-monitoring',
['@fliidotdev/blinks-plugin-custom', {
option1: 'value1'
}]
]
};CI/CD Integration
GitHub Actions
name: Deploy Blinks
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Install Blinks CLI
run: npm install -g @fliidotdev/blinks-cli
- name: Build
run: blinks build --optimize
- name: Deploy
run: blinks deploy --network mainnet
env:
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }}Vercel Deployment
{
"buildCommand": "blinks build",
"outputDirectory": "dist",
"installCommand": "npm install && npm install -g @fliidotdev/blinks-cli"
}Troubleshooting
Common Issues
Command not found
# Reinstall globally npm install -g @fliidotdev/blinks-cli # Or use npx npx @fliidotdev/blinks-cli initNetwork connection issues
# Use custom RPC blinks deploy --rpc https://your-rpc-endpoint.comTransaction failures
# Increase commitment level blinks deploy --commitment finalizedBuild errors
# Clear cache blinks clean blinks build --no-cache
Debug Mode
Enable debug output for troubleshooting:
# Enable debug mode
DEBUG=blinks:* blinks deploy
# Verbose logging
blinks deploy --verbose
# Dry run
blinks deploy --dry-runBest Practices
- Use environment variables for sensitive data
- Test on devnet before mainnet deployment
- Version control your blinks.config.js
- Implement proper error handling in custom actions
- Use TypeScript for better type safety
- Regular backups of wallet keypairs
- Monitor gas usage and optimize transactions
License
MIT © fliidotdev
Contributing
We welcome contributions! Please see our Contributing Guide.
