1. Home
  2. /
  3. Ink Typing Test
  4. /
  5. Ink! Simple Counter Contract

Ink! Simple Counter Contract - Ink Typing CST Test

Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.

Ink! Simple Counter Contract — Ink Code

A minimal Ink! contract defining a counter with increment and reset functions.

#[ink::contract]
mod counter {
	#[ink(storage)]
	pub struct Counter {
		value: u64,
	}

	impl Counter {
		#[ink(constructor)]
		pub fn new() -> Self {
		Self { value: 0 }
		}

		#[ink(message)]
		pub fn increment(&mut self) {
		self.value += 1;
		}

		#[ink(message)]
		pub fn reset(&mut self) {
		self.value = 0;
		}
	}
}

Ink Language Guide

Ink! is a Rust-based eDSL (embedded domain-specific language) for writing smart contracts on the Substrate blockchain framework. It emphasizes safety, efficiency, and tight integration with Polkadot and Substrate ecosystems.

Primary Use Cases

  • ▸High-security smart contracts
  • ▸DeFi protocols on Substrate
  • ▸NFT minting and marketplaces
  • ▸On-chain governance modules
  • ▸Wasm-based blockchain apps

Notable Features

  • ▸Rust-based syntax
  • ▸Compile-time type safety
  • ▸Wasm target for Substrate
  • ▸Macros for contract boilerplate
  • ▸Support for storage, events, and messages

Origin & Creator

Ink! was created by Parity Technologies, the team behind Substrate and Polkadot, to provide a safe Rust-based smart contract language for WebAssembly chains. Initial development started around 2018.

Industrial Note

Ink! is primarily used in Substrate-based chains and Polkadot parachains, for high-assurance contracts in DeFi, on-chain governance, NFT minting, and other blockchain-native applications.

Quick Explain

  • ▸Ink! uses Rust syntax with domain-specific macros for blockchain smart contracts.
  • ▸It provides compile-time safety and strong typing, reducing runtime errors.
  • ▸Contracts compile to WebAssembly (Wasm) to run on Substrate-based chains.
  • ▸Designed for formal verification and predictable execution.
  • ▸Used in DeFi, NFTs, and governance applications within Polkadot and Kusama ecosystems.

Core Features

  • ▸#[ink(storage)] for state
  • ▸#[ink(event)] for events
  • ▸#[ink(message)] for callable functions
  • ▸Cross-contract calls
  • ▸Metadata generation for contracts

Learning Path

  • ▸Learn Rust basics
  • ▸Understand Substrate architecture
  • ▸Write simple ink! contracts
  • ▸Compile and deploy Wasm
  • ▸Test, audit, and deploy production contracts

Practical Examples

  • ▸Simple key-value store
  • ▸ERC-20-like token
  • ▸NFT minting and transfer
  • ▸Voting and governance module
  • ▸Cross-contract calls for DeFi pools

Comparisons

  • ▸Ink! vs Solidity: Ink! is Rust-based and Wasm-native; Solidity is EVM-native.
  • ▸Ink! vs Vyper: Ink! runs on Substrate/Wasm; Vyper runs on EVM.
  • ▸Ink! vs Solidity + EVM: Ink! has strong Rust type safety; Solidity has larger ecosystem.
  • ▸Ink! vs Move: Move is resource-based, Ink! is Rust/Wasm based.
  • ▸Ink! vs Cairo: Cairo targets STARKs; Ink! targets Substrate/Wasm chains.

Strengths

  • ▸Safe, type-checked contracts
  • ▸High performance via Wasm
  • ▸Strong ecosystem support in Polkadot
  • ▸Auditable Rust code
  • ▸Predictable gas and storage behavior

Limitations

  • ▸Limited to Substrate/Wasm chains
  • ▸Smaller ecosystem than Solidity/EVM
  • ▸Requires Rust proficiency
  • ▸No EVM compatibility
  • ▸Less tooling for testing vs EVM chains

When NOT to Use

  • ▸EVM-based chains
  • ▸Projects requiring Solidity tooling
  • ▸Developers unfamiliar with Rust
  • ▸Contracts targeting non-Substrate chains
  • ▸Projects needing large pre-existing libraries from Solidity

Cheat Sheet

  • ▸#[ink(storage)] -> contract state struct
  • ▸#[ink(event)] -> blockchain event
  • ▸#[ink(message)] -> public function
  • ▸Constructor via #[ink(constructor)]
  • ▸Traits for cross-contract calls

FAQ

  • ▸Is ink! Rust-based?
  • ▸Yes - fully built on Rust.
  • ▸Can ink! run on EVM?
  • ▸No - targets Wasm/Substrate.
  • ▸Is ink! safe for DeFi?
  • ▸Yes - Rust safety + compile-time checks.
  • ▸Does ink! support NFTs?
  • ▸Yes - with PSP34 standard.
  • ▸Can ink! contracts call each other?
  • ▸Yes - via cross-contract trait calls.

30-Day Skill Plan

  • ▸Week 1: Rust syntax and ownership
  • ▸Week 2: ink! storage & messages
  • ▸Week 3: Events and cross-contract calls
  • ▸Week 4: Unit testing & simulation
  • ▸Week 5: Deploy real-world applications on Substrate

Final Summary

  • ▸Ink! is a Rust-based smart contract language for Substrate.
  • ▸Safe, high-performance, Wasm-targeted.
  • ▸Ideal for DeFi, NFTs, governance, and blockchain-native apps.
  • ▸Leverages Rust's type safety and macros for secure contracts.
  • ▸Perfect for developers targeting Polkadot/Kusama ecosystems.

Project Structure

  • ▸lib.rs - main contract code
  • ▸Cargo.toml - Rust project config
  • ▸tests/ - Rust unit tests
  • ▸target/ - compiled Wasm artifacts
  • ▸metadata.json - ABI for frontend interaction

Monetization

  • ▸Develop Polkadot DeFi contracts
  • ▸Offer audited NFT templates
  • ▸Consult on ink! contract development
  • ▸Sell governance modules
  • ▸Educational workshops

Productivity Tips

  • ▸Leverage ink! macros
  • ▸Write modular contracts
  • ▸Unit-test extensively
  • ▸Keep Wasm code minimal
  • ▸Use cargo-contract CLI efficiently

Basic Concepts

  • ▸Storage struct holds contract state
  • ▸Messages are public callable functions
  • ▸Events record contract activity
  • ▸Cross-contract calls allowed via ink! traits
  • ▸Constructor initializes contract state

Official Docs

  • ▸https://paritytech.github.io/ink-docs/
  • ▸https://github.com/paritytech/ink

More Ink Typing Exercises

Ink! Owner-Only MessageInk! Simple ERC20 TokenInk! Simple Vault (Deposit + Withdraw)Ink! Timelock ContractInk! Simple VotingInk! Whitelist AccessInk! Event LoggerInk! Immutable Config ExampleInk! Simple Multiplier

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher