near/dev-guide
NEAR Protocol Development Guide
nearguide👥 Communityconfidence highhealth 100%
v1.0.0·Updated 3/20/2026
NEAR Core Features
- Human-readable account names: alice.near (string, not hexadecimal)
- Subaccounts: app.alice.near is a subaccount of alice.near
- Storage Staking: storage requires staking NEAR (1 NEAR = 10KB)
- Asynchronous cross-contract calls: via Promise, non-blocking
- Aurora: EVM chain on NEAR, runs Solidity directly
- Low gas: transaction fees < $0.001
Rust Contracts
rustup target add wasm32-unknown-unknown
cargo install cargo-near near-cli-rs
cargo near new my-contract && cd my-contract
use near_sdk::{near, store::LookupMap, AccountId};
#[near(contract_state)]
pub struct Contract {
owner: AccountId,
balances: LookupMap<AccountId, u128>,
}
#[near]
impl Contract {
#[init]
pub fn new(owner: AccountId) -> Self {
Self { owner, balances: LookupMap::new(b"b") }
}
#[payable]
pub fn deposit(&mut self) {
let amount = near_sdk::env::attached_deposit().as_yoctonear();
let caller = near_sdk::env::predecessor_account_id();
let bal = self.balances.get(&caller).unwrap_or(&0);
self.balances.insert(caller, bal + amount);
}
pub fn get_balance(&self, account_id: AccountId) -> u128 {
self.balances.get(&account_id).copied().unwrap_or(0)
}
}
# Build and deploy
cargo near build
near contract deploy my-account.testnet use-file ./target/near/my-contract.wasm without-init-call network-config testnet
JavaScript SDK (Frontend)
import { connect, keyStores, WalletConnection } from "near-api-js"
const near = await connect({
networkId: "mainnet", nodeUrl: "https://rpc.mainnet.near.org",
walletUrl: "https://app.mynearwallet.com",
keyStore: new keyStores.BrowserLocalStorageKeyStore()
})
const wallet = new WalletConnection(near, "my-app")
if (!wallet.isSignedIn()) wallet.requestSignIn({ contractId: "my-contract.near" })
// view call (free)
const result = await (await near.account("my-contract.near")).viewFunction({
contractId: "my-contract.near", methodName: "get_balance",
args: { account_id: wallet.getAccountId() }
})
// write to contract (requires signature)
await wallet.account().functionCall({
contractId: "my-contract.near", methodName: "deposit", args: {},
attachedDeposit: BigInt("1000000000000000000000000"), // 1 NEAR
gas: BigInt("30000000000000") // 30 TGas
})
Storage Staking Considerations
1 byte ≈ 0.00001 NEAR, 1KB ≈ 0.01 NEAR. Make users pay for their own storage costs:
#[payable]
pub fn register_user(&mut self) {
let deposit = near_sdk::env::attached_deposit().as_yoctonear();
near_sdk::require!(deposit >= 100_000_000_000_000_000_000_000u128, "Need 0.1 NEAR for storage");
}
Aurora (EVM on NEAR)
Fully EVM compatible, Chain ID: 1313161554, RPC: https://mainnet.aurora.dev Rainbow Bridge connects NEAR and Ethereum. Deploy directly with Hardhat/Foundry.