A TypeScript/JavaScript client library for interacting with the Convex DLT network.
See: Convex Docs
pnpm add convex-ts
import { Convex } from 'convex-ts';
// Connect to a Convex peer
const convex = new Convex('https://convex.world');
// Create a new account with initial balance (on test network)
await convex.createAccount(10000000);
// Get account information
const accountInfo = await convex.getAccountInfo();
// Submit a transaction
const result = await convex.submitTransaction({
// transaction details
});
import { Convex } from 'convex-ts';
// Connect to a Convex peer
const convex = new Convex('https://convex.world');
// Create a new account with initial balance (on test network)
await convex.createAccount(10000000);
const { Convex } = require('convex-ts');
// Connect to a Convex peer
const convex = new Convex('https://convex.world');
// Create a new account with initial balance (on test network)
convex.createAccount(10000000)
.then(account => console.log(account));
- Connect to Convex network peers
- Account management
- Transaction submission and tracking
- Cryptographic key pair generation and management
- Query state and history
- Full TypeScript type definitions
- Supports both ESM and CommonJS
- Docker Desktop
- pnpm (v8 or later)
- Node.js (v16 or later)
# Install dependencies
pnpm install
# Build the library
pnpm run build
The tests require a local Convex peer running in Docker. Follow these steps:
-
Start Docker Desktop and ensure it's running
-
Start the local Convex peer:
docker-compose up -d
- Verify the peer is running:
# Check container status
docker ps | grep convex-peer
# Check API endpoint
curl http://localhost:18888/api/v1/status
- Run the tests:
# Run tests with local peer
CONVEX_PEER_URL=http://localhost:18888 pnpm test
If you can't access the Convex peer:
- Check Docker container status:
docker-compose ps
- Check container logs:
docker-compose logs
- Ensure ports are properly exposed:
# Stop the container
docker-compose down
# Start with verbose output
docker-compose up
- If you still can't connect, try:
- Restarting Docker Desktop
- Running
docker-compose down
followed bydocker-compose up -d
- Checking your firewall settings for ports 18888 and 18889
The main class for interacting with the Convex network.
new Convex(peerUrl: string, options?: ClientOptions)
createAccount(initialBalance?: number): Promise<Account>
getAccountInfo(): Promise<AccountInfo>
submitTransaction(tx: Transaction): Promise<TransactionResult>
getKeyPair(): KeyPair
query(query: Query): Promise<QueryResult>
Apache License 2.0