Installation
Run the Midnight Contracts Wizard CLI to generate smart contract projects
The Midnight Contracts Wizard runs directly via npx, so you do not need to install anything globally. This guide covers all the ways to run the wizard and verify your environment.
Quick start
Run the wizard immediately with npx:
npx @meshsdk/midnight-contracts-wizardThis command:
- Downloads the latest version automatically
- Launches the interactive wizard
- Generates your project with selected contracts
Prerequisites
Before running the wizard, verify you have the required tools installed.
Check Node.js version
node --versionYou need Node.js 18 or higher. If you need to install or update Node.js, visit nodejs.org.
Check npm version
npm --versionYou need npm 8 or higher (includes npx). npm is included with Node.js, so updating Node.js will also update npm.
Running the wizard
Basic usage
npx @meshsdk/midnight-contracts-wizardCheck available version
npx @meshsdk/midnight-contracts-wizard --versionDisplay help
npx @meshsdk/midnight-contracts-wizard --helpWhat happens when you run npx
When you execute the npx command:
- Downloads package - npx fetches the latest version from npm registry
- Runs wizard - Launches the interactive CLI interface
- Creates project - Generates files based on your selections
- Cleans up - The package is not permanently installed
Troubleshooting
"npx: command not found"
Cause: npm is not installed or not in your PATH.
Solution: Install Node.js from nodejs.org, which includes npm and npx.
"Node.js version too old"
Cause: You have Node.js < 18 installed.
Solution: Update Node.js using your preferred method:
# Using nvm (recommended)
nvm install 18
nvm use 18
# Or download directly from nodejs.orgSlow download
Cause: First-time download or npm cache cleared.
Solution: Wait for the download to complete. Subsequent runs use the npm cache and are faster.
Permission errors
Cause: npm directory permissions issue.
Solution: Fix npm permissions:
# Create npm directory in home folder
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to your shell profile (.bashrc, .zshrc, etc.)
export PATH=~/.npm-global/bin:$PATHVerifying installation
After running the wizard, verify the generated project:
# Navigate to your project
cd my-project
# Check the files were created
ls -la
# Verify package.json exists
cat package.jsonYou should see:
package.jsonwith project configurationsrc/directory with contract filestsconfig.jsonfor TypeScript configuration
Next steps
Now that you can run the wizard:
- Usage - Create your first project
- Contracts - Learn about available templates
- Project Structure - Understand generated files