All pages
Powered by GitBook
1 of 1

Loading...

Smart Contract Stack

Runtime Architecture

UOMI's runtime is built on Substrate and incorporates pallet-contracts, providing a sandboxed environment for WebAssembly smart contracts. While any language that compiles to Wasm can potentially be used, the code must be compatible with the pallet-contracts API.

💡 Tip For efficient development, it's recommended to use an eDSL (embedded Domain-Specific Language) targeting pallet-contracts, such as:

  • ink! (Rust-based)

  • ask! (AssemblyScript-based)

Execution Environment

Interpreter

The pallet-contracts uses the wasmi interpreter to execute Wasm smart contracts.

ℹ️ Note While faster JIT interpreters like wasmtime exist, wasmi is chosen for its higher degree of interpretation correctness, which is crucial for the untrusted environment of smart contracts.

Contract Deployment Process

Contract deployment follows a two-step process:

  1. Code Upload

    • Upload Wasm contract code to the blockchain

    • Each contract receives a unique code_hash identifier

  2. Contract Instantiation

Benefits of Two-Step Deployment

  1. Storage Efficiency

    • Multiple instances can share the same code

    • Reduces on-chain storage requirements

    • Particularly efficient for standard tokens (like PSP22 & PSP34)

Development Tools

Client APIs

🔧 Available Tools

  • Polkadot.js API for blockchain interaction via JavaScript

  • contracts-ui web application for contract interaction

Comparison with Ethereum

Feature
Ethereum
UOMI

Additional Resources

  • pallet-contracts Rust Documentation

  • pallet-contracts GitHub Repository

  • Polkadot.js API Documentation

📚 Further Reading For more detailed information about pallet-contracts, visit the Rust docs or GitHub repository.

  • Create contract address and storage

  • Anyone can instantiate a contract using its code_hash

  • Flexible Deployment

    • Create new instances from existing contracts

    • Use code_hash for contract instantiation within other contracts

    • Single upload for standard contracts, reducing gas costs

  • Upgradability

    • Update contract code while preserving storage and balances

    • Use set_code_hash to replace contract code at specific addresses

  • Standards

    EIPs

    PSPs

    Architecture

    Ethereum clients

    Substrate

    Runtime Environment

    EVM

    Wasm pallet-contract + EVM frontier

    Gas Model

    Fixed price per instruction

    Weight + storage fees + loading fees

    Smart Contract DSLs

    Solidity and Vyper

    ink! (Rust) and ask! (AssemblyScript)