@t-0/provider-starter-ts
v0.4.12
Published
CLI tool to scaffold a Node.js t-0 Network integration service
Readme
t-0 Network Provider Starter
CLI tool to quickly bootstrap a Node.js TypeScript integration service for the t-0 Network.
Overview
This CLI tool scaffolds a complete TypeScript project configured to integrate with the t-0 Network as a provider. It automatically generates secp256k1 cryptographic key pairs, sets up your development environment, and includes all necessary dependencies to get started immediately.
Prerequisites
Before using this tool, ensure you have:
- Node.js >= 14.0.0
- npm >= 6.0.0
- OpenSSL (for cryptographic key generation)
Quick Start
Using npx (Recommended)
Run the following command to create a new t-0 Network integration:
npx @t-0/provider-starter-tsAlternative: Global Installation
npm install -g @t-0/provider-starter-ts
provider-starter-tsWhat It Does
When you run the CLI tool, it performs the following steps automatically:
- Interactive Prompt - Asks for your project name
- Project Directory - Creates a new directory with your project name
- Template Setup - Copies pre-configured TypeScript project structure
- Key Generation - Generates a secp256k1 cryptographic key pair using OpenSSL
- Environment Configuration - Creates
.envfile with:- Generated private key (
PROVIDER_PRIVATE_KEY) - Generated public key (as comment for reference)
- t-0 Network public key (
NETWORK_PUBLIC_KEY) - Server configuration (
PORT,NODE_ENV) - Optional quote publishing interval
- Generated private key (
- Git Initialization - Initializes git repository with
.gitignore - Dependency Installation - Runs
npm installto install all dependencies
Generated Project Structure
After running the CLI, your new project will have the following structure:
your-project-name/
├── src/
│ ├── index.ts # Main entry point
│ ├── service.ts # Provider service implementation
│ ├── publish_quotes.ts # Quote publishing logic
│ ├── get_quote.ts # Quote retrieval logic
│ ├── submit_payment.ts # Payment submission logic
│ └── lib.ts # Utility functions
├── .env # Environment variables (with generated keys)
├── .env.example # Example environment file
├── .eslintrc.json # ESLint configuration
├── .gitignore # Git ignore rules
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configurationEnvironment Variables
The generated .env file includes:
| Variable | Description |
|----------|-------------|
| NETWORK_PUBLIC_KEY | t-0 Network's public key (pre-configured) |
| PROVIDER_PRIVATE_KEY | Your generated private key (keep secret!) |
| PORT | Server port (default: 3000) |
| NODE_ENV | Environment mode (default: development) |
| TZERO_ENDPOINT | t-0 Network API endpoint (default: sandbox) |
| QUOTE_PUBLISHING_INTERVAL | Quote publishing frequency in ms (optional) |
Available Scripts
In your generated project, you can run:
npm run dev
Runs the service in development mode using ts-node.
npm run build
Compiles TypeScript to JavaScript in the dist/ directory.
npm start
Runs the compiled production build from dist/.
npm run lint
Lints TypeScript files in the src/ directory using ESLint.
Getting Started with Your Integration
After creating your project:
Navigate to project directory:
cd your-project-nameReview the generated keys:
- Open
.envfile - Your private key is stored in
PROVIDER_PRIVATE_KEY - Your public key is shown as a comment (you'll need to share this)
- Open
Share your public key with t-0 team:
- Find your public key in the
.envfile (marked as "Step 1.2") - Contact the t-0 team to register your provider
- Find your public key in the
Implement quote publishing:
- Edit
src/publish_quotes.tsto implement your quote publishing logic - This determines how you provide exchange rate quotes to the network
- Edit
Start development server:
npm run devTest your integration:
- Follow the TODO comments in
src/index.tsfor step-by-step guidance - Test quote retrieval
- Test payment submission
- Verify payout endpoint
- Follow the TODO comments in
Key Features
- Type Safety - Full TypeScript support with strict mode enabled
- Automatic Key Generation - Secure secp256k1 key pairs generated via OpenSSL
- Pre-configured SDK - t-0 Provider SDK integrated and ready to use
- Development Ready - Hot reload support with ts-node
- Production Ready - Optimized build configuration
- Security First -
.envautomatically excluded from git - Code Quality - ESLint configured with TypeScript rules
Security Considerations
- Never commit
.envfile - It's automatically added to.gitignore - Keep private key secure - The
PROVIDER_PRIVATE_KEYmust remain confidential - Share only public key - Only the public key should be shared with t-0 team
- Use environment-specific configs - Different keys for dev/staging/production
Deployment
When ready to deploy:
Build your project:
npm run buildSet environment variables on your hosting platform
Provide your base URL to t-0 team for network registration
Start the service:
npm start
Troubleshooting
"Directory already exists" Error
The project directory name is already taken. Choose a different project name.
"OpenSSL not found" Error
Install OpenSSL:
- macOS:
brew install openssl - Ubuntu/Debian:
sudo apt-get install openssl - Windows: Download from openssl.org
Key Generation Fails
Ensure OpenSSL is installed and accessible in your PATH. Try running:
openssl versionnpm install Fails
Check your Node.js and npm versions:
node --version # Should be >= 14
npm --version # Should be >= 6Support
For issues or questions:
- Review the generated code comments and TODO markers
- Check the t-0 Network documentation
- Contact the t-0 team for integration support
