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:
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:
- Your dApp interacts with Starknet.js through its JavaScript/TypeScript interface
- Starknet.js comprises several classes and utilities that abstract and simplify interacting with Starknet
- 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 theRpcProvider
class.Channel
: Handles low-level communication. Available as theRpcChannel
andWebSocketChannel
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 formattingSigner
: Cryptographic operations and message signing
Network Compatibilityโ
Connect your dApp to any Starknet environment:
Network | Description | Use Case |
---|---|---|
Mainnet | Production network (Layer 2 of Ethereum) | Live applications |
Testnet | Test network (Layer 2 of Sepolia) | Testing & development |
Devnet | Local development network | Rapid 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:
- Starknet Documentation - Understanding the network
- Cairo Programming - Smart contract development
- JavaScript/TypeScript fundamentals
Next Stepsโ
Ready to start building? Head to our Getting Started guide to begin your journey with Starknet.js!