jcarbonnell/preTrainingNEAR huggingface dataset:
---
id: account-model
title: NEAR Accounts
sidebar_label: Overview
---

Users participate in the NEAR ecosystem through their NEAR accounts. These accounts are identified by a [unique address](./account-id.md), can optionally hold a [smart contract](./smart-contract.md), and are controlled through [Access Keys](./access-keys.md).

By signing [transactions](./transactions.md) with their account, users can:

1. Send and receive **digital assets** (such as tokens or collectibles)
2. Create and interact with on-chain applications known as **smart contracts**
3. Control accounts in **other chains** (such as Ethereum or Bitcoin) ✨
4. Help onboard new users by **covering the costs** of their transactions (gas fees)

:::tip Want to create an account?
You have multiple ways to create an account, you can [sign-up using your email](https://near.org/), get a mobile wallet through [telegram](https://web.telegram.org/k/#@herewalletbot), or create a [web wallet](https://app.mynearwallet.com).
:::

---

## Account Model Overview 

Let's take a closer look at the different elements that compose the NEAR account model.

![img](@site/static/docs/assets/welcome-pages/accounts.png)


#### [Account ID](account-id.md)
NEAR implements two types of accounts IDs: **named accounts** such as `alice.near`, which are simple to remember and share, and the classic alphanumeric IDs (`fb9243ce...`) that other chains also implement.

#### [Permissions Through Access Keys](access-keys.md)
NEAR accounts can have multiple [keys](access-keys.md), each with their own set of permissions. This allows to easily swap keys if one gets compromised, and to use keys as authorization tokens for third-parties.

#### [Simple to Develop Smart Contracts](smart-contract.md)
NEAR accounts can optionally hold a simple program, known as a [smart contract](smart-contract.md). In NEAR, developers can create smart contracts using languages such as Javascript or Rust. 

---

## Comparison With Ethereum {#compared-to-ethereum}

If you're familiar with development on Ethereum, it's worth making a quick note about how accounts are different. The table below summarizes some key differences:

|                   | Ethereum Wallet                                                                             | NEAR Account                                                                            |
|-------------------|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| Public Identifier | Public Key (`0x123...`)                                                                     | Named IDs (`alice.near`) and implicit accounts (Public Key `0x123...`)                  |
| Secret Key        | Private Key (`0x456...`)                                                                    | Multiple key-pairs with permissions:<br />- `FullAccess` key<br />- `FunctionCall` key  |
| Characteristics   | - Private key gives full access<br />- Account doesn't have to be created via a transaction | - Permission-based keypair<br />- Account ID must be created via blockchain transaction |
---
id: introduction
title: About JS SDK
---

JavaScript is the most popular programming language, used by nearly 14 million developers worldwide. You can write smart-contracts in JavaScript or Typescript, and our SDK will pack them with a lightweight runtime. This can then be compiled into a single Wasm file that can be deployed into the NEAR network.

:::info Help contribute!
- [Report issues you encounter](https://github.com/near/near-sdk-js/issues) 🐞 
- [Provide suggestions or feedback](https://github.com/near/near-sdk-js/discussions) 💡 
- [Show us what you've built!](https://github.com/near/near-sdk-js/discussions/categories/show-and-tell) 💪  
:::

---

## Create Your First Javascript Contract
Create your first **Javascript contract** in minutes:
1. Download and install [Node.js](https://nodejs.org/en/download/).
2. Create a new **javascript** project using our [quickstart guide](../../2.build/2.smart-contracts/quickstart.md).
3. Read our docs on **[how to write smart contract](../../2.build/2.smart-contracts/anatomy/anatomy.md)**.
Introducing 4 NEAR apps at Consensus Distributed
COMMUNITY
May 6, 2020
It’s only halfway through the week and it’s been busy at NEAR — the just-announced MainNet has now produced over 1.5 million blocks since genesis and we’ve hosted over a dozen talks, workshops and events as part of organizing the epic Ready Layer One conference (which ends today). This rolls into the RL1 Hackathon over the next two weeks and… we’ll probably find time to sleep someday.

At this point, we’ve told the story of Open Money, Open Finance and the Open Web but the best way to make this concrete is to see real examples. With MainNet out, we want to begin surfacing some of the fantastic applications that are building on NEAR and use them to help explain why the NEAR platform is so special.  That’s why we’re firing up the coffee pot for another leap onto the virtual stage to showcase the following teams at next week’s Consensus: Distributed conference:

1inch Exchange (Anton Bukov), a decentralized exchange (DEX) aggregation platform which allows teams to find the best prices on the market. Typically, trying to move high volumes on DEXes results in poor fills and price slippage but they help spread the volume out across multiple exchanges to prevent this. Their platform relies on fast and low cost transactions, which is part of what brought them to build on NEAR.
TessaB (Tanuj Nigam), a company which facilitates the secondary market for mobile devices by removing multiple middlemen from the process. They track provenance, power financial transactions and offer on-device app stores using the blockchain.
Stardust (Canaan Linder), a platform which allows game developers to both increase revenue and improve their players’ experiences by easily adding a secondary marketplace for digital goods. NEAR gives them a set of UX tools and flexible accounts that no one else can so they can offer the end-users of their game developers a fantastic experience while introducing them to blockchain.
Flux (Peter Mitchell), a protocol which powers easy markets for a variety of applications including helping Twitch streamers create live betting experiences around their streams. NEAR gives them performance and usability.
Mark your calendar!
NEAR and the four Open Web builders will be presenting at Consensus: Distributed on

Tuesday, May 12, 2020 @ 6-7pm EST

At the event, we’ll provide a brief overview of the NEAR MainNet, take questions from the audience and then allow the projects to shine:

Changelog: The NEAR MainNet is Live (Illia Polosukhin, Co-founder of Near Inc)
Construct: The Open Web Collective with Anton @ 1inch, Tanuj @ TessaB, Canaan @ Stardust and Peter @ Flux.
Closing remarks
In addition, Amos Zhang (Strategic Lead – China @ NEAR) from our team will join forces with Jieli (Jerry) Li (Ant Financial & Alibaba), Harriet Cao (Co-founder @ IRISnet), and Jan Xie (Co-founder @ Nervos ) on a session hosted by Coindesk China at Consensus Distributed. The session will start at 1:00 AM – 2:00 AM EST (or 1:00 PM – 2:00 PM Beijing Time) on May 12th.
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs className="file-tabs">

<TabItem value="near-api-js" label="near-api-js">

```js
import { KeyPair } from 'near-api-js';

const newKeyPair = KeyPair.fromRandom('ed25519');
newKeyPair.public_key = newKeyPair.publicKey.toString();
```

</TabItem>

<TabItem value="Keypom API" label="Keypom API">

```js
const state = {};

const dropsNumber = "2";
const keysGeneratorUrl = "https://keypom.sctuts.com/keypair/";

fetch(keysGeneratorUrl + dropsNumber + "/rootEntrophy").then((res) => {
  const keyPairs = JSON.parse(res.body);
  const pubKeys = [];
  const privKeys = [];

  keyPairs.forEach((e) => {
    pubKeys.push(e.pub);
    privKeys.push(e.priv);
  });

  state.publicKeys = pubKeys;
  state.privKeys = privKeys;
});
```

</TabItem>

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

const KEYPOM_CONTRACT_ADDRESS = "v2.keypom.near";
const NFT_CONTRACT_ADDRESS = "nft.primitives.near";
const DROP_AMOUNT = "10000000000000000000000";

const keypomConnectedWallet = new Wallet({ createAccessKeyFor: KEYPOM_CONTRACT_ADDRESS }); 
const nftConnectedWallet = new Wallet({ createAccessKeyFor: NFT_CONTRACT_ADDRESS });

await wallet.callMethod({
  method: "create_drop",
  contractId: KEYPOM_CONTRACT_ADDRESS,
  args: {
    public_keys: state.publicKeys,
    deposit_per_use: DROP_AMOUNT,
    nft: {
      // Who will be sending the NFTs to the Keypom contract
      sender_id: accountId, // TODO How to get it
      // NFT Contract Id that the tokens will come from
      contract_id: NFT_CONTRACT_ADDRESS,
    },
  },
  deposit: "23000000000000000000000" // state.publicKeys.length * dropAmount + 3000000000000000000000,
  gas: "100000000000000",
});
```

_The `Wallet` object comes from our [quickstart template](https://github.com/near-examples/hello-near-examples/blob/main/frontend/near-wallet.js)_
```rust
#[derive(Serialize, Deserialize)]
#[serde(crate = "near_sdk::serde")]
pub struct PoolInfo {
  /// Pool kind.
  pub pool_kind: String,
  /// List of tokens in the pool.
  pub token_account_ids: Vec<AccountId>,
  /// How much NEAR this contract has.
  pub amounts: Vec<U128>,
  /// Fee charged for swap.
  pub total_fee: u32,
  /// Total number of shares.
  pub shares_total_supply: U128,
  pub amp: u64,
}

// Validator interface, for cross-contract calls
#[ext_contract(ext_amm_contract)]
trait ExternalAmmContract {
  fn get_pools(&self, from_index: u64, limit: u64) -> Promise;
}

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

    // Return the pools data
    let pools_data = call_result.unwrap();
    return Some(pools_data);
  }

  pub fn get_amm_pools(&self, from_index: u64, limit: u64) -> Promise {
    let promise = ext_amm_contract::ext(self.amm_contract.clone())
      .get_pools(from_index, limit);

    return promise.then( // Create a promise to callback query_greeting_callback
      Self::ext(env::current_account_id())
      .external_get_pools_callback()
    )
  }
}
```
```bash
near call tkn.near create_token '{"args":{"owner_id": "bob.near","total_supply": "1000000000","metadata":{"spec": "ft-1.0.0","name": "Test Token","symbol": "TTTEST","icon": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","decimals": 18}},"account_id": "bob.near"}' --gas 300000000000000 --depositYocto 2234830000000000000000000 --accountId bob.near
```
NEAR Foundation Backs Hydra Ventures to Create Web3’s First ‘Fund of Funds’ Investment DAO
NEAR FOUNDATION
March 29, 2023
NEAR Foundation is excited to announce that it has joined Hydra Ventures, a “fund of funds” investment DAO. A first in the Web3 space, Hydra Ventures is designed to help other investment DAOs get off the ground. 

By partnering with NEAR Foundation, Hydra Ventures will open the doors to the eventual launch of the first investment DAO in the Near ecosystem. 

“The combined expertise of the leaders that have created this fund offers a winning formula that will help provide critical funding to purpose-driven, socially impactful web3 startups,” said Marieke Flament, CEO of NEAR Foundation. “We are delighted to be playing a part in launching this DAO and look forward to seeing the role it will play in developing our ecosystem.”

Decentralizing Web3 investment with DAOs
To power the “fund of funds” investment DAO, Hydra Ventures has raised $10M in capital from NEAR Foundation, MetaCartel Ventures, ConsenSys, 1kx Ventures, Collab + Currency, Nonagon Ventures, CMT Digital, among others. Hydra Ventures aims to take a hands-on approach to support investment DAOs, from community coordination and investment practices to organizational design, incentive design, and back office/operations.
“While the first legally wrapped investment DAOs showed us what was possible, many of them have had major operating flaws which have been exposed over the years,” said Peter Pan, co-summoner of MetaCartel and Partner at 1kx Ventures. “Hydra looks to address many of these problems and ultimately emerge with a fundamentally better model for how investment DAOs should be operated. We are thrilled to have NEAR Foundation’s support in this venture.”

Hydra Ventures is incubated by Thing3 and MetaCartel Ventures (the first and one of the most successful investment DAOs created), and backed by leading founders and thinkers in Web3. MetaCartel has incubated and made investments in several category-leading projects like Sky Mavis, Axie Infinity, Arweave, Open Zeppelin, DAOhaus, Zapper Finance, and Rarible, and were also one of the first investors in Mintbase, an NFT marketplace built on Near. MetaCartel members include Ameen Soleimani (founder, Moloch DAO), Stani Kulechov (founder, AAVE), Roneil Rumburg (founder, Audius), Bobby Ong (founder, Coingecko), RAC (Grammy award winner), Peter Pan (Partner, 1kx Ventures), amongst others.
Mantle Ecosystem Gateway Launches on the NEAR Blockchain Operating System (B.O.S)
NEAR FOUNDATION
September 20, 2023
An ecosystem gateway for Mantle, the layer-2 scaling solution built on Ethereum, has launched on the NEAR Blockchain Operating System (B.O.S) to offer a unified point of entry into the Mantle ecosystem. 

Hosted by popular Mantle dApp FusionX, the gateway, built in collaboration with the NEAR community, streamlines the discovery of Mantle applications and helps aggregate components of top dApps including the Mantle Bridge, Agni, Ammos, iZiSwap, FusionX, Gamma, Lendle, and soon Pendle, in one place. 

The gateway offers greater accessibility for developers and users, easier discoverability for the apps they build, and powerful composability. This was all made possible thanks to the B.O.S.

“Mantle has seen some great traction since their launch and we’re very excited to have a Mantle gateway built on B.O.S. Ethereum and DeFi users interested in discovering new projects can now find lots of Mantle apps in one place, with bridging already solved so they can get started right away,” says Illia Polosukhin, co-founder of NEAR Protocol. “The Mantle gateway demonstrates the value of B.O.S gateways for other L2s and EVM projects looking to increase discoverability.” 

Unlocking the Web3 ecosystem 
Mantle’s development on NEAR is a testament to the protocol’s commitment to creating the foundations for the open web. “We are delighted to ally with NEAR in bringing leading Mantle dApps to a wider community through the Mantle Ecosystem Gateway on B.O.S,” says Arjun Kalsy, head of ecosystem of Mantle. “Through this effort, we look to provide even more support to our dev community, and allow for more cross-pollination in our respective Web3 communities.” 

The Mantle gateway joins a growing list of projects that have partnered with the B.O.S to help unlock the full potential of Web3. A zkEVM B.O.S gateway for the Polygon ecosystem launched on NEAR to help increase accessibility and discoverability for developers, while also improving the user experience for end users exploring L2 ecosystems. 

While the B.O.S is built on NEAR, it offers many benefits  to founders and builders from EVM projects and across the whole Web3 ecosystem. The Blockchain Operating System speeds up the process of building multi-chain experiences, empowering builders from any ecosystem––including EVM projects such as Ethereum layer 2s––to focus on creating great products for users rather than on managing infrastructure. 

Developers can quickly build composable apps for the open web from thousands of flexible components, as well as seamlessly onboard users and increase discoverability across Web3 since every application utilising B.O.S is visible on a common interface. This collaboration brings new capabilities to developers and lets them build apps that can quickly reach more users.
---
id: frontend-multiple-contracts
title: Frontend Interacting with Multiple Contracts
sidebar_label: Frontend & Multiple Contracts
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {CodeTabs, Language, Github} from "@site/src/components/codetabs"

This example showcases how to interact with multiple contracts from a single frontend.

Particularly, this example shows how to:

1. Query data from multiple contracts.
2. Call methods in multiple contracts simultaneously.

---

## Query Data from Multiple Contracts

To query multiple contracts simply perform multiple `view` calls:

<Language value="js" language="ts">
  <Github fname="index.js"
        url="https://github.com/near-examples/frontend-multiple-contracts/blob/main/frontend/index.js"
        start="70" end="76" />
</Language>

---

## Dispatching Multiple Transactions

The `wallet` object enables to dispatch multiple transactions simultaneously. However, please notice that the transactions execute independently.

Dispatching multiple transactions at once is just a nice way to improve UX, because the user interacts with the wallet only once.

<Language value="js" language="ts">
  <Github fname="index.js"
          url="https://github.com/near-examples/frontend-multiple-contracts/blob/main/frontend/index.js"
          start="39" end="66" />
</Language>

In this example, the user signs two independent transactions:

1. A transaction to call `set_greeting` in our [Hello NEAR example](https://github.com/near-examples/hello-near-examples)
2. A transaction to call `add_message` in our [GuestBook example](https://github.com/near-examples/guest-book-examples)

:::caution
Even when the user accepts signing the transactions at the same time, the
transactions remain **independent**. This is, if one fails, the other is **NOT** rolled back.
:::

---

## Batch Actions

You can aggregate multiple [actions](../../2.build/2.smart-contracts/anatomy/actions.md) directed towards a same contract into a single transaction. Batched actions execute **sequentially**, with the added benefit that, if **one fails** then they **all** get reverted.

```js
  // Register a user and transfer them FT on a single take
  const REGISTER_DEPOSIT = "1250000000000000000000";

  const ftTx = {
    receiverId: FT_ADDRESS,
    actions: [
      {
        type: 'FunctionCall',
        params: {
          methodName: 'storage_deposit',
          args: { account_id: "<receiver-account>" },
          gas: THIRTY_TGAS, deposit: REGISTER_DEPOSIT
        }
      },
      {
        type: 'FunctionCall',
        params: {
          methodName: 'ft_transfer',
          args: { receiver_id: "<receiver-account>", amount: amount_in_yocto },
          gas: THIRTY_TGAS, deposit: 1 }
      }
    ]
  }

  // Ask the wallet to sign and send the transaction
  await wallet.signAndSendTransactions({ transactions: [ ftTx ] })
```
---
id: welcome
title: Tools
sidebar_label: Home
---

Welcome! The NEAR ecosystem has a complete set of tools for you to make the most out of the NEAR network.
In this page you will find:

1. [Wallets](https://www.mynearwallet.com/) to handle your assets.
2. [Explorers](explorer.md) to quickly obtain information from the blockchain.
3. Websites to simplify creating and participating on governance projects.
4. Tools to query [past information](indexer4explorer.md) from the blockchain as well as [real time events](events.md).
5. Developer tools to deploy and interact with contracts such as the [NEAR CLI](cli.md) and [NEAR JavaScript API](/tools/near-api-js/quick-reference).
Case Study: Indexer’s Mary Korch on Building a Multichain Indexing Platform
NEAR FOUNDATION
August 18, 2023
NEAR is a home to a number of amazing apps and projects. These developers, founders, and entrepreneurs are using NEAR to effortlessly create and distribute innovative decentralized apps, while helping build a more open web — free from centralized platforms. In these Case Study videos, NEAR Foundation showcases some of these projects. 

In the latest NEAR Foundation Case Study video below, Mary Korch, Customer Success at Indexer, talks about how the project built its Multichain Indexing Platform on NEAR. As Korch notes in the case study, Indexer builds infrastructure to support developers, giving them the data they need to be successful on the NEAR Protocol.

“If you’re a Web2 company looking to build in Web3, and specifically in NEAR, we have done a lot of the hard work for you,” says Korch.  “You’re going to need data from the blockchain but also some off-chain data like metadata and IPFS. We actually have that all at your disposal, and it makes it a lot easier to build your application and get to market a lot quicker.”
---
id: runtime
title: Runtime
---

This section contains videos that explore the core Runtime, its operation, and how it implements cross-contract calls.

## Runtime Overview

An in-depth code overview of NEAR Runtime.

<iframe
  width="560"
  height="315"
  src="https://www.youtube-nocookie.com/embed/Xi_8PapFCjo"
  frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen>
</iframe>

## Runtime Action and Data Receipts

An in-depth code review of how NEAR Runtime implements cross contract calls.

<iframe
  width="560"
  height="315"
  src="https://www.youtube-nocookie.com/embed/RBb3rJGtqOE"
  frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen>
</iframe>

## Runtime State

An in-depth overview of how NEAR runtime operates with its state.

<iframe
  width="560"
  height="315"
  src="https://www.youtube-nocookie.com/embed/JCkSNL4ie1U"
  frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen>
</iframe>
```js
import { Wallet } from './near-wallet';

const AMM_CONTRACT_ADDRESS = "v2.ref-finance.near";
const wallet = new Wallet({ createAccessKeyFor: AMM_CONTRACT_ADDRESS });
 
await wallet.callMethod({
  method: 'swap',
  args: {
   actions: [
      {
        pool_id: 79,
        token_in: "token.v2.ref-finance.near",
        token_out: "wrap.near",
        amount_in: "100000000000000000",
        min_amount_out: "1",
      },
    ],
  },
  contractId: AMM_CONTRACT_ADDRESS,
  gas: 300000000000000,
  deposit: 1
});
```
_The `Wallet` object comes from our [quickstart template](https://github.com/near-examples/hello-near-examples/blob/main/frontend/near-wallet.js)_

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

```json
"5019606679394603179450"
```
</details>