Salta ai contenuti

Introduction to Polkadot Development Stack

Questi contenuti non sono ancora disponibili nella tua lingua.

A practical, up-to-date map of the open-source Polkadot Stack—wallets, SDKs, client libraries, smart-contract tooling, node infrastructure, governance dashboards, explorers, and front-end integrations—plus workflows, gotchas, and FAQs for builders shipping real dapps on Polkadot and its parachains.

What is the “Polkadot Stack”?

ELI5: Polkadot is a network of blockchains. The Polkadot Stack is the open-source toolbox developers use to build apps, launch chains, deploy smart contracts, view data, and participate in governance—everything from wallets and APIs to SDKs and dashboards.

Pro view: The stack spans Layer-0 (Relay Chain), Layer-1s (parachains), and application layers. It includes the Polkadot Blockchain SDK (formerly “Substrate”), ink! for Wasm contracts, client libraries in TypeScript/Rust/Go/Python, light clients (smoldot), and DX tooling (Zombienet, Chopsticks, benchmarking CLI) plus UX layers (wallets, explorers, governance UIs).

Architecture Layers

  • Base / Execution: Relay Chain + parachains (runtime logic via FRAME pallets or ink! contracts on chains that enable pallet-contracts).
  • Middleware: RPCs, indexing, type generation, light clients, and cross-chain messaging.
  • Application: Wallets, dapps, dashboards, and domain tooling (DeFi, NFTs, DAOs, identity).

Core Categories & Representative OSS Projects

Wallets

  • Web & multisig: Multix, Polkasafe, polkadot-js/apps (accounts, transfers, governance).
  • Desktop / enterprise: nova-spektr for operational controls and policy workflows.
  • Browser extensions: Talisman Extension, SubWallet Extension for account injection and signing.
  • Mobile: Nova Wallet (iOS/Android), Fearless Wallet (iOS/Android).
  • Hardware: Ledger Polkadot/Kusama apps (cold storage + secure signing).

When to use what:

  • Everyday users: Mobile + extension combo.
  • Teams/DAOs: Multisig dashboards (Multix/Polkasafe) + hardware keys.
  • Power users/validators: Desktop tooling with richer telemetry & policy controls.

User Interfaces & Observability

  • Explorers: Statescan, Subscan (blocks, extrinsics, accounts, assets).
  • Validator ops: Telemetry (real-time peers, block authorship), Cyclops.
  • Governance & treasury: Delegation Dashboard (Polkassembly UI), doTreasury.
  • NFTs: Kodadot (multi-chain NFT explorer for Polkadot/Kusama).

SDKs, Client Libraries & Languages

  • Runtime/Parachain frameworks: Polkadot Blockchain SDK (FRAME pallets, consensus), Gosemble (Go-based runtime authoring).
  • Client libraries:
    • TypeScript: Polkadot API (PAPI) / polkadot-api
    • Go: go-substrate-rpc-client
    • Rust: substrate-api-client
    • Python: py-substrate-interface
  • Smart-contract languages: ink! (Rust eDSL for Wasm), Solang (Solidity→Wasm), experimental Move pallets.
  • Testing & benchmarking: Zombienet (multi-node nets), polkadot-launch, Chopsticks (forked-state testing), FRAME benchmarking CLI.

ink! Smart-Contract Tooling

  • Core: ink!, cargo-contract, pallet-contracts (Wasm VM in runtimes).
  • Dev UX: contracts-ui, SmartBeaver, OpenBrush (traits & standards), Sol2Ink, Polkadot Contract Wizard, ink! Playground/Remix plugin.
  • Security & QA: ink-waterfall, verifier images, fuzzers (Inkscope), test suites; analyzers/linters.
  • Frontend integration: useink / use-inkathon, type generators (ink-typegen, Typechain Polkadot).

Chains, Pallets & Protocols

  • DeFi/general-purpose parachains: Astar, Moonbeam, Acala, Hydration (Omnipool).
  • Bridges & interoperability: Interlay (interBTC), Darwinia.
  • Privacy/ZK: Phala (TEE-backed privacy services), PLONK/zk tooling for Substrate ecosystems.

Hosts, Light Clients & Node Ops

  • Hosts: Polkadot SDK/Substrate (Rust), Kagome (C++).
  • Light clients: smoldot (embed in browsers/apps), Substrate Connect.
  • Validator automation & monitoring: Ansible playbooks, ONE-T, SubVT; common stacks: Prometheus + Grafana; sentry nodes; snapshot tooling.

Signatures, Consensus & Networking

  • Crypto: SR25519 (schnorrkel) for account keys, Ed25519 for consensus roles when needed.
  • Consensus: BABE (block production) + GRANDPA (finality).
  • Networking: libp2p (gossip, discovery, multiplexing).

Front-End Dev Stack: Reactive DOT, PAPI, Onboard, polkadot.js

  • Reactive DOT — a reactive programming framework for Polkadot dapp UIs; component-based patterns that subscribe to chain state and events with minimal boilerplate.
  • Polkadot API (PAPI / polkadot-api) — modern TypeScript client emphasizing strong typing, generated interfaces, and ergonomic subscriptions/transactions.
  • Polkadot Onboard — wallet-connectivity layer providing a unified interface across injected, WalletConnect, and hardware wallets for Polkadot ecosystems.
  • polkadot.js — the long-standing JS library with broad ecosystem adoption; still useful, especially for legacy apps and quick prototypes. Many teams increasingly evaluate newer stacks (e.g., PAPI + smoldot) for DX, typing, and bundle size benefits.

Feature Comparison: Front-End & Integration Libraries

ToolPrimary RoleStrengthsTypical Use CasesLearning CurveMaintainer/Ecosystem
Reactive DOTUI frameworkReactive dataflows; component patterns; live chain subscriptionsReal-time dashboards, wallets, traders’ UIsModerate (framework mindset)Community framework focused on Polkadot
PAPI (polkadot-api)TS client libraryStrong types, codegen, concise subscriptions/txModern TS apps, strict typing, scalable codebasesLow–ModerateActive community; modern TS
Polkadot OnboardWallet integrationOne API for many wallets; WalletConnect supportDapps needing broad wallet coverageLowOpen-source, wallet-agnostic
polkadot.jsJS/TS client libraryMature, battle-tested, rich examplesLegacy apps, quick tooling, wide compatibilityLowHistoric ecosystem standard
smoldotLight clientTrust-minimized, in-browser validationWallet UIs, privacy-sensitive appsModerate (client mgmt)Parity/Community
Substrate ConnectLight-client wrapperDeveloper-friendly bundling of smoldotBrowser apps wanting LC without full infraLow–ModerateParity/Community

Tip: For greenfield TS projects, many teams pair PAPI + Polkadot Onboard + smoldot/Substrate Connect and optionally layer Reactive DOT for UI reactivity.

Build Workflow: From Local Dev to Production

1) Plan your target

  • Smart contract on an existing parachain? → ink! + pallet-contracts.
  • Custom chain? → Polkadot SDK (FRAME), pallets, runtime benchmarking.
  • Front-end only? → PAPI + wallet onboarding + light client.

2) Stand up local & ephemeral networks

  • Local contracts: substrate-contracts-node or chain-specific dev nodes.
  • Ephemeral nets: Zombienet or polkadot-launch to simulate validators/parachains.
  • Forked-state tests: Chopsticks for realistic, reproducible scenarios.

3) Inner-loop dev

  • ink! contracts: cargo-contract new/build/test/instantiate.
  • Runtime dev: add FRAME pallets, cargo build --release, run unit/bench tests.
  • Front-end: generate types, wire RPC/light client, add wallet onboarding, subscriptions.

4) Security, QA & performance

  • ink!: run fuzzers, property tests, static analyzers; watermark audits in docs.
  • Runtime: benchmarking & weights; storage migration tests; upgrade rehearsals.
  • Front-end: handle chain metadata changes; schema/type generation in CI.

5) Testnet → Mainnet

  • Testnets: Paseo/Westend or chain-specific testnets; acquire faucet tokens.
  • Observability: dashboards (Telemetry, Prometheus/Grafana), log hygiene.
  • Dry-run governance flows: if your app depends on OpenGov or treasury.

Common Pitfalls & Pro Tips

  • Breaking metadata/types: Runtime upgrades can change types. Automate typegen (CI step) and pin compatible versions.
  • Missing weight/fees: Contracts & extrinsics may fail due to fees/weights. Estimate at runtime and expose UX hints.
  • Wallet fragmentation: Different signing flows across wallets. Use Polkadot Onboard for a unified interface.
  • Over-trusting RPCs: For UX and resilience, prefer light clients where feasible; fall back to RPCs gracefully.
  • Ignoring XCM: Cross-chain assets/logic are first-class in Polkadot. Model XCM (routing, fees, HRMP) early in your design.
  • Security last: Fuzzers, audits, and caps (allow-lists, rate limits) before mainnet.
  • Governance blind spots: If you rely on chains’ features/funding, track OpenGov timelines and treasury policies.

FAQs

1) Should I build an ink! contract or a custom pallet? Start with ink! when you need fast iteration, app-level logic, or portability across multiple contract-enabled chains. Choose FRAME pallets for deep protocol features, custom fee logic, or performance that contracts can’t deliver.

2) Is polkadot.js obsolete? No. It’s widely used and reliable. Many new projects evaluate PAPI for type-safety and DX while keeping polkadot.js in maintenance or tooling roles.

3) Do I need a light client? Not strictly. But smoldot/Substrate Connect improves trust, privacy, and resilience—great for wallets and critical UX.

4) How do I test multi-chain features? Use Zombienet to spin up multiple nodes/parachains and Chopsticks for forked-state scenarios. Script XCM routes and failure modes.

5) What’s the quickest way to ship a MVP dapp UI? PAPI + Onboard + hosted RPC (with a plan to add smoldot). For contracts, add cargo-contract + contracts-ui for quick cycles.

6) How do I keep up with runtime changes? Pin versions, run typegen in CI, subscribe to chain release notes, and include compat tests against upcoming metadata.

7) Can I port Solidity? Yes—Solang compiles Solidity to Wasm for Parity’s contracts pallet. Expect differences in tooling and standards—test thoroughly.

8) How do I monitor validators? Telemetry for live health, Prometheus/Grafana for metrics dashboards, and tools like ONE-T/SubVT for alerts and historical insights.

Conclusion

Polkadot’s open-source stack gives you everything to ship—from smart contracts and custom runtimes to wallet UX, governance, and observability. Start small (testnet + ink! or PAPI), automate typegen and tests, then layer light-clients and XCM as you scale.