A comprehensive collection of ink! smart contracts and modern frontend applications built for the Polkadot ecosystem. This repository showcases various contract implementations, from basic token standards to complex governance systems, along with production-ready React frontends for seamless user interaction.
- ποΈ Governance Contract - DAO governance system (README)
- πͺ PSP22 Boilerplate - Token standard implementation (README)
- π’ Advanced Token - Enterprise token features (README)
- β Simple Todo - Vec-based todo list (README)
- β Todo Map - Mapping-based todo list (README)
- πͺ v6 PSP22 - Modern token implementation (README)
- π· Piggy Bank - Savings contract (README)
- ποΈ Governance DApp - Production-ready governance UI (README)
- πͺ ERC20 Frontend - Token interaction interface (README)
- π Web3Bridge Curriculum - Learning materials
| Contract | Description | Technology | Link |
|---|---|---|---|
| ποΈ Governance | DAO Governance System | ink! v6.0.0-alpha.4 | π governance/ |
| πͺ PSP22 Boilerplate | PSP22 Token Standard | ink! v5.1.1 | π ink-bootcamp-erc20-boilerplate/ |
| π’ Advanced Token | ERC-20 Style Token | ink! v5.1.1 | π Token/ |
| β Simple Todo | Vec-based Todo List | ink! v5.1.1 | π todo/ |
| β Todo Map | Mapping-based Todo List | ink! v5.1.1 | π todo_map/ |
| πͺ v6 PSP22 | Modern PSP22 Token | ink! v6.0.0-alpha.4 | π v6psp20/ |
| π· Piggy Bank | Savings Contract | ink! v6.0.0-alpha.4 | π v6psp20piggybank/ |
| Application | Description | Technology | Link |
|---|---|---|---|
| ποΈ Governance DApp | DAO Governance Frontend | Next.js 15 + React 19 | π governance-dapp/ |
| πͺ ERC20 Frontend | Token Interaction UI | Next.js 15 + React 19 | π erc20fe/ |
| π Web3Bridge | Learning Materials | React + Vite | π web3bridge-curriculum/ |
| Document | Description | Link |
|---|---|---|
| π Main README | This comprehensive guide | π README.md |
Before you begin, ensure you have the following installed:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add WebAssembly target
rustup target add wasm32-unknown-unknown
# Install cargo-contract
cargo install cargo-contract --force
# Install substrate-contracts-node (for local testing)
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git
# Install Node.js (for frontend development)
# Visit: https://nodejs.org/- Start Local Node
# In a separate terminal
substrate-contracts-node --dev- Build Any Contract
cd <contract-directory>
cargo contract build --release- Deploy Contract
cargo contract instantiate --constructor new --suri //Alice --skip-confirm- Run Frontend
cd frontend/governance-dapp
npm install
npm run devLocation: governance/
Technology: ink! v6.0.0-alpha.4
A comprehensive DAO governance system implementing decentralized decision-making:
- Proposal Management: Create, vote on, and execute proposals
- Voting System: Multi-option voting with customizable parameters
- Quorum Requirements: Configurable participation thresholds
- Execution Delays: Time-locked execution for security
- Voter Registration: Permission-based voting participation
- Treasury Management: Fund allocation and spending controls
// Proposal Management
create_proposal(title, description, proposal_type, governance_params, voting_options) -> u32
get_proposal(proposal_id) -> Option<Proposal>
get_all_proposal_ids() -> Vec<u32>
// Voting System
vote(proposal_id, option_index) -> Result<()>
get_user_vote(proposal_id, user) -> Option<Vote>
has_reached_quorum(proposal_id) -> Option<bool>
get_detailed_results(proposal_id) -> Option<Vec<(String, u128)>>
// Voter Management
register_voter() -> Result<()>
is_voter(account) -> bool
get_total_voters() -> u32
// Status Management
update_proposal_status(proposal_id) -> Result<()>
execute_proposal(proposal_id) -> Result<()>pub struct Proposal {
pub id: u32,
pub title: String,
pub description: String,
pub proposal_type: ProposalType, // Treasury, Governance, Technical, Other
pub governance_params: GovernanceParameters,
pub voting_options: VotingOptions, // Custom voting choices
pub proposer: H160,
pub created_at: u32, // Block number
pub voting_end: u32, // Block number
pub execution_time: u32, // Block number
pub status: ProposalStatus, // Active, Passed, Rejected, Executed, Expired
pub vote_counts: Vec<u128>, // Votes per option
pub total_voters: u32,
}
pub struct Vote {
pub voter: H160,
pub choice: VoteChoice,
pub timestamp: u32,
pub weight: u128,
}Location: ink-bootcamp-erc20-boilerplate/
Technology: ink! v5.1.1
A complete PSP22 token implementation with all standard features:
- β PSP22 Core - Transfer, approve, and allowance functionality
- β PSP22 Metadata - Token name, symbol, and decimals
- β PSP22 Mintable - Mint new tokens
- β PSP22 Burnable - Burn existing tokens
- β Safe Arithmetic - Overflow protection
- β Comprehensive Error Handling
Location: Token/
Technology: ink! v5.1.1
Advanced ERC-20 style token with enterprise features:
- Core Functionality: Transfer, approve, allowance
- Burn Mechanism: Users can burn their tokens
- Pausable: Emergency pause functionality
- Blacklist: Address blacklisting capability
- Batch Operations: Multi-recipient transfers
- Owner Controls: Administrative functions
Location: v6psp20/
Technology: ink! v6.0.0-alpha.4
Modern PSP22 token implementation using ink! v6 with:
- Latest ink! v6 features and optimizations
- Enhanced storage patterns
- Improved error handling
- Polkadot VM compatibility
Location: v6psp20piggybank/
Technology: ink! v6.0.0-alpha.4
A savings contract that allows users to:
- Deposit Tokens: Save PSP22 tokens
- Set Goals: Define savings targets
- Withdraw: Retrieve funds (with restrictions)
- Break Piggy Bank: Emergency withdrawal
- Goal Tracking: Monitor progress
Location: todo/
Technology: ink! v5.1.1
Basic todo list implementation using Vec storage:
- Add tasks
- Mark tasks as complete
- Get all tasks
- Delete tasks
- Simple storage pattern
Location: todo_map/
Technology: ink! v5.1.1
Optimized todo list using Mapping storage:
- More efficient storage
- Individual task access
- Better gas optimization
- Scalable design
Location: frontend/governance-dapp/
Technology: Next.js 15.5.3 + React 19 + TypeScript
A production-ready governance frontend with real contract integration:
- Real Contract Integration: Direct interaction with deployed governance contract
- Wallet Connection: Support for multiple Polkadot wallets
- Proposal Management: Create, view, and vote on proposals
- Voter Registration: Join governance participation
- Real-time Updates: Live data from blockchain
- Responsive Design: Mobile-first UI with Tailwind CSS
- Type Safety: Full TypeScript integration
src/
βββ app/ # Next.js App Router pages
β βββ page.tsx # Home page with stats
β βββ proposals/ # Proposal listing and voting
β βββ create/ # Create new proposals
β βββ dashboard/ # User dashboard
β βββ voters/ # Voter statistics
βββ components/ # Reusable UI components
β βββ create-proposal.tsx
β βββ governance-dashboard.tsx
β βββ shared/ # Shared components
βββ contexts/ # React Context providers
β βββ governance-client.tsx # Contract interaction
β βββ types.ts # TypeScript definitions
βββ lib/ # Utilities and types
βββ governance-types.ts
- Framework: Next.js 15.5.3 with App Router
- UI Library: Radix UI + Tailwind CSS
- Web3 Integration: Polkadot API + Typink
- State Management: React Context API
- Type Safety: TypeScript 5.9.2
- Wallet Integration: Talisman Connect
Location: frontend/erc20fe/
Technology: Next.js 15.5.4 + React 19
Modern Next.js application for token interaction:
- Framework: Next.js 15.5.4 with TypeScript
- Styling: Tailwind CSS
- Web3 Integration: Polkadot.js API
- Features:
- Wallet connection
- Token balance display
- Transfer functionality
- Transaction history
- Real-time updates
Location: frontend/web3bridge-curriculum/
Technology: React + Vite
Educational materials and demos:
- ink-papi-demo: React + Vite demo application
- Learning Resources: Comprehensive tutorials
- Contract Examples: Step-by-step implementations
- Best Practices: Development guidelines
# Development build (faster, with debug info)
cargo contract build
# Production build (optimized, smaller size)
cargo contract build --release# Run unit tests
cargo test
# Run integration tests
cargo test --features e2e-tests# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm startsubstrate-contracts-node --dev
cargo contract instantiate --constructor new --suri //AliceVisit: https://contracts-ui.substrate.io/
Visit: https://polkadot.js.org/apps/
- Rococo Contracts:
wss://rococo-contracts-rpc.polkadot.io - Aleph Zero Testnet:
wss://ws.test.azero.dev
Most contracts implement these standard functions:
// Token contracts
total_supply() -> Balance
balance_of(owner: AccountId) -> Balance
transfer(to: AccountId, value: Balance) -> Result<(), Error>
approve(spender: AccountId, value: Balance) -> Result<(), Error>
// Todo contracts
add_task(description: String) -> u32
complete_task(id: u32) -> bool
get_task(id: u32) -> Option<Task>
get_all_tasks() -> Vec<Task>
// Governance contracts
create_proposal(title: String, description: String, ...) -> u32
vote(proposal_id: u32, option_index: u32) -> Result<(), Error>
execute_proposal(proposal_id: u32) -> Result<(), Error>
register_voter() -> Result<(), Error>All contracts use these core dependencies:
ink! v5 Contracts:
[dependencies]
ink = { version = "5.1.1", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.11", default-features = false, features = ["derive"] }ink! v6 Contracts:
[dependencies]
ink = { git = "https://github.com/use-ink/ink", tag = "v6.0.0-alpha.4", version = "6.0.0-alpha.4", default-features = false, features = ["unstable-hostfn"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }Governance DApp:
{
"dependencies": {
"next": "^15.5.3",
"react": "^19.1.1",
"polkadot-api": "^1.20.0",
"@talismn/connect-wallets": "^1.2.8",
"typink": "^0.5.0",
"tailwindcss": "^4.1.13"
}
}cargo testcargo test --features e2e-testscd frontend/governance-dapp
npm test# Install compatible node version
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --tag v0.47.0 --locked --force# Check if node is running
substrate-contracts-node --dev
# Verify node health
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_health"}' \
http://localhost:9944- Use pre-funded test accounts:
//Alice,//Bob,//Charlie - Request funds from testnet faucet
# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Rebuild
npm run buildβββββββββββββββββββββββββββββββββββββββ
β Frontend Apps β
β (Next.js, React, TypeScript) β
βββββββββββββββββββββββββββββββββββββββ€
β Polkadot API β
β (Web3 Integration Layer) β
βββββββββββββββββββββββββββββββββββββββ€
β Substrate Runtime β
β (Blockchain Infrastructure) β
βββββββββββββββββββββββββββββββββββββββ€
β ink! Contracts β
β (Smart Contract Layer) β
βββββββββββββββββββββββββββββββββββββββ
User β Frontend β Polkadot API β Substrate Node β ink! Contract
βββββββββββββββββββββββββββββββββββββββ
β User Interface β
β (React Components + Tailwind) β
βββββββββββββββββββββββββββββββββββββββ€
β Context Providers β
β (Wallet + Governance Context) β
βββββββββββββββββββββββββββββββββββββββ€
β Contract Client β
β (Polkadot API + Typink) β
βββββββββββββββββββββββββββββββββββββββ€
β Smart Contract β
β (ink! Governance Contract) β
βββββββββββββββββββββββββββββββββββββββ
- DeFi Applications: Lending, borrowing, staking
- NFT Marketplaces: Payment tokens
- DAO Governance: Voting tokens
- Cross-chain Bridges: Bridge tokens
- DAO Management: Decentralized decision making
- Treasury Management: Fund allocation
- Protocol Upgrades: Governance-controlled changes
- Community Voting: Proposal and voting systems
- Todo Lists: Task management dApps
- Piggy Banks: Savings and goal tracking
- Escrow Services: Secure fund holding
- Multi-signature Wallets: Shared control
- Safe Arithmetic: Overflow/underflow protection
- Access Control: Owner-only functions
- Input Validation: Parameter checking
- Event Logging: Comprehensive event emission
- Error Handling: Detailed error messages
- Testing: Unit and integration tests
- Pausable contracts for emergency stops
- Blacklist functionality for malicious addresses
- Time-locked operations for critical functions
- Multi-signature requirements for sensitive operations
- Quorum requirements for governance decisions
- Mapping vs Vec: Efficient storage selection
- Packed Structs: Optimized data layout
- Lazy Loading: On-demand data access
- Batch Operations: Reduced transaction costs
- Minimal Storage: Only store necessary data
- Efficient Algorithms: Optimized computation
- Event Optimization: Selective event emission
- Contract Size: Minimized WASM size
- Code Splitting: Lazy loading of components
- Image Optimization: Next.js image optimization
- Bundle Analysis: Webpack bundle analyzer
- Caching: Strategic caching strategies
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Follow Rust conventions
- Add comprehensive tests
- Document public functions
- Use meaningful variable names
- Implement proper error handling
- Follow TypeScript best practices
- Use consistent formatting
- Ensure all tests pass
- Update documentation
- Add changelog entries
- Request code review
- Address feedback
- Merge after approval
This project is provided as-is for educational purposes. Individual contracts may have different licenses - check each contract's directory for specific licensing information.
For issues and questions:
- Create an issue in the repository
- Join the ink! Discord community
- Check the troubleshooting section above
- Review the documentation links
- β Real contract integration with Polkadot API
- β Production-ready build system
- β Comprehensive error handling
- β Mobile-responsive design
- β Type-safe contract interactions
- β Wallet connection support
- β Real-time blockchain data
- β ink! v6.0.0-alpha.4 support
- β Enhanced governance features
- β Improved error handling
- β Optimized storage patterns
- β Comprehensive test coverage
π¦ Built with Rust + ink! v6.0.0-alpha.4
This collection demonstrates the power and flexibility of ink! smart contracts in the Polkadot ecosystem, from simple utility contracts to complex governance systems with production-ready frontends.