Pirichain Smart Scenarios - CLI tool for blockchain development
npm install psceA command-line interface for Pirichain Smart Scenarios (PSCE). Create, manage, and test blockchain development workspaces with smart contract scenarios.


``bash`
npm install -g psce
`bash`
npx psce new my-workspace
`bashCreate a new PSCE workspace
psce new my-workspace
cd my-workspace
Commands
$3
`bash
Create new workspace
psce new
`$3
`bash
Network commands (can use 'n' as shorthand)
psce network|n add --name --url # Add network
psce network|n list [--json] # List networks
psce network|n set # Set active network
psce network|n current # Show current network
psce network|n test # Test network connection
psce network|n remove # Remove networkExamples
psce n add --name mainnet --url https://mainnet.pirichain.com
psce n list # Show networks in table format
psce n list --json # Show networks in JSON format
psce n set mainnet
psce n current
`$3
`bash
Address commands (can use 'a' as shorthand)
psce address|a generate [--name ] # Generate new address (auto-saves as temp-* or custom name)
psce address|a import [--name ] # Import address from 24-word mnemonic
psce address|a validate # Validate a Pirichain address
psce address|a list [--json] # List all addresses
psce address|a set # Set active address
psce address|a current # Show current address
psce address|a rename # Rename address
psce address|a remove # Remove addressExamples
psce a generate # Auto-saves as temp-1699123456
psce a generate --name wallet1 # Saves as wallet1
psce a generate --json # Output in JSON format
psce a import --name imported-wallet # Import from mnemonic (will prompt securely)
psce a import --mnemonic "word1 word2 ... word24" --name my-wallet # Import with mnemonic
psce a validate TZ123abc... # Check if address is valid
psce a list # Show addresses in table format
psce a list --json # Show addresses in JSON format
psce a rename temp-1699123456 mainwallet # Rename temp to permanent name
psce a set mainwallet
psce a current
`$3
`bash
Add new scenario
psce scenario add [options]
--name Scenario name
--tags Comma-separated tags
--network Target network URLExamples
psce scenario add payment
psce scenario add --name nft-market --tags "nft,marketplace" --network https://mainnet.pirichain.com
`$3
`bash
Test scenario methods
psce test -m [options]
-m, --method Method name to execute (required)
-p, --params Method parameters (comma-separated)
-n, --network Network name (uses current if not specified)
-a, --address Address name (uses current if not specified)Examples
psce test payment -m init
psce test token -m transfer -p "100,TZ123abc"
psce test nft -m mint -n mainnet -a wallet1
`Generated Workspace Structure
`
my-workspace/
├── package.json # PSCE configuration
├── scenarios/ # Smart contract scenarios
│ └── example/ # Example scenario
│ ├── example.psce # Scenario code
│ ├── tests/ # Scenario-specific tests
│ │ ├── example.test.js
│ │ └── README.md
│ ├── .scenario-config.json
│ └── README.md
├── psce.json # PSCE workspace configuration
├── README.md # Workspace documentation
└── .gitignore
`Scenario Configuration
Each scenario includes:
`json
{
"name": "payment",
"description": "PSCE scenario: payment",
"version": "1.0.0",
"author": "",
"networks": ["https://testnet.pirichain.com"],
"dependencies": [],
"testDir": "tests",
"tags": ["finance", "payment"],
"methods": [
{
"method": "init",
"description": "Initialize the scenario"
}
]
}
`Testing System
PSCE tests work by sending requests to the active network's
/previewScenario endpoint:- scenarioText: Complete scenario code
- address: Active selected address
- privateKey: Private key (master password may be required)
- method: Method name to execute
- params: Parameter values
Test responses:
{error: number, returnedData: any}- error: 0 = Success
- error: > 0 = Error occurred
Features
- 🔗 Workspace Creation: Generate complete PSCE development environments
- 📝 Scenario Management: Create scenarios with customizable tags and networks
- 🌐 Network Management: Add, test, and manage multiple blockchain networks
- 👤 Address Management: Generate, import from mnemonic, manage, and secure blockchain addresses with auto-save functionality
- 🧪 Integrated Testing: Built-in test framework using real PSCE API endpoints
- ⚡ Dynamic Configuration: Auto-detects workspace type and structure
- 🎯 VS Code Ready: Works with PSCE VS Code extension
Network Auto-Detection
The CLI automatically detects network properties:
- Tests
/getStats endpoint for connectivity
- Extracts address prefix from genesis block
- Stores network metadata for future useDevelopment
$3
`bash
git clone
cd psce-cli
npm install
npm linkTest CLI
psce new test-workspace
`$3
`
psce-cli/
├── bin/
│ └── psce.js # CLI entry point
├── commands/
│ ├── new.js # Workspace creation
│ ├── scenario.js # Scenario management
│ ├── network.js # Network management
│ ├── address.js # Address management
│ └── test.js # Testing framework
├── lib/
│ ├── utils.js # Utility functions
│ ├── security-manager.js # Network/security management
│ └── wallet/ # Wallet functionality
│ ├── createNewAddress.js # Address generation
│ ├── getMnemonic.js # Mnemonic handling
│ ├── index.js # Wallet exports
│ ├── isValidAddress.js # Address validation
│ ├── rescuePrivateKey.js # Key recovery
│ └── utility.js # Wallet utilities
└── package.json
`Examples
$3
`bash
Create workspace
psce new my-dapp
cd my-dappAdd and set network
psce n add --name PirichainTestnet --url https://testnet.pirichain.com
psce n add --name PirichainMainnet --url https://core.pirichain.comYou can also add custom or local networks
psce n add --name local --url http://localhost:8080
psce n add --name custom --url https://my-custom-network.comSet active network
psce n set PirichainTestnetGenerate and set active address
psce a generate --name wallet1
psce a set wallet1OR import existing address from mnemonic
psce a import --name imported-wallet --network PirichainTestnet
psce a set imported-wallet
Create scenarios
psce scenario add --name token --tags "token,erc20" --network https://testnet.pirichain.com
psce scenario add --name nft --tags "nft,collectibles" --network https://core.pirichain.comTest scenarios
psce test token -m init
psce test token -m transfer -p "100,TZ123abc"
psce test nft -m mint -n mainnet -a wallet1
``