Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates Ink! events with a simple log message.
#[ink::contract]
mod logger {
#[ink(event)]
pub struct Log {
#[ink(topic)]
from: AccountId,
msg: String,
}
#[ink(storage)]
pub struct Logger {}
impl Logger {
#[ink(constructor)]
pub fn new() -> Self { Self {} }
#[ink(message)]
pub fn fire(&self, msg: String) {
self.env().emit_event(Log { from: self.env().caller(), msg });
}
}
}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.
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.