NEAR Core: Reference client for NEAR Protocol
Reference implementation of NEAR Protocol blockchain, providing infrastructure for smart contracts and applications.
Learn more about NEAR Core
NEAR Core is the reference implementation of NEAR Protocol, a blockchain platform designed for smart contracts and decentralized applications. The implementation is written in Rust and supports WebAssembly-based smart contracts, providing a complete node software for participating in the NEAR network. The architecture focuses on usability and scalability through sharding and other consensus mechanisms. Developers use NEAR Core to run validator nodes, build applications, or contribute to the protocol's development.
WebAssembly Support
Executes smart contracts compiled to WebAssembly, allowing developers to write contracts in multiple programming languages including Rust and JavaScript.
Sharding Architecture
Implements a sharded blockchain design to improve transaction throughput and network scalability compared to single-chain architectures.
Multiple Networks
Supports mainnet, testnet, and betanet environments, allowing developers to test and deploy applications across different network configurations.
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{env, near_bindgen, AccountId, Balance, Promise};
use std::collections::HashMap;
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct TokenContract {
balances: HashMap<AccountId, Balance>,
total_supply: Balance,
}
impl Default for TokenContract {
fn default() -> Self {
Self {
balances: HashMap::new(),
total_supply: 0,
}
}
}
#[near_bindgen]
impl TokenContract {
pub fn transfer(&mut self, receiver_id: AccountId, amount: Balance) {
let sender_id = env::predecessor_account_id();
let sender_balance = self.balances.get(&sender_id).unwrap_or(&0);
assert!(sender_balance >= &amount, "Insufficient balance");
self.balances.insert(sender_id.clone(), sender_balance - amount);
let receiver_balance = self.balances.get(&receiver_id).unwrap_or(&0);
self.balances.insert(receiver_id, receiver_balance + amount);
}
pub fn get_balance(&self, account_id: AccountId) -> Balance {
self.balances.get(&account_id).unwrap_or(&0).clone()
}
}Performance optimizations and bug fixes for state sync and indexer
- –State sync performance optimization
- –Indexer fix for double hashing of code as part of DeployContract and DeployGlobalContract actions
- –GlobalContractIdentifierView serialization fix
Critical security release fixing network code flaws that could cause node crashes
- –Fixes critical flaws in network code that could cause node crash
- –Upgrade as soon as possible to avoid node downtime
Network traffic and data copying optimizations for state snapshots and archival nodes
- –Optimize the network traffic involved in distributing state snapshot information between nodes
- –Optimize data copying to make sure archival node can keep up with the chain
Related Repositories
Discover similar tools and frameworks used by developers
Agave
Blockchain validator software designed for fast, secure, and scalable decentralized applications and marketplaces.
Kubo
The first and most widely used IPFS implementation, providing distributed file storage and content addressing.
Bitcoin Core
Reference implementation of the Bitcoin protocol that connects to the peer-to-peer network for block validation.
Foundry
A modular toolkit for Ethereum application development that includes compilation, testing, and deployment tools.
MetaMask Extension
Browser extension that provides wallet functionality for interacting with Ethereum blockchain applications.