polkatruffle
v1.0.0
Published
A drop-in Truffle suite preconfigured for Passet Hub Testnet (Chain ID 420420421) and other Parachain-EVM networks (no Docker).
Downloads
6
Readme
🎩 PolkaTruffle
A drop-in Truffle suite preconfigured for Passet Hub Testnet (Chain ID 420420421) and other Parachain-EVM networks.
No Docker required—just scaffold, install, compile, migrate, and verify!
🚀 Features
- 🔧 One-command Scaffold
Instantly create a brand-new Truffle project (contracts/,migrations/,test/,truffle-config.js) configured for Passet Hub Testnet. - 📦 Automatic Dependency Install
After scaffolding,polkatruffle init <name>runsnpm installfor you—no extra steps. - ⚡ Proxy to Truffle
Usepolkatruffle run <truffle-args>instead ofnpx truffle <...>. Keeps your local Truffle version consistent. - 🔍 Blockscout Verification
polkatruffle verify <address> --network passetHubTestnetsubmits source code verification to Passet Hub’s Blockscout (Etherscan API–compatible). - 🤝 Multi-network Ready
Easily extendtruffle-config.jsto add Moonbeam, Astar, Moonriver, or any EVM-compatible parachain. - 🎨 Friendly CLI Output
Colorful, easy-to-read messages powered by Chalk.
📦 Installation
npm install -g polkatruffleIf you prefer, you can also install it per‐project (as a dev dependency):
npm install --save-dev polkatruffle
🏁 Quickstart
Scaffold a New Project
polkatruffle init my-projectThis creates a folder
my-project/populated with:my-project/ ├── contracts/ │ └── Example.sol ├── migrations/ │ └── 1_initial_migration.js ├── test/ │ └── Example.test.js ├── truffle-config.js ├── .gitignore ├── package.json └── README.mdImmediately runs
npm installinsidemy-project/for you.
Enter Your Project & Create a
.envcd my-project echo 'MNEMONIC="your twelve-word mnemonic here"' > .env # — or — # echo 'PRIVATE_KEY="0xYourPrivateKeyHere"' >> .envMake sure
.envis in.gitignore(it is by default). Never commit secrets to Git!Compile & Migrate
npx truffle compile npx truffle migrate --network passetHubTestnetOutput:
Compiling your contracts... > Compiling ./contracts/Example.sol > Artifacts written to /.../my-project/build/contracts Starting migrations... > Network: passetHubTestnet (ID 420420421) > Deploying 'Example' • tx hash: 0xabc123... • block: 1234567 (confirmed) • contract: 0xdef456...
Run Tests (Local or On-chain)
Local Ganache:
Install Ganache CLI:
npm install -g ganache-cliRun:
ganache-cli -p 8545 -i 1337In another terminal:
npx truffle test --network ganache
Passet Hub Testnet (slower, real chain):
npx truffle test --network passetHubTestnet
Verify on Blockscout
polkatruffle verify 0xdef456... --network passetHubTestnet --apiKey YOUR_BLOCKSCOUT_API_KEYResult:
🔎 Submitting verification for Example at 0xdef456... ✅ Verification submitted successfully! GUID: 0x789abc... Check status: https://blockscout-passet-hub.parity-testnet.parity.io/api?module=contract&action=checkverifystatus&guid=0x789abc...
📖 Full Command Reference
polkatruffle init <projectName>
Description: Scaffolds a new Truffle project in
<projectName>/using ourtemplates/, then automatically runsnpm installinside it.Example:
polkatruffle init hdh-app # → Creates ./hdh-app, copies templates, and runs `npm install` inside "hdh-app/"After Init:
cd <projectName>Create your
.env:echo 'MNEMONIC="your mnemonic here"' > .envnpx truffle compile && npx truffle migrate --network passetHubTestnet
polkatruffle run [truffleArgs...]
Description: Proxies directly to
npx truffle <truffleArgs...>using your local Truffle version.When to Use:
polkatruffle run compilepolkatruffle run migrate --network passetHubTestnetpolkatruffle run test --network ganache
Example:
polkatruffle run compile polkatruffle run migrate --network passetHubTestnet polkatruffle run test --network ganache
polkatruffle verify <contractAddress> --network <network> [--apiKey <key>]
Description: Submits a source-code verification request to Passet Hub’s Blockscout.
Required:
<contractAddress>: The exact 0x-prefixed address of your deployed contract.--network <network>: Must match a network name in yourtruffle-config.js(e.g.,passetHubTestnet).
Optional:
--apiKey <key>: Your Blockscout API key. If you setBS_API_KEYin your environment, you can omit this flag.
Example:
polkatruffle verify 0xdef4567890abcdef1234567890abcdef12345678 \ --network passetHubTestnet \ --apiKey ABCDEF1234567890
🤝 Contributing
Fork the repository:
git clone https://github.com/sambitsargam/polkatruffle.git cd polkatruffleInstall dependencies:
npm install npm link # so you can test your changes locallyCreate a new branch for your feature or bugfix:
git checkout -b feature/amazing-improvementMake your changes in
bin/polkatruffle.jsortemplates/.Write tests (if applicable) and ensure everything still works:
polkatruffle init test-app cd test-app npm test # or run your own test suiteCommit, push to your fork, and open a Pull Request. We’ll review and merge!
📜 License
MIT License
Crafted with ❤️ by Sambit Sargam Ekalabya Happy smart-contracting on Polkadot! 🚀
