Skip to main content
Version: 11.x

Why Starknet JS

Starknet.js is your gateway to building powerful decentralized applications (dApps) on Starknet. As the official JavaScript/TypeScript library for Starknet, it provides a comprehensive suite of tools to interact with the Starknet network, making blockchain development accessible and efficient.

Why Choose Starknet.js?โ€‹

  • ๐Ÿš€ Easy Integration: Simple, intuitive APIs for interacting with Starknet
  • ๐Ÿ”’ Type Safety: Full TypeScript support with smart contract type generation
  • โšก High Performance: Optimized for handling Starknet's high throughput
  • ๐Ÿ› ๏ธ Complete Toolset: Everything you need for Starknet development in one package
  • ๐Ÿ“š Well Documented: Extensive documentation and examples

Architecture Overviewโ€‹

The following diagrams illustrate how Starknet.js connects your dApp to the Starknet network:

Starknet.js Architecture

This architecture enables:

  • Seamless communication between your dApp and Starknet nodes
  • Efficient handling of transactions and contract interactions
  • Secure account management and transaction signing
  • Real-time event monitoring and state updates

Key components and their interactions:

  1. Your dApp interacts with Starknet.js through its JavaScript/TypeScript interface
  2. Starknet.js comprises several classes and utilities that abstract and simplify interacting with Starknet
  3. Starknet Network processes transactions and maintains the blockchain state

Starknet.js Core Componentsโ€‹

1. Provider, Channel & Transportโ€‹

  • All three handle communication with the network, at decreasing levels.
  • Provider: Your main connection to Starknet nodes. Handles high-level communication. Available as the RpcProvider class, and as WebSocketProvider when you also want subscriptions.
  • Channel: Handles low-level communication โ€” the JSON-RPC methods of one spec version. RpcChannel carries the requests; subscriptions are served by WebSocketChannel, or by the subscriptions of a WebSocketProvider.
  • Transport: Carries the JSON-RPC envelopes over the wire, as HttpTransport or WsTransport. This is an independent choice: the same channel code runs over either, and only a WebSocket can carry subscriptions.

2. Accountโ€‹

The Account class is your primary interface for:

  • ๐Ÿ’ผ Managing wallets and tokens
  • ๐Ÿ’ฐ Handling transaction fees
  • ๐Ÿ“ Signing and sending transactions
  • ๐Ÿ” Managing account security

3. Contractโ€‹

The Contract class provides:

  • ๐Ÿ“– Reading smart contract state
  • โœ๏ธ Writing to contracts
  • ๐Ÿ”„ Handling contract events
  • ๐Ÿงช Testing contract interactions

4. Utility Toolsโ€‹

  • Utils: Helper functions for data conversion and formatting
  • Signer: Cryptographic operations and message signing

Network Compatibilityโ€‹

Connect your dApp to any Starknet environment:

NetworkDescriptionUse Case
MainnetProduction network (Layer 2 of Ethereum)Live applications
TestnetTest network (Layer 2 of Sepolia)Testing & development
DevnetLocal development networkRapid development

You can also connect to:

  • Custom Starknet deployments
  • Local Starknet nodes (connected to mainnet or testnet)

Prerequisitesโ€‹

Before diving into Starknet.js, familiarize yourself with:

  1. Starknet Documentation - Understanding the network
  2. Cairo Programming - Smart contract development
  3. JavaScript/TypeScript fundamentals

Next Stepsโ€‹

Ready to start building? Head to our Getting Started guide to begin your journey with Starknet.js!