패리티 잉크는 서브스트레이트에서 제공하는 스마트 컨트랙트 언어입니다. wasm으로 만들어지며 블록체인 안에 디앱을 만들어서 배포할 때 쓰입니다.
현재 플라즈마 개발이 진행 중에 있으며 plasm이 대표적인 예입니다.
contract! {
/// Flips its state between `true` and `false`.
struct Flipper {
/// The current state of our flag.
value: storage::Value<bool>,
}
impl Deploy for Flipper {
/// Initializes our state to `false` upon deploying our smart contract.
fn deploy(&mut self) {
self.value.set(false)
}
}
impl Flipper {
/// Flips the current state of our smart contract.
pub(external) fn flip(&mut self) {
*self.value = !*self.value;
}
/// Returns the current state.
pub(external) fn get(&self) -> bool {
*self.value
}
}
}
다른 예: