Skip to main content
Version: Next

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โ€‹

  • Both handle communication with the network at different levels.
  • Provider: Your main connection to Starknet nodes. Handles high-level communication. Available as the RpcProvider class.
  • Channel: Handles low-level communication. Available as the RpcChannel and WebSocketChannel classes that support HTTP and WebSocket connections, respectively.

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!