Blockchain technology has revolutionized numerous industries with its decentralized and secure approach to data management. However, as adoption grows, traditional blockchain architectures face significant scaling challenges. Sharded contracts represent one of the most promising solutions to these limitations, offering a path to truly scalable decentralized applications.
The Fundamental Problem: Blockchain Scalability
Traditional non-sharded blockchains like Bitcoin and Ethereum (pre-2.0) operate on a simple but limiting principle: every node in the network processes the same transactions and maintains an identical copy of the entire state. While this approach maximizes security and decentralization, it creates an inherent bottleneck.
Adding more nodes to such networks doesn’t improve performance—it simply reinforces the existing consensus model. This leads to two critical problems:
- Limited Throughput: The network can only process as many transactions as a single chain can handle.
- State Growth: As the blockchain grows, the state becomes increasingly unwieldy for nodes to maintain.
Sharding: The First Step Toward Scalability
Sharding divides the blockchain network into smaller partitions called “shards.” Each shard functions as its own mini-blockchain with its own set of validators who process transactions specific to that shard. This creates parallel processing capability that can scale linearly with the number of shards.
In NEAR’s implementation, rather than each shard maintaining a separate chain (which creates complex fork management issues), there’s only one main chain. Each block on this chain contains “chunks” from every shard, simplifying security and cross-shard communication.
Sharding effectively addresses both throughput limitations and state growth concerns by distributing the network’s workload and state across multiple partitions. However, there’s a critical limitation that standard sharding alone doesn’t solve.
The Overlooked Challenge: Smart Contract Limitations
While sharding solves many scalability issues, it introduces a new challenge: what happens when a single smart contract becomes extremely popular and grows very large?
Consider popular DeFi applications like Uniswap or consumer applications with millions of users. These contracts store massive amounts of data and handle high transaction volumes. In a standard sharded environment, each smart contract must reside on a specific shard, meaning:
- The contract’s throughput is limited by the capacity of a single shard
- The contract’s state can grow to unmanageable sizes within that shard
This creates a bottleneck that undermines the benefits of sharding for the most successful applications—precisely those that need scalability the most.
Sharded Smart Contracts: The Solution
Sharded smart contracts elegantly solve this problem by fundamentally changing how contracts exist and store data on the blockchain. A sharded contract:
- Exists simultaneously across all shards through global contract code
- Stores user data on individual user accounts rather than in the contract’s own storage
How It Works: Global Contract Code
Instead of deploying a contract to a specific account, global contract code is deployed to a special state that’s available on all shards simultaneously. This deployment:
- Generates receipts that propagate to every shard
- Updates a global contract state on each shard
- Is intentionally expensive to prevent spam/attacks
Other users can then reference this globally deployed code without redeploying it themselves, creating an efficient system for code reuse across the network.
How It Works: User Account Storage
The second critical innovation is changing where contract data is stored. Instead of maintaining a centralized mapping of user data within the contract account, data is stored within namespaces on the users’ own accounts.
For example, in a traditional USDT contract:
- The USDT account stores a mapping of all users to their balances
- All operations must interact with this central account
In a sharded USDT contract:
- Each user account contains a “usdt.near” namespace
- This namespace stores the user’s USDT balance
- Transfers happen directly between user accounts via cross-shard communication
This reverses the traditional storage model, transforming one massive storage problem into many small, distributed storage operations that naturally benefit from sharding.
Benefits of Sharded Smart Contracts
This architectural shift delivers several crucial advantages:
- Linear Scalability: Contract throughput scales with the number of shards, just as the overall network does
- Manageable State Growth: No single account needs to store enormous amounts of data
- Natural Distribution: User data is automatically distributed according to the network’s existing sharding boundaries
- Complete Scalability Solution: Addresses both throughput and state growth concerns holistically
Implementation Status
NEAR is currently building this solution in two phases:
- Global contract code (already developed and soon to be released)
- User account storage for contract data (currently in development)
Together, these components will make sharding a complete solution to blockchain scaling problems, handling both throughput limitations and state growth challenges.
Watch full talk “From Sharded Blockchain to Sharded Smart Contract” by Bowen Wang, NEAR One founder
Conclusion
Sharded smart contracts represent a significant leap forward in blockchain scalability technology. By tackling the often-overlooked challenge of large contract scaling, they remove one of the final barriers to truly scalable decentralized applications. As this technology matures and becomes widely available, it will enable blockchain applications to support user bases in the millions or even billions without sacrificing performance or decentralization.
For developers building high-scale applications on blockchain, sharded contracts offer a pathway to unlimited growth potential without the traditional constraints of blockchain architecture.
This is a crucial point that often gets overlooked in the excitement around sharding as a scalability solution. It's ironic that the very success of DeFi applications like Uniswap can become their own scalability bottleneck. As we continue to build complex smart contracts, we need to think creatively about how to distribute the load of these massive contracts across multiple shards. One potential approach could be to design contracts that can dynamically split and reassemble across shards as needed, but this would require significant changes to the way we design and interact with smart contracts. Anyone have thoughts on how we can tackle this challenge?