jcarbonnell/preTrainingNEAR huggingface dataset:
---
id: reentrancy
title: Reentrancy Attacks
---

Between a cross-contract call and its callback **any method of your contract can be executed**. Not taking this into account is one of the main sources of exploits. It is so common that it has its own name: **reentrancy attacks**.

Always make sure to keep your state in a consistent state after a method finishes executing. Assume that:

- Any method could be executed between a method execution and its callback.
- The same method could be executed again before the callback kicks in.

---

### Example
Imagine that we develop a `deposit_and_stake` with the following **wrong logic**: (1) The user sends us money, (2) we add it to its balance, (3) we try to stake it in a validator, (4) if the staking fails, we remove the balance in the callback. Then, a user could schedule a call to withdraw between (2) and (4), and, if the staking failed, we would send money twice to the user.

![img](https://miro.medium.com/max/1400/1*VweWHQYGLBa70uceiWHLQA.png)
*Between a cross-contract call and the callback anything could happen*

Luckily for us the solution is rather simple. Instead of immediately adding the money to our user’s balance, we wait until the callback. There we check, and if the staking went well, then we add it to their balance.

![img](https://miro.medium.com/max/1400/1*o0YVDCp_7l-L3njJMGhU4w.png)
*Correct way to handle deposits in a cross-contract call*
---
id: tokens
title: Tokens
---

# NEAR Token
This is the native token used in NEAR Protocol.
It has multiple use cases:
- Secures the network through staking
- Provides a unit of account - NEAR is used for processing transactions and storing data
- Serves as a medium of exchange

### Securing the Network
NEAR Protocol is a proof-of-stake (PoS) network, which means that resistance from various attacks comes from staking NEAR.
Staked NEAR represents the decentralized infrastructure of servers that maintain the network and process transactions for applications and users on NEAR.
Rewards for providing this service are received in NEAR.

## Providing a Unit of Account
NEAR is used to price computation and storage on the NEAR infrastructure.
The network charges transaction fees in NEAR to process changes and transactions.

## Medium of Exchange
NEAR is readily available on the protocol level, so it can be used to transfer value between NEAR applications and accounts.
This means that applications can use NEAR to charge for various functions, like access to data or other complex transactions.
Entities can also easily exchange NEAR between each other, without the need for trusted third parties to clear and settle transactions.


For a deeper dive on NEAR Economics: [https://near.org/blog/near-protocol-economics](https://near.org/blog/near-protocol-economics)

For more information about the NEAR token, visit [NEAR Token Supply and Distribution](https://near.org/blog/near-token-supply-and-distribution/) or [Nomicon](https://nomicon.io).
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="nft-contract-tabs" className="file-tabs">
<TabItem value="NFT Primitive" label="Reference" default>

```bash
near call nft.primitives.near nft_mint '{"token_id": "1", "receiver_id": "bob.near", "token_metadata": {"title": "NFT Primitive Token", "description": "Awesome NFT Primitive Token", "media": "string"}}' --depositYocto 10000000000000000000000, --accountId bob.near
```

</TabItem>

<TabItem value="Paras" label="Paras">

```bash
near call x.paras.near nft_mint '{"token_series_id": "490641", "receiver_id": "bob.near"}' --depositYocto 10000000000000000000000 --accountId bob.near
```

:::note
In order to use `nft_mint` method of the `x.paras.near` contract you have to be a creator of a particular token series.
:::

</TabItem>

<TabItem value="Mintbase" label="Mintbase">

```bash
near call thomasettorreiv.mintbase1.near nft_batch_mint '{"num_to_mint": 1, "owner_id": "bob.near", "metadata": {}}' --accountId bob.near --depositYocto 10000000000000000000000
```

:::note
In order to use `nft_batch_mint` method of Mintbase store contract your account have to be a in the contract minters list.
:::

</TabItem>

</Tabs>
Near at ETHDenver Hackathon Bounty Winners
NEAR FOUNDATION
March 13, 2023
For the 2023 edition of ETHDenver, the Near ecosystem offered a number of bounties across a range of Web3 verticals, including DeFi, Content, Search, Social Media, Interoperability, Smart Contract History, and more. There were 3 main prize pools from Aurora, Proximity, and Developer Governance (DevGov). 

Congratulations to all Near winners. who received over 30k in USDC! Let’s have a look at the winning projects of the Near at ETHDenver bounties. 

Aurora Bounty Winners
Open Aurora Bounty
Winner – StakingPool Aurora

Implements a liquid staking protocol around Aurora Plus staking. Users will deposit AURORA and receive a share in $stAUR tokens, which distributes the APY rewards. $stAUR could be immediately converted with a fee or wait for a delayed unstake.

Runner Up – Geni

AI-powered specifications generator of security tests for smart contracts.

Runner Up – Demeter

A lending platform that offers yield advancements, i.e., self-paying loans. Borrowers’ collateral is invested in RWA protocols, and the yield pays off debt.

Proximity Bounty Winners
Deploy a Decentralized Frontend Component
Winner – BosWrap 

BosWrap used the Near Blockchain Operating System to build a decentralized widget for wrapping/unwrapping ETH.

Runner Up – ABI BOS Widget 

A solidity explorer widget that allow users to explore any smart contract for a given ABI. You can get ABI from Etherscan website.

Runner Up – Bossed Up

A project focusing on Ethereum frontends, Blockchain Operating System improvements, and NEAR Social widgets that interact with NEAR contracts.

Runner Up – Atmosph3re

A dApp for reducing the homeless crisis in the United States by giving those living on the streets a decentralized identity, mentoring and community support, and funds for spending on their basic needs to help them thrive. 

Runner Up – EthDenver2023UWCA

A dApp on NeaR’s new frontend with BOS.GG. Integrates with Rocketpool to offer quick swaps on Ethereum.

DevGov Bounty Winners
Extensive Developer Profile Widget
Winner – Developer Profile

A recreation of Github profile for NEAR social developers in the Blockchain Operating System. 

Fuzzy Search Widget / Promoted Posts Banner Widget / Top Posts Widget  / Post History with Diff Widget
Winner – Near.Social DevGovGigs Improvements 

A new Developer Governance Gigs interaction experience for Near.Social. Features: 1) Fuzzy Searching that can handle typos, 2) Promote posts and Promoted Post viewer, 3) Hottest Posts viewer, and 4), Post editing history viewer.

Near.Social Bots Coded in Javascript
Winner – JS Bot Widget

Verifiable RPC Replies
Winner – Near Verifiable RPC Endpoints for Viewing Access Keys

Adds proof generation support to RPC read access key endpoints on the NEAR protocol to help pave the road for light client support.
USDC Launches Natively on the NEAR Protocol
NEAR FOUNDATION
September 14, 2023
USDC, the open-source, permissionless protocol and stablecoin that enables any app to send and store digital dollars, is now native on the NEAR blockchain. 

The announcement opens the door for businesses built on NEAR to easily withdraw NEAR USDC and send it on-chain in seconds. Users can also swap USDC natively from Ethereum to NEAR and back — without incurring costs or delays from third-party bridges. MyNearWallet, Ledger, and wallet.near.org have all confirmed support allowing a user to hold USDC and interact with dapps on the B.O.S. Other wallets will follow over the coming days.

Before this, USDC was only available on NEAR as a bridged form of USDC, known as USDC.e from Ethereum. This announcement means users get all the benefits of a native stablecoin, empowering developers to integrate stablecoin payments flows into their Javascript and  Rust-based decentralized applications. 

This will unlock a new wave of accessibility for Web2 builders moving into Web3. It will also serve a vital role in NEAR’s mission of Web3 mass adoption, while helping developers build without limits on an open web.

Native versus Bridged
Circle brings USDC natively to new blockchain networks to empower developers to build on a stable foundation they can trust. Native USDC is officially issued by Circle and is always redeemable 1:1 for US dollars.

In the case of NEAR, historically USDC was only available as a bridged version of USDC from Ethereum. USDC.e is not issued by Circle and is not compatible with Circle Account or Circle APIs. This brings a NEAR native version of USDC on chain. 

To facilitate this shift, the NEAR Foundation will be working with ecosystem partners to help facilitate the migration of liquidity from bridged USDC to native USDC.

Exchanges, digital wallets, institutional traders, and developers can now all access NEAR USDC via the Circle Account and Circle APIs. This unlocks a whole range of use cases including:  

Making low cost payments and remittances globally in seconds.
24/7 trading, borrowing, and lending on apps like Burrow, Orderly, and Ref Finance.
Enable users to hold savings in digital dollars without needing a traditional bank account. 
Allow for enhanced cross-chain interoperability with other blockchains via NEAR’s extensive range of bridges. 
In the DeFi realm, Ref Finance will also launch its stable 4-pool on September 14 onwards. Trisolaris, Burrow, Orderly, VEAX and others are all planning on bringing USDC to its platforms within the coming weeks.

USDC.e will still be supported by the ecosystem during the transition.

Getting started with USDC 
If you’re a business or project working on NEAR, you can readily access on/off-ramps for converting fiat currency to NEAR USDC by applying for a Circle Account.

If you’re new to NEAR, you can find free resources for building apps, deploying smart contracts, creating B.O.S components, and more on the DevRel resources page. 

For developers looking for documentation on building with USDC, check out Circle’s developer docs.
NEAR Foundation’s Response to the SEC’s Recent Coinbase Complaint
NEAR FOUNDATION
June 6, 2023
We are aware of the news that the most recent SEC complaint against Coinbase, published today, alleges the NEAR token (along with many other crypto assets) is a crypto asset that is being offered and sold as an investment contract, and thus as a security (see the full complaint here). 

This SEC enforcement action is not against the NEAR Foundation (the “Foundation”) (or any other participant in the NEAR ecosystem). In any event, the Foundation disagrees with (and is surprised by) the inclusion of the NEAR token in the complaint, and we believe the Foundation has not violated any applicable US securities laws. 

The Foundation is regulated in Switzerland and the NEAR token has been characterized as a payment token (and not as a security) under Swiss law.

Over the last few months, given the increased regulatory scrutiny and hostility in the US, we have continued to strengthen our team and surround ourselves with the best advisors in the industry, and we will continue to do so. 

Keeping our ecosystem safe has always been – and will remain – at the forefront of what we do. 

We understand this might feel unsettling, however we are concerned but confident and the Foundation leadership and legal team are prepared for this development. 

The best thing we can all be doing is to continue focusing on building great products, bringing delightful user experiences, and onboarding millions into web3. In other words, business as usual.
ICC Launches ‘Captain’s Call’ Game on NEAR to Level Up Cricket Fandom During World Cup
NEAR FOUNDATION
October 26, 2023
Cricket fans are getting a Web3-powered path to engaging with their favorite international sport. NEAR Foundation and the  International Cricket Council (ICC), the global governing body of cricket, just teamed up  to explore different ways of getting fans closer to their favorite teams and players. 

This ICC and NEAR partnership arrives just as the cricket world is watching the Men’s Cricket World Cup 2023. The partnership’s first cricket fan experience, the Captain’s Call gaming app, taps into the NEAR Protocol’s infinite scalability. 

Watch an animated primer below on the gameplay in Captain’s Call.

Level up cricket fandom with Captain’s Call game
In Captain’s Call, ICC’s first app on the NEAR blockchain, cricket fans compete against each other for the chance of winning prizes. Developed by Wincast, Captain’s Call allows fans to strategize around bowling, batting, and fielding actions during live cricket matches.

To play, fans simply navigate to the ICC’s mobile apps or website, click on the Match Centre for the game they intend to watch, and submit their predictions before the match begins. Players then compete for a chance to win prizes, merchandise, and more. 

Beyond Captain’s Call
With NEAR and ICC, Web3 and and sports are on a path of continual innovation. A fan passport is currently in early discussions, which would enable fans to record their actions and memories in a tamper proof way, both on and off chain. Captain’s Call will serve as a template in creating other games that fuses other Web2 and Web3 worlds. 

All of these sporting innovations are possible thanks to the Blockchain Operating System (B.O.S). With its full stack of Web3 tools and easy onboarding, partners like the ICC and others can take advantage of the world’s most highly scalable, community-driven, and secure blockchains that deliver proven, best-in-class performance that can support any kind of Web3 strategy.
Update on the NEAR Wallet Transition
COMMUNITY
August 16, 2022
On July 29th, NEAR Foundation announced that wallet.nearpages.wpengine.com would be transforming into a new multi-wallet portal, and that the NEAR Wallet team is spinning out to become its own entity. This is part of the NEAR Foundation’s continued mission to foster a rich and vibrant ecosystem that can build and maintain its core components. 

Originally, the plan was to begin transitioning wallet.nearpages.wpengine.com into the multi-wallet portal starting August 17th. But, based on community feedback following the July 29th wallet.nearpages.wpengine.com transition announcement, the MyNearWallet team, Pagoda, and NEAR Foundation realized a rethink was needed to ensure the smoothest user experience possible. 

This transition is incredibly important for the NEAR ecosystem and community, allowing NEAR to further decentralize, enhance security, and ultimately give users more wallet options. 

With that in mind, Pagoda will be gathering feedback from the community over the next few months and deciding on a more appropriate path forward. The Foundation believes this is the right move for the NEAR ecosystem. 

There will be no changes on the wallet.nearpages.wpengine.com front until that point. As things progress, the NEAR Foundation will keep you, the NEAR community, in the loop with any and all future announcements related to the wallet transition process. 

Stay tuned for more updates on the transition. 

Other Wallet Options in the NEAR Ecosystem? 
Again, if you’re interested in exploring the other wallets available in the NEAR ecosystem, there are plenty to check out. Over 30 wallet providers are currently compatible with NEAR. 

Visit AwesomeNEAR for a list of wallets compatible with the NEAR ecosystem.
Fireblocks Provides Custody Facility for Institutional Investors on NEAR
COMMUNITY
July 26, 2022
NEAR Foundation is excited to announce a new partnership with Fireblocks, a leading provider of custody and settlement solutions for digital assets. Fireblocks is trusted by more than 1,300 banks, hedge funds, and financial institutions, and to date has ensured the safe transfer of more than $3 trillion. 

The Fireblocks integration with NEAR will allow institutional users to now access the NEAR Protocol’s fast and low-cost sharded proof-of-stake blockchain safely and securely. 

This means clients BNY Mellon, Credit Suisse, and other Tier 1 institutions can utilize Fireblocks’ class-leading custody solutions to access the NEAR ecosystem like never before.

“The institutional appetite for accessing DeFi across major blockchain ecosystems is only going to grow,” said Michael Shaulov, CEO of Fireblocks. “The newly launched integration with NEAR on Fireblocks will enable us to continue expanding the network of blockchains, DeFi and Web3 apps that institutional customers can  participate in. We look forward to continuing leading the way as the most secure platform for building crypto products and accessing global crypto capital markets.”     

Fireblocks on the NEAR ecosystem
Over the last few months, NEAR Foundation has identified that a healthy ecosystem should be made up of different communities. NEAR Foundation’s partnership with Fireblocks is a major step in helping institutional community members take part in the NEAR ecosystem. 

Fireblocks’ close relationships with banks, hedge funds, VC firms, and other financial institutions will allow these users to access a broad range of products being built on NEAR. 

Soon, Fireblock’s 1,000+ enterprise partners will be able to access Aurora, Ref.Finance, Octopus Network, and other decentralized apps being built on the platform. 

“A core mission for NEAR is building an ecosystem of diverse communities,” says NEAR Foundation CEO Marieke Flament. “With the Fireblocks partnership, NEAR can now welcome to the NEAR ecosystem the many financial institutions that have turned to Fireblocks as their trusted provider for digital assets custody and settlement solutions.”

About Fireblocks
Fireblocks is a leading enterprise-grade platform delivering a secure infrastructure for moving, storing, and issuing digital assets. Fireblocks enables banks, fintechs, exchanges, liquidity providers, OTCs, and hedge funds to securely manage digital assets across a wide range of products and services. The technology consists of the Fireblocks Network and MPC-based Wallet Infrastructure. Fireblocks serves over 1,000 financial institutions and has secured over $2 trillion in digital assets. Fireblocks has a unique insurance policy that covers assets in storage & transit and offers 24/7 global support.
# StorageUsageConfig

Describes cost of storage per block

## account_cost

_type: Gas_
Base storage usage for an account

## data_record_cost

_type: Gas_
Base cost for a k/v record

## key_cost_per_byte:

_type: Gas_
Cost per byte of key

## value_cost_per_byte: Gas

_type: Gas_
Cost per byte of value

## code_cost_per_byte: Gas

_type: Gas_
Cost per byte of contract code
---
id: bos-gateway
title: Using components on WebApps
---

In order to use the components you create in a WebApp you need to use what is known as the `NEAR VM`. This virtual machine helps you to easily fetch components from the blockchain and transform them into executable code.

There are two possible scenarios:
- You want to start a WebApp [**from scratch**](#starting-a-webapp-from-scratch).
- You want to integrate components into an [**existing WebApp**](#integrating-components-into-your-webapp)

---

## Starting a WebApp from scratch

If you want to start a WebApp from scratch, the simplest option is to use `create-near-app`. To use it, you only need to have [node.js](https://nodejs.org/en/) installed on your computer.

Simply run the following command and follow the instructions:

```bash
npx create-near-app@latest
```

:::tip Tutorial
To learn more about the template created by `create-near-app` see our [Quickstart a WebApp](../../2.build/4.web3-apps/quickstart.md) tutorial.
:::

---

## Integrating Components into your WebApp

In order to integrate components into your WebApp you will leverage two libraries:
- **Wallet Selector**: Allows user to login using their preferred NEAR wallet.
- **NEAR VM**: Simplifies fetching NEAR components from the blockchain and rendering them.

The best way to learn how to integrate components into your WebApp is by following our tutorial:

:::tip Tutorial
To learn step-by-step how to integrate them, please visit our [integrating components into a WebApp](../../2.build/4.web3-apps/integrate-components.md) tutorial.
:::
---
title: Building On NEAR
description: A quick quide to building projects on NEAR.
sidebar_position: 0
---

# Building on near

:::info on this page
* The guide is for those interested in building projects on NEAR, and provides tools and resources for a better experience.
* Essential tools include the NEAR wallet, block explorer, and command-line interface (CLI), while AwesomeNEAR provides project inspiration.
* Educational resources are available for both technical and non-technical builders, and can be found on the learning resources page.
:::

Welcome to the building overview!

This is a guide for project managers, founders, software developers, or anybody else interested in building projects on NEAR.
It contains tools and resources that can improve your experience building projects on NEAR.

## Tools

There are a wide variety of tools available to help you develop your project.
You can start by looking at our [essential tools](overview/essential-tools.md), the NEAR wallet, the block explorer, and the command-line interface(CLI).
These tools allow you to interface the NEAR protocol in different ways, the NEAR wallet makes it easy to store your NEAR and interact with the NEAR network with a convenient graphical user interface.
The block explorer allows you to see what's happening on the NEAR network on a larger scale, including what transactions are happening, statistics about nodes and blocks, and a historical look at the NEAR network.

For project inspiration, have a look at [AwesomeNEAR](https://awesomenear.com/), which has a large and growing directory of projects built on NEAR.
This can help you understand what projects already exist, and help you determine what you should include in your project.
For developers looking to dive right into a project, have a look at our [documentation](https://docs.near.org) for information about how to build your project.

## Learning About Building on NEAR

Once you have the essential tools to interact with the NEAR network, you can use our educational resources to learn more about NEAR.

We have a wide variety of resources for builders in both technical and non-technical roles, and are always adding more. You can find out what's available by on our [learning resources](tech-resources.md) page.
---
sidebar_position: 1
title: "Public Methods"
---

# Public Method Types

Methods can be called externally by using the `view({})` or `call({})` decorators within the contract class which will expose the method in the compiled WASM bytecode to be called by any other NEAR Account. Whenever a method is declared in your contract class without these decorators and is called by another NEAR Account, a `MethodNotFound` error will be thrown.

:::tip

If you need a contract to call itself, you can mark the function with these decorators but add the [`({  privateFunction: true })` annotation in the decorator parameters](private-methods.md) so that it will panic if called from anything but the contract itself.

:::

A basic usage of this would look like the following:

```js
@NearBindgen({})
export class MyContractStructure {
    @call({}) // or @view({})
    some_method({ parameter_a, parameter_b }) {
        // .. method logic here
    }
}
```

:::note `snake_case` vs `camelCase`
We recommend using `snake_case` for method names, contrary to the `camelCase` convention in JavaScript. This is because the method names for a majority of contracts in the NEAR ecosystem use `snake_case`, and it is easier to use the same convention for all contracts.
:::

Where this would expose `some_method` from the WASM binary and allow it to be called externally.

<!-- TODO: insert detail overview -->