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. img Smart contracts in NEAR are written in Rust and then compiled into WebAssembly. They can then be deployed and executed on the NEAR platform.
Do not worry if you don’t know how smart contract blockchains work. As a developer, it is sufficient to 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 to NEAR accounts. Any NEAR account can hold a contract and must 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 (average finality of 1.2 seconds) and cheap. Read-only operations are free for everyone.
Storing 100 KB costs 1 Ⓝ, so deploying a contract generally costs only a few $NEARs.
Since protocol version 2.6, NEAR supports global contracts, which can be deployed to multiple accounts without paying for code storage each time.

What can they do?

Smart contracts have complete control over the account and can therefore perform any action on its behalf. For example, contracts can:
  • Transfer $NEAR tokens
  • Call methods on other contracts
  • Create new accounts and deploy contracts on them
  • Update their own code
In addition, 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 must be called by an external account

What are they used for?

Smart contracts are used to create decentralized applications. Common examples include: 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.

Smart Contract SDK

near-sdk-rs is NEAR’s only official smart-contract SDK. Use it to write contracts in Rust and compile them to WebAssembly. Start with the smart-contract quickstart, or see the Rust SDK guide for reference documentation.