Skip to Content
DevelopersNTSN1 CLI

N1 CLI

️⚠️
NTS is in active development and currently unstable. It is open to select early developers for exploration but is not yet suitable for production use. Follow developer updates for the latest changes, as performance is not at production level.

The N1 CLI is a powerful command-line interface for managing N1 applications, cryptographic keys, and configuration. It provides developers with everything needed to build, deploy, and interact with N1 smart contracts.

Installation

If you haven’t already installed the N1 CLI, follow the installation guide.

npm install -g @n1xyz/cli

Getting Started

Once installed, you can access the CLI using the n1 command:

n1 --help

This displays all available commands and options.

Configuration Management

The CLI uses a configuration system to store settings like the NTS URL and default key names.

View Configuration

# Show all configuration n1 config get # Show specific configuration value n1 config get nts_url

Set Configuration

# Set the NTS URL n1 config set nts_url https://n1ts.n1.xyz # Set default key name n1 config set default_key my-key

Reset Configuration

# Reset all settings to defaults n1 config reset

Configuration is stored in ~/.config/n1/config.json

Key Management

The CLI provides comprehensive cryptographic key management for N1 applications.

Generate Keys

# Generate a key with default name n1 key generate # Generate a key with custom name n1 key generate --name my-app-key # Generate key with custom output path n1 key generate --name production --output ./keys/prod-key.json # Force overwrite existing key n1 key generate --name existing-key --force

List Keys

# List all stored keys n1 key list

Show Key Details

# Show public key and creation date n1 key show my-key # CLI will prompt before showing private key for security

Delete Keys

# Delete a key (with confirmation prompt) n1 key delete my-key
⚠️

Private keys are stored unencrypted in ~/.config/n1/keys/. Keep your system secure and consider the security implications.

Application Commands

The CLI provides a complete workflow for N1 application development.

Initialize New App

# Initialize new N1 app in current directory n1 app init # Force initialization even if directories exist n1 app init --force

This creates:

  • contracts/ - Smart contract source code
  • tests/ - Test files
  • utils/ - Utility functions
  • build/ - Compiled output
  • package.json - Project dependencies
  • n1config.json - N1-specific configuration

Development Mode

# Start development server with hot reload n1 app dev

Development mode provides:

  • Automatic compilation on file changes
  • Test execution
  • Local development environment

Deploy Application

# Deploy to configured network n1 app deploy # Deploy with specific configuration n1 app deploy --config production

Update Application

# Update deployed application n1 app update

Interact with Applications

# Interactive mode for calling contract functions n1 app interact # Read contract state n1 app read

Transaction Commands

Manage and execute transactions on the N1 network.

# View transaction commands n1 tx --help

Transaction commands require a valid session and configured network connection.

Project Structure

When you run n1 app init, the CLI creates a standardized project structure:

my-n1-app/ ├── contracts/ │ └── app.ts # Main contract file ├── tests/ │ └── counter.test.ts # Test files ├── utils/ # Utility functions ├── build/ # Compiled output ├── package.json # Dependencies └── n1config.json # N1 configuration

Best Practices

Key Management

  • Use descriptive names for keys: n1 key generate --name mainnet-deployer
  • Keep production keys separate from development keys
  • Regularly back up important keys to secure storage

Development Workflow

  1. Initialize: n1 app init
  2. Develop: Edit contracts in contracts/app.ts
  3. Test: n1 app dev for continuous testing
  4. Deploy: n1 app deploy when ready

Configuration

  • Set up different configurations for different environments
  • Use n1 config get to verify settings before deployment

Troubleshooting

Common Issues

CLI not found after installation

# Check if CLI is in PATH which n1 # Reinstall if necessary npm install -g @n1xyz/cli

Permission errors

# Check file permissions for config directory ls -la ~/.config/n1/

Network connection issues

# Verify NTS URL configuration n1 config get nts_url # Test connectivity (if applicable) curl https://n1ts.n1.xyz

Key-related errors

# List available keys n1 key list # Verify key file exists ls ~/.config/n1/keys/

Getting Help

Command Reference

CommandDescription
n1 config get/set/resetManage CLI configuration
n1 key generate/list/show/deleteCryptographic key management
n1 app init/dev/deploy/updateApplication lifecycle
n1 app interact/readContract interaction
n1 txTransaction management

For detailed help on any command, use the --help flag:

n1 [command] --help
Last updated on