jcarbonnell/preTrainingNEAR huggingface dataset:
NEAR at ETHCC: Horizon Pitch Contest, BOS Workshops, and More
COMMUNITY
July 16, 2023
As Day One at NEAR @ ETHCC concludes, there’s palpable growing excitement for what’s in store for tomorrow. Held at the beautiful Museum National D’Histoire Naturelle in Paris, the first day of workshops and sessions proved to be an exceptional success for Ethereum and BOS builders. 

Day Two is gearing up to take the experience to a whole new level, with a primary focus on founders and their ventures.

Morning and Early Afternoon Sessions: Fostering Innovation
Day Two will kick off with a casual networking opportunity over café au laits and pastries. It’ll be a great way to get warmed up and connect builders, innovators, and visionaries within the NEAR ecosystem.

The first main event of the day will be a special workshop held  by Matt Stephenson , Head of Cryptoeconomics at Pantera Capita, along with Pantera Principal, Ryan Barney. His insights on the opportunities and challenges within blockchain economics will deepen participants’ understanding of the critical economic principles underpinning blockchain ecosystems.

As the morning sessions conclude, the afternoon will kick off by delving into the world of interoperability, onboarding, and value generation with Vik Pandey from NEAR Foundation. Vik has been actively involved in the development of the BOS, focusing on interoperability, open-source technologies, and blockchain success efforts. 

During his session, “Interoperability, Onboarding, and Value Generation with the BOS,” Vik will share insights from his work, highlighting the ways in which the BOS fosters innovation and impact in the Open Web.

Late Afternoon Highlights: Regulatory Discussions and Horizon Workshop
Next on the agenda is a panel of experts moderated by Mya Shofany, regulatory lead at NEAR Foundation. The discussion will delve into regulatory considerations in blockchain, and tackle some of the most critical issues facing Web3  founders in the current regulatory landscape.

The panel will be followed by one of the day’s most anticipated events — the Horizon afternoon. This session will be a deep dive into the cutting-edge ideas poised to redefine the blockchain world, spearheaded by NEAR’s new Web3 accelerator arm.

As Day Two winds down, participants can enjoy relaxed networking during the Horizon Happy Hour. Here, NEAR and Ethereum enthusiasts can reflect on the day’s learnings, forge new connections, and unwind over drinks and appetizers.

If you would like to browse the official schedule, head to near.org.ethcc 

Throughout the two days of NEAR @ ETHCC, participants are not just learning about the Blockchain Operating System (BOS), they’re experiencing it firsthand. Day Two promises a packed schedule of learning, building, and networking opportunities.

For those who couldn’t join us on Day One, you can catch up on the sessions uploaded on the NEAR Protocol YouTube channel. Prepare for Day Two by soaking up the insights shared by our experts.

Stay connected with us for more updates and insights from NEAR @ ETHCC as we continue to explore the limitless possibilities of the Blockchain Operating System (BOS).
NEAR Teams With Google Cloud to Accelerate Web3 Startups
DEVELOPERS
October 4, 2022
NEAR Foundation is excited to announce a new partnership between Google Cloud and NEAR Protocol. Going forward, Google Cloud will provide technical support for NEAR grant recipients. Open and developer-friendly, Google Cloud will support devs as they build and scale their Web3 projects and dApps.

If you’re developing on NEAR, this is great news—the partnership will supercharge blockchain innovations. Developers will even more easily create without limits as they build dApps and help onboard the masses into Web3. 

“We are thrilled to be collaborating with those who pioneered the Internet as we know it,” says Marieke Flament, CEO of the NEAR Foundation. “This partnership marks a new chapter for us as we continue to offer the best support possible for the next generation of visionaries choosing to build on the NEAR protocol.”

Powering NEAR developers with Google Cloud
In the last year, NEAR has grown exponentially thanks to its super-fast, incredibly secure, and infinitely scalable protocol. There are now over 20 million accounts, 200 million transactions to date, and 300,000 to 400,000 transactions per day on the NEAR network. Building upon the momentum of NEARCON 2022, which showcased the NEAR ecosystem’s vibrancy, 800 projects are now building on the protocol. 

How will the hundreds of projects currently building on NEAR benefit from the Google Cloud partnership? 

Google Cloud provides the infrastructure for NEAR’s Remote Procedure Call (RPC) node provider to Pagoda, NEAR’s Web3 startup platform. This allows developers to deploy code quickly, securely, and seamlessly. Pagoda helps developers easily and rapidly launch dApps on NEAR through a library of pre-audited templates and auto-generated contract user interfaces.

 “We will be supporting NEAR and giving Web3 developers the most secure, reliable, and sustainable cloud infrastructure on which they can build and scale,” Carlos Arena, Director of Digital Assets at Google Cloud. “We continue to support tomorrow’s leaders in creating new products and services on blockchain-based platforms.”

For more information on how Google Cloud is working to support Web3 innovation, check out Google Cloud’s Digital Assets blog.
---
id: welcome
title: Security
---

Here you will find information on how to keep your smart contract and decentralized applications secure.

:::tip
Please take some time to go through this section, it will help you to keep your dApp safe
:::

---

## 🐞 Bug Bounty Program
NEAR has a [revamped bug bounty program](./bounty.md), use it if you find any security errors in the protocol or mainstream apps.

## ✅ Security Checklist
Make sure to keep your smart contract safe by running through our [security checklist](checklist.md).

## 🛡️ Security Concepts
Learn important security concepts to keep your dApp safe and sound.  Read about:

- Keeping [callbacks safe](./callbacks.md).
- Understanding [frontrunning](./frontrunning.md).
- Understanding [sybil attacks](./sybil.md).
- Understanding [reentrancy attacks](./reentrancy.md).
- Making sure the owner of an account is [the one calling](./one_yocto.md).
- Understanding the complexity of [generating random numbers](./random.md).
- Protecting from a [small deposit attacks](./storage.md) draining your account.
---
sidebar_position: 2
title: Sending Native Tokens
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Sending $NEAR

You might want to send tokens from a contract for many reasons.

- The contract uses something like the [Storage Standard](https://nomicon.io/Standards/StorageManagement) and needs to return deposits to users when they unregister.
- Users pay into the contract and the contract later pays these fees to the maintainers, redistributes them to users, or disburses them to some cause the users vote on.
- And more!

Blockchains give us programmable money, and the ability for a smart contract to send tokens lies at the heart of that ability.

NEAR makes this easy. Transferring NEAR tokens is the simplest transaction you can send from a smart contract. Here's all you need:

```js
let amount = BigInt(1_000_000_000_000_000_000_000_000); // 1 $NEAR as yoctoNEAR
let to = "alice.near";

NearPromise.new(to).transfer(amount);
```

In the context of a full contract and function call, this could look like:

```js
import { NearPromise, NearBindgen } from "near-sdk-js";

@NearBindgen({})
export class Contract {
  pay({ amount, to }) {
    return NearPromise.new(to).transfer(amount);
  }
}
```

Most of this is boilerplate you're probably familiar with by now – imports, setting up [`NearBindgen`](../contract-structure/near-bindgen.md), etc. Some interesting details related to the transfer itself:

- The `pay` method defined here accepts JSON as input, and numbers in JS [cannot be larger than `2^53-1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER), so for compatibility with deserializing JSON to JS, the integer is serialized as a string. Since the `transfer` method takes a value in [yocto](https://en.wikipedia.org/wiki/Yocto-)NEAR, it's likely to need numbers much larger than `2^53-1`.

- Returning the `NearPromise`: This allows NEAR Explorer, near-cli, near-api-js, and other tooling to correctly determine if a whole chain of transactions is successful. If your function does not return `Promise`, tools like near-cli will return immediately after your function call. And then even if the `transfer` fails, your function call will be considered successful.

Using near-cli or near-cli-rs, someone could invoke this function with a call like:

<Tabs className="language-tabs" groupId="code-tabs">
  <TabItem value="near-cli">

  ```bash
  near call <contract> pay '{"amount": "1000000000000000000000000", "to": "example.near"}' --accountId benjiman.near
  ```

  </TabItem>
  <TabItem value="near-cli-rs">

  ```bash
  near contract call-function as-transaction <contract> pay json-args '{"amount": "1000000000000000000000000", "to": "example.near"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as benjiman.near network-config testnet sign-with-keychain send
  ```

  </TabItem>
</Tabs>
```rust
// Validator interface, for cross-contract calls
#[ext_contract(ext_nft_contract)]
trait ExternalNftContract {
  fn nft_token(&self, token_id: TokenId) -> Promise;
}

// Implement the contract structure
#[near_bindgen]
impl Contract {
  pub fn nft_token(&self, token_id: TokenId) -> Promise {
    let promise = ext_nft_contract::ext(self.nft_contract.clone())
      .nft_token(token_id);

    return promise.then( // Create a promise to callback query_greeting_callback
      Self::ext(env::current_account_id())
      .nft_token_callback()
    )
  }

  #[private] // Public - but only callable by env::current_account_id()
  pub fn nft_token_callback(&self, #[callback_result] call_result: Result<Token, PromiseError>) -> Option<Token> {
    // Check if the promise succeeded
    if call_result.is_err() {
      log!("There was an error contacting NFT contract");
      return None;
    }

    // Return the token data
    let token_data: Token = call_result.unwrap();
    return Some(token_data);
  }
}
```
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="nft-contract-tabs" className="file-tabs">
<TabItem value="Paras" label="Paras">

```js
import { Wallet } from './near-wallet';

const CONTRACT_ADDRESS = "marketplace.paras.near";
const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS });
 
await wallet.callMethod({
  method: 'storage_deposit',
  args: {
    receiver_id: "bob.near"
  },
  contractId: CONTRACT_ADDRESS,
  gas: 300000000000000, // attached GAS (optional)
  deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional)
});

await wallet.callMethod({
  method: 'nft_approve',
  args: {
    token_id: "1e95238d266e5497d735eb30",
    account_id: "marketplace.paras.near",
    msg: {
      price: "200000000000000000000000",
      market_type: "sale",
      ft_token_id: "near"
    }
  },
  contractId: "nft.primitives.near"
});
```

_The `Wallet` object comes from our [quickstart template](https://github.com/near-examples/hello-near-examples/blob/main/frontend/near-wallet.js)_ 

Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `marketplace.paras.near` as a callback.

</TabItem>

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

```js
import { Wallet } from './near-wallet';

const CONTRACT_ADDRESS = "simple.market.mintbase1.near";
const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS });
 
await wallet.callMethod({
  method: 'deposit_storage',
  args: {
      autotransfer: true
    },
  contractId: CONTRACT_ADDRESS,
  gas: 300000000000000, // attached GAS (optional)
  deposit: 9390000000000000000 // attached deposit in yoctoNEAR (optional)
});

await wallet.callMethod({
  method: 'nft_approve',
  args: {
    args: {
      token_id: "3c46b76cbd48e65f2fc88473",
      account_id: "simple.market.mintbase1.near",
      msg: {
        price: "200000000000000000000000"
      }
    },
  },
  contractId: "nft.primitives.near"
});
```

_The `Wallet` object comes from our [quickstart template](https://github.com/near-examples/hello-near-examples/blob/main/frontend/near-wallet.js)_ 

Method `nft_approve` of a NFT contract also calls the `nft_on_approve` method in `simple.market.mintbase1.near` as a callback.

:::tip

Check how to also do this using the [`Mintbase JS`](https://docs.mintbase.xyz/dev/mintbase-sdk-ref/sdk/list)

:::

</TabItem>

</Tabs>
---
id: minting-nft-frontend
title: Minting NFT Front-end
sidebar_label: Minting Front-end
---
import {Github} from "@site/src/components/codetabs"

# NFT Minting Front-end

> In this tutorial you'll learn how to create a simple NFT front-end and mint a "Go Team" NFT on the NEAR blockchain straight from your web browser.

## App Overview

The app is fairly simple: the user signs in and hits the <kbd>Mint NFT</kbd> button. Once the user hits the mint button, a "Go Team" NFT is minted and sent to their NEAR Wallet.

![Front-end](/docs/assets/nfts/nft-mint-frontend.png)

## Smart Contract code

The code for the NFT smart contract can be found in the [Zero to Hero NFT tutorial](/tutorials/nfts/introduction)'s  [GitHub repository](https://github.com/near-examples/nft-tutorial/tree/main/nft-contract/src), under the `main` branch.

The contract methods used in this application are as follows:

- `nft_mint`: Function used to mint tokens.
- `check_token`: Custom function created to check for the existence of a token. This helps to ensure one token per user.

## Front-end

The front-end of the contract was implemented using `create-near-app`. [React Bootstrap](https://react-bootstrap.github.io/) was used for the styling of the application.

To bootstrap your React front-end, run the following command on your terminal:

```sh
npx create-near-app --frontend react --contract rust
```

Then, simply import the contract files from the `main` branch, and you'll have the needed structure to run the application.

### Start

Upon mounting the application's components, the app checks for the existence of a non-fungible token.

<Github language="js" start="24" end="46" url="https://github.com/near-examples/nft-tutorial-frontend/blob/master/src/App.js" />

If no prior NFT has been minted, the mint button will be available for use.

### Mint button

Here is the function behind the mint button. The meta data has been filled out for the user already:

- `token_id` is set by the user's account id,
- and the `media` link is hard-coded to a `goteam-gif.gif` hosted on IPFS.

<Github language="js" start="7" end="23" url="https://github.com/near-examples/nft-tutorial-frontend/blob/master/src/Components/MintingTool.js" />

After hitting the <kbd>Mint NFT</kbd> button the user will be able to check out the newly minted NFT at [wallet.testnet.near.org](https://testnet.mynearwallet.com//?tab=collectibles), under the Wallet's `Collectibles` tab.

## Final remarks

You can find the complete application repository [on GitHub](https://github.com/near-examples/nft-tutorial-frontend) to clone and run.
In the configuration folder you can see that this smart contract has been deployed to `nft-frontend-simple-mint.blockhead.testnet`:

<Github language="js" start="1" end="2" url="https://github.com/near-examples/nft-tutorial-frontend/blob/master/src/config.js" />

You can also check out the [explorer link here](https://testnet.nearblocks.io/address/nft-frontend-simple-mint.blockhead.testnet) to see how many individuals have been minting their own _Go Team_ NFTs. _**Happy Minting!**_

:::tip
Clone and run this example from https://github.com/near-examples/nft-tutorial-frontend
:::
```js
const keypomContract = "v2.keypom.near";
const ftContract = "ft.primitives.near";
const dropAmount = "10000000000000000000000";

Near.call([
  {
    contractName: keypomContract,
    methodName: "create_drop",
    args: {
      public_keys: state.publicKeys,
      deposit_per_use: dropAmount,
      ftData: {
	    	contractId: ftContract,
	    	senderId: accountId,
	    	// This balance per use is balance of human readable FTs per use. 
	    	amount: "1"
        // Alternatively, you could use absoluteAmount, which is dependant on the decimals value of the FT
        // ex. if decimals of an ft = 8, then 1 FT token would be absoluteAmount = 100000000
	    },
    },
    deposit: "23000000000000000000000", // state.publicKeys.length * dropAmount + 3000000000000000000000,
    gas: "100000000000000"
  },
]);
```
```js
const accountId = context.accountId ?? props.accountId;
const keypomContract = "v2.keypom.near";
const nftContract = "nft.primitives.near";
const dropAmount = "10000000000000000000000";

 Near.call([
  {
    contractName: keypomContract,
    methodName: "create_drop",
    args: {
      public_keys: state.publicKeys,
      deposit_per_use: dropAmount,
      nft: {
        // Who will be sending the NFTs to the Keypom contract
        sender_id: accountId,
        // NFT Contract Id that the tokens will come from
        contract_id: nftContract,
      },
    },
    deposit: "23000000000000000000000" // state.publicKeys.length * dropAmount + 3000000000000000000000,
    gas: "100000000000000",
  },
]);
```
---
id: introduction
title: Introduction
---

While developing your smart contract you will want to test that it works as it is supposed to, and moreover, does so securely. In NEAR we have developed tools to help you carry out such tests. Basically, there are two types of tests you can perform:

1. **Unit Tests** to test methods individually. They are written in the contract's language and are executed locally.
2. **Integration Tests** to test how your contract behaves in a realistic environment. You can write them in Rust or Typescript, and execute in a local Sandbox or the NEAR testnet.

We recommend all developers to implement both types of tests, since each is suitable to detect different types of errors and make your code intentional. Furthermore, we strongly recommend to first release all projects on testnet, and give users time to try them before releasing them on mainnet.

---
## Setting Up Testing
Testing a smart contract involves using different pieces of software depending on which type of test you are performing. In order to save you from the trouble of setting them up, we recommend you copy the structure from one of our [example projects](https://github.com/near-examples).
NEAR Enhances Decentralization with Validator Upgrade
DEVELOPERS
January 7, 2022
Since the NEAR Mainnet launch in October 2020, the network has seen a steady increase in the number of validators, with many more wanting to participate. Nevertheless, the extremely high threshold of 3.6M $NEAR has made it challenging for new validators to join the network. So much so, the NEAR Foundation has, at times, supported validators with substantial delegations in order to allow for some of the 60 validators to remain active on Mainnet.

That is why, in December 2021, the NEAR Protocol team released the updated validator selection algorithm. The new selection algorithm now allows for up to 100 validator nodes on the Mainnet, and reduces the validators’ barrier to entry by bringing down the seat price from 3.6 million $NEAR to 67,000. This lowered seat price makes it easier for them to join the active validator set and to maintain their seats. 

Additionally, the NEAR Foundation aims to limit delegation amounts to a maximum of 100,000 NEAR per validator, as part of its continuous commitment to building a fully decentralized network. 

NEAR Delegation Role 
Historically, the NEAR Foundation has used delegation to bootstrap network decentralization by helping new validators enter the active set and build their following but it wasn’t intended to be a long term grant. Current validators on NEAR Mainnet who had received historical delegation from NEAR Foundation should expect to see current delegations from NEAR Foundation to be withdrawn in the next 48 hours as part of this change.

This will be followed by the NEAR Foundation delegating up to 100,000 NEAR to validators who had been selected to receive delegation by submitting their delegation application up to December 13, 2021. This new wave of delegation will take place during the coming weeks.

This change is only the beginning of a number of ecosystem-wide initiatives that will continue increasing the number of validators and improving network decentralization. With the upcoming launch of phase 1 of sharding in early 2022, we expect another 200 validators to join Mainnet. 

NEAR has always been, and will always be committed to building a secure, scalable, and decentralized network to help onboard the world into Web3. To take advantage of the upcoming expansion, there are other opportunities for NEAR Foundation delegation, including participating in the validator governance progress. 

Please consider joining the NEAR Validator governance process by participating in the NEAR Validator Advisory Board general election in early 2022. Stay tuned for more announcements.
```js
import { Wallet } from './near-wallet';

const TOKEN_CONTRACT_ADDRESS = "token.v2.ref-finance.near";
const wallet = new Wallet({ createAccessKeyFor: TOKEN_CONTRACT_ADDRESS });
 
await wallet.viewMethod({
  method: 'ft_metadata',
  args: {},
  contractId: TOKEN_CONTRACT_ADDRESS
});
```

<details>
<summary>Example response</summary>
<p>

```json
{
  "spec": "ft-1.0.0",
  "name": "Ref Finance Token",
  "symbol": "REF",
  "icon": "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='16 24 248 248' style='background: %23000'%3E%3Cpath d='M164,164v52h52Zm-45-45,20.4,20.4,20.6-20.6V81H119Zm0,18.39V216h41V137.19l-20.6,20.6ZM166.5,81H164v33.81l26.16-26.17A40.29,40.29,0,0,0,166.5,81ZM72,153.19V216h43V133.4l-11.6-11.61Zm0-18.38,31.4-31.4L115,115V81H72ZM207,121.5h0a40.29,40.29,0,0,0-7.64-23.66L164,133.19V162h2.5A40.5,40.5,0,0,0,207,121.5Z' fill='%23fff'/%3E%3Cpath d='M189 72l27 27V72h-27z' fill='%2300c08b'/%3E%3C/svg%3E%0A",
  "reference": null,
  "reference_hash": null,
  "decimals": 18
}
```

</p>

</details>

_The `Wallet` object comes from our [quickstart template](https://github.com/near-examples/hello-near-examples/blob/main/frontend/near-wallet.js)_
---
id: what-is
title: What are Web3 Apps? 
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {CodeTabs, Language, Github} from "@site/src/components/codetabs"

Web3 Applications - also known as decentralized apps (dApps) - leverage [smart contracts](../2.smart-contracts/what-is.md) and blockchain data to offer **transparency**, **security** and **giving back control** to users over their assets and data.

![img](/docs/assets/welcome-pages/examples.png)

NEAR simplifies building Web3 apps for the general public, making it easy to **interact** with different blockchains, while helping to **onboard users** that are not familiarized with crypto.

---

### Why Integrating NEAR to your App?
Any application can benefit from integrating NEAR, including games, financial services, social platforms, and more.

- **Easy Onboarding**: Users can create accounts using familiar methods such as email login. Furthermore, applications can cover all transactional costs for their users, so they never have to worry about handling crypto.

- **Ownership**: Users have true ownership of digital assets within their accounts. Fungible Tokens can be used as reward systems, Non-Fungible Tokens can denote holdings, and wallets can represent digital identities.

- **Fast, Cheap and Scalable**: Near’s efficient consensus mechanism and fee model make transactions cost effective for both users and developers.

- **Security & Transparency**: All transactions and data on the blockchain is transparent and auditable, thus ensuring trust in the application’s behavior.