--- title: NEAR for Senior Developers tags: NSD --- # Intro to NEAR for Senior Developers ## The Map NEAR is a layer 1 smart contract platform (like Ethereum but [cheaper](https://docs.near.org/docs/concepts/gas#ballpark-comparisons-to-ethereum) and [faster](https://docs.near.org/docs/roles/integrator/exchange-integration#blocks-and-finality)) that scales by parallelizing [sharded storage and compute](https://docs.near.org/docs/concepts/architecture/papers). NEAR Protocol uses Proof of Stake consensus with [over 50 validators](https://explorer.near.org/nodes/validators) securing [millions of transactions and hundreds of thousands of accounts](https://explorer.near.org/stats) as of summer 2021. The platform exposes two surfaces for extension: - Smart contracts (currently written in [Rust](https://docs.near.org/docs/develop/contracts/rust/intro) or [AssemblyScript](https://docs.near.org/docs/develop/contracts/as/intro)) to encode business logic and provide access to on-chain storage - JSON over HTTP [RPC API](https://docs.near.org/docs/api/rpc) to communicate with the platform from the outside In terms of MVC application architecture, developers usually write applications that combine these two areas with one or more smart contracts acting as a secure, decentralized and trusted **M**odel + **C**ontroller and the RPC API acting as the glue to the **V**iew. Smart contracts are executed (conceptually like serverless functions) in a Wasm-compatible virtual machine with about a [`200ms` time-to-live](https://docs.near.org/docs/concepts/gas) corresponding to `200Tgas` upper bound. Inputs, outputs and contract state are all captured on chain. NEAR Protocol supports human-readable [accounts](https://nomicon.io/DataStructures/Account.html). These accounts sign and send [`Transactions`](https://docs.near.org/docs/concepts/transaction) to the network which are processed by validator nodes. "Signing" happens using public key cryptography where each account supports an unlimited number of keys (currently defined as one of two types: `FullAccess` and `FunctionCall`). The individual nodes of this decentralized network run on computers [operated by validators](https://docs.near.org/docs/validator/staking-overview) who agree to run a NEAR-compatible software package called "nearcore", a reference implementation of NEAR Protocol, and commit enough value in NEAR tokens to buy a "seat" at the table. As of summer 2021 the minimum stake required to hold a single validator seat on the network is [over $7M USD](https://near-staking.com). Network users can [delegate smaller amounts](https://docs.near.org/docs/validator/delegation) of tokens to support these validators in exchange for a portion of their reward. ## The Territory ### Developer Tools - Visual Studio Code (or CLion for nearcore devs), git and GitHub - [NEAR CLI](https://docs.near.org/docs/tools/near-cli) is used by developers and validators to interact with the platform from the command line - [`nearup`](https://github.com/near/nearup) is used to standup LocalNet or an archival node ### Extensions and Frameworks - [Aurora](https://aurora.dev) runs Ethereum contracts on NEAR with native ETH token - Sputnik DAO [contracts](https://github.com/near-daos/sputnik-dao-contract/tree/feat/enchance-contract-v2-readme/sputnikdao2) and [vision](https://medium.com/sputnikdao/sputnik-dao-empowering-communities-e55ac65f4433) provide a working implementation of the future of organized human activity - [NEAR Indexer Framework](https://docs.near.org/docs/tutorials/near-indexer) is used to monitor and capture network activity to create applications like [NEAR Explorer](https://explorer.near.org/) ### Core Documentation - [docs.near.org](https://docs.near.org/) -- NEAR Protocol documentation - [Rust SDK docs](http://github.com/near/sdk-docs) -- added context to the Rust SDK for ambitious devs - [nomicon.io](https://nomicon.io/) -- NEAR Protocol specification & standards (NFT, FT, etc) - [NEPs](https://github.com/near/NEPs) -- NEAR Enhancement Proposals for platform futures ### Contract Samples - [Core contracts](https://github.com/near/core-contracts) -- MainNet contracts managing hundreds of millions in assets - [NEAR Apps](http://github.com/near-apps) -- several production-quality demos with instructional video walkthroughs - [github.com / Learn-NEAR](https://github.com/Learn-NEAR) -- instructor samples and student projects from [NEAR Certified Developer program](https://hackmd.io/@nearly-learning/ncd) ### Video Content _Mostly Conceptual_ - [NEAR Blockchain Concepts](https://youtube.com/playlist?list=PL9tzQn_TEuFWJwvBg5V6EVa2DtYL_-2lJ) -- all major concepts of the platform - [Lunch and Learn Series](https://youtube.com/playlist?list=PL9tzQn_TEuFW_t9QDzlQJZpEQnhcZte2y) -- high level concepts like sharding and economics _Mostly Practical_ - [Live App Review](https://youtube.com/playlist?list=PL9tzQn_TEuFXnHlfh00etU57IjpRlQGpY) -- full stack applications using Rust contracts and React frontend - [Live Contract Review](https://youtube.com/playlist?list=PL9tzQn_TEuFXnYksuNJwrl1l_AuWzn6eF) -- line-by-line core contracts in Rust - [NEAR Core Overview](https://youtube.com/playlist?list=PL9tzQn_TEuFV4qlts0tVgndnytFs4QSYo) -- nearcore architecture and implementation - [NEAR Concepts](https://youtube.com/playlist?list=PL9tzQn_TEuFUmRVVjdD6XvCSN2xj9p51S) -- NEAR native contract development as well as Aurora EVM ### Other Educational Content - [NEAR 101](https://bit.ly/near-101): Intro to NEAR for web devs - [NEAR 102](https://bit.ly/near-102): Intro to NEAR for Ethereum devs - [NEAR 104](https://bit.ly/near-104): A Tour of NEAR Protocol - [NEAR cross-contract calls](http://bit.ly/near-xcc) - [Exploring AssemblyScript](http://bit.ly/near-sdk-as) Workshop - [Exploring NEAR Protocol APIs](https://bit.ly/near-apis) Workshop ## The People The NEAR community has more than a few moving parts. You can find them around here: - [core team members](http://near.org/team) - [Discord community](http://near.chat) - [Discourse forum](http://forum.near.org) - [Telegram community](https://t.me/joinchat/HfBpeBW52W6SaGNhfnpAbQ) - [Twitter](https://twitter.com/NEARProtocol) - [StackOverflow](https://stackoverflow.com/tags/nearprotocol) - [Github](https://github.com/nearprotocol) ## The Code ### Application Architecure Applications built on NEAR tend to follow a similar high level architecture. The app communicates with the network through the RPC API. If the app includes a JavaScript execution context (eg. React, Vue, etc) then `near-api-js` can be used to save development effort. Transactions are signed and sent to the network where they are processed and the outcome returned. ![](https://i.imgur.com/4g26LFu.png) The diagram below shows a round-trip call from frontend, through the RPC API, into the contract and back. Between steps 3 and 6 is a maximum of `200ms` of wall clock time for a single function call to finish execution. ![function call round trip](https://i.imgur.com/lzDfZkN.png) ### AssemblyScript vs Rust Contracts NEAR currently supports two contract language, AssemblyScript and Rust, with more on the way. ![](https://i.imgur.com/WcKdkFT.png) ![](https://i.imgur.com/JajWlJF.png) ![](https://i.imgur.com/kj2ckGM.png) ### Access Keys The diagram below shows the primary difference between these two key types which is in their ability to do something useful on the network where "something useful" here means to take some `Action`, one of 8 composable primitives relating to identity, money and code. One or more actions can be composed into a single transaction, signed and sent to the network for processing. ![access keys](https://i.imgur.com/Jw65roE.png) ### Storage ![state storage](https://i.imgur.com/1We1T4P.png) ### Comparing NEAR to Ethereum ![primitives](https://i.imgur.com/i2fcub6.png) ![features](https://i.imgur.com/OsLjyL6.png) ![deployment](https://i.imgur.com/CQXIGk8.png) ![transaction metadata](https://i.imgur.com/6nf3ZGv.png) ![transaction value](https://i.imgur.com/WqpdOgT.png) ![transaction data vs actions](https://i.imgur.com/Hg1sInQ.png) ![NEAR actions](https://i.imgur.com/Fopt9ne.png)