Skip to main content
Smart contracts are pieces of executable code that live in a NEAR account. They can store data, perform transactions in the account’s name, and expose methods so other accounts can interact with them.
Smart Contracts Overview
Developers can choose between using JavaScript or Rust to write smart contracts in NEAR. Regardless of the language chosen, the contract will be compiled into WebAssembly, from which point it can be deployed and executed on the NEAR platform.
New to Smart Contract Development?If you don’t know how smart-contract blockchains work, understand that NEAR smart contracts:
  1. Have limited computational resources
  2. Interact with other contracts in an asynchronous way
  3. Deal with real money, for which security must be a top concern

Where Do Contracts Live?

Smart contracts are deployed into NEAR accounts. Any NEAR account can hold a contract, needing to pay for the contract’s code and the data it stores. Once in an account, anyone can interact with the contract. Thanks to the underlying network structure, executing code from a contract is both fast (avg. 1.4s finality) and cheap. Moreover, read-only operations are free for everyone.
Storing 100kb costs 1Ⓝ, so deploying a contract generally costs only a few $NEARs.

What Can They Do?

Smart contracts have complete control over the account, and thus can perform any action on its behalf. For example, contracts can:

Transfer $NEAR Tokens

Send NEAR tokens to other accounts

Call Other Contracts

Execute methods on other deployed contracts

Create Accounts

Create new accounts and deploy contracts on them

Update Code

Update their own code programmatically
Besides, smart contracts can store data in the account’s storage. This allows contracts to create almost any type of application, from simple games to complex financial systems.
What Contracts Cannot Do
  • Smart contracts cannot access the internet, so they cannot make HTTP requests or access external data
  • Smart contracts cannot execute automatically, they need to be called by an external account

What Are They Used For?

Smart contracts are useful to create decentralized applications. Some traditional examples include:
  • Decentralized Autonomous Organizations (DAOs) - where users create and vote on proposals
  • Marketplaces - where users create and commercialize digital art pieces
  • Decentralized Exchanges (DEXs) - where users can trade different currencies
  • DeFi Protocols - lending, borrowing, and yield farming platforms
  • NFT Projects - collectibles, games, and digital art
For instance, you can easily create a crowdfunding contract that accepts $NEAR. If the goal is met in time, the creator can claim the funds. Otherwise, the backers are refunded.

Development Flow

Just like any piece of software, smart contracts have a development flow - starting with creation and ending with monitoring.
1

Scaffold

The simplest way to create a project is by starting from a template. See Quickstart.
2

Build

Write a contract using Rust or JavaScript. Learn about Contract Anatomy.
3

Test

Our Sandbox enables simulating interactions with contracts in a realistic environment. See Testing.
4

Deploy

After ensuring the contract is secure, deploy it into your account. See Deployment.
5

Use

Any user can interact with the contract through their NEAR Wallet.
6

Monitor

The contract’s activity can be monitored through APIs and indexers.

Supported Languages

During the whole cycle, developers can choose between JavaScript and Rust, allowing them to use their favorite language at each step of their journey.
Rust is recommended for production apps due to its mature tooling and better performance. JavaScript is great for prototyping and learning.
Other LanguagesTheoretically, you can use any language that compiles to WebAssembly for developing NEAR smart contracts. However, to have a user-friendly experience, you need a library that wraps around low-level runtime APIs while offering high-level functionalities.We envision that in the future, more languages will be supported through community efforts.

Contract Primitives

Contract primitives such as FT (Fungible Tokens), NFT (Non-Fungible Tokens), and DAOs are fundamental building blocks that can be combined to create awesome user experiences such as reward tokens, decision-making tools, and marketplaces.

Learn About Primitives

Explore NEAR’s contract primitives and standards

Next Steps

Quickstart

Build your first smart contract in minutes

Contract Anatomy

Understand how smart contracts work

Testing

Learn how to test your contracts

Security

Best practices for secure contracts

Build docs developers (and LLMs) love