A side-by-side comparison of two approaches to building Polkadot smart contracts:
- Bare Rust: Low-level PolkaVM contract with manual ABI encoding and storage management
- ink!: High-level framework with automatic code generation
Both implementations use the same contract: Mixocracy, a decentralized DJ voting platform with 25 public functions. Obtained from here: https://github.com/lovelaced/mixocracy
See BENCHMARK_REPORT.md for detailed analysis including:
- Code metrics and binary sizes
- Gas costs per operation
- Build times and dependencies
- When to use each approach
.
├── benchmark_gas.ts # Gas benchmark script
├── deploy_ink_paseo.ts # ink! deployment script
├── BENCHMARK_REPORT.md # Detailed results
└── mixocracy/
├── mixocracy-contract/ # Bare Rust implementation
└── mixocracy-contract-ink/ # ink! implementation
- Node.js 18+
- Rust nightly (for bare rust contract)
- Pop CLI (for ink! contract)
- Foundry (for wallet creation)
Create a new Ethereum-compatible wallet:
cast wallet newSave the private key. Convert the address to Polkadot format:
pop convert address <your-ethereum-address>Fund the converted address on Paseo Asset Hub using the Paseo Faucet or transfer from another account.
# Root directory
npm install
# Bare rust contract
cd mixocracy/mixocracy-contract
npm install
cd ../..Bare Rust: Don't build, the binary has to be used that is provided (couldn't get it to work with rebuilding)
ink!:
cd mixocracy/mixocracy-contract-ink
pop build --release --metadata solidity
cd ../..Set your private key:
export PRIVATE_KEY=0x_your_private_key_hereDeploy Bare Rust:
cd mixocracy/mixocracy-contract
npm run deploy:paseo
cd ../..Deploy ink!:
npx ts-node deploy_ink_paseo.tsPRIVATE_KEY=0x_your_private_key_here npx ts-node benchmark_gas.tsResults are saved to benchmark_results.json and printed to console.
All benchmarks run on Paseo Asset Hub (testnet):
- Chain ID:
420420422 - RPC:
https://testnet-passet-hub-eth-rpc.polkadot.io - Explorer: https://blockscout-passet-hub.parity-testnet.parity.io
MIT