difcli
v0.0.13
Published
CLI tool for Diffuse Prime
Maintainers
Readme
Prime CLI
A CLI tool for Diffuse Prime built with TypeScript and viem.
Configuration
The CLI uses a config.json file with the following settings:
{
"rpc": "https://rpc.berachain.com",
"vaultContract": "0x17b040cF3bbAf62B60871B4d396FBC5109d560af",
"tokenContract": "0xBe4170b9903f796490F8E88aCBf9db9F336Ec27e"
}Installation
npm install -g difcli
# or
npx difcliUsage
Main Commands
difcli --help # Show help
difcli --version # Show versionWallet Commands
Set Private Key
difcli wallet set-private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80Show Wallet Information
difcli wallet showDisplays wallet address and type.
Remove Wallet
difcli wallet removeRemoves the stored private key from local storage.
Balance Command
Show Balance
difcli balanceDisplays wallet balance in native BERA tokens and configured token contract balance.
Contracts Command
Display Contract Addresses
difcli contractsDisplays all configured contract addresses including RPC endpoint, vault contract, and token contract.
Token Commands
Mint Tokens
difcli token mint <amount>Mints the specified amount of tokens to the configured wallet. Amount is in token units (will be multiplied by 1e18 for the transaction).
Burn Tokens
difcli token burn <amount>Burns the specified amount of tokens from the configured wallet. Amount is in token units (will be multiplied by 1e18 for the transaction).
Both commands will:
- Display transaction hash
- Wait for transaction confirmation
- Show success/failure status
- Display gas usage information
Lender Commands
Deposit Tokens
difcli lender deposit <amount>Deposits tokens into the vault as a lender. Amount is in token units (will be multiplied by 1e18 for the transaction).
The command will:
- Check token balance to ensure sufficient funds
- Check token allowance for the vault contract
- Approve tokens if allowance is insufficient
- Execute deposit transaction to vault contract
- Display transaction hashes and confirmation status
- Show gas usage information
Validation: Command will fail with clear error message if token balance is insufficient.
Withdraw Tokens
difcli lender withdraw <amount>Withdraws tokens from the vault as a lender. Amount is in token units (will be multiplied by 1e18 for the transaction).
The command will:
- Check maximum withdrawable amount from vault
- Execute withdraw transaction from vault contract (if sufficient balance)
- Display transaction hash and confirmation status
- Show gas usage information
Note: Both receiver and owner addresses are set to the configured wallet address.
Validation: Command will fail with clear error message if requested amount exceeds maximum withdrawable balance.
Vault Commands
Set Vault Address
difcli vault set <chain> <address>Sets a custom vault contract address for a specific chain.
difcli vault set berachain 0x1234567890123456789012345678901234567890Show Vault Addresses
difcli vault showDisplays current vault addresses for all chains, showing both default and custom addresses.
Reset Vault Address
difcli vault reset <chain>Resets the vault address for a specific chain back to the default.
difcli vault reset berachainNote: Custom vault addresses are stored per chain and persist across sessions.
Vault Status
difcli lender statusDisplays comprehensive vault status and lender-specific information:
Vault Statistics:
- Total assets in vault
- Assets currently utilized
- Base asset deficit
Lender Information:
- Maximum withdrawable amount
- Current vault balance (shares)
- Accrued yield information
Vault Status:
- Pause status and reason (if paused)
Security
⚠️ WARNING: This CLI tool stores private keys locally with encryption. While the keys are encrypted, this is NOT suitable for production use with real funds.
For production use:
- Use hardware wallets
- Implement proper key management systems
- Never store private keys on disk
The current implementation uses a default encryption key. For better security, consider:
- User-provided passwords for encryption
- Hardware security modules
- Secure key vaults
Development
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Test locally
node dist/index.js [command]
# or
npx difcli [command]Dependencies
- viem - Ethereum library for TypeScript
- commander - CLI framework
- crypto-js - Encryption utilities
- chalk - Terminal styling
License
MIT
