jcarbonnell/preTrainingNEAR huggingface dataset:
---
id: welcome
title: "NEAR SDKs"
hide_table_of_contents: false
---

import {FeatureList, Column, Feature} from "@site/src/components/featurelist";

Explore our language-specific SDK documentation

<FeatureList>
  <Column title="SDKs">
    <Feature url="/sdk/rust/introduction" title="Rust SDK" subtitle="Write Contracts in Rust" image="smartcontract-rust.png" />
  </Column>
  <Column title="&nbsp;">
    <Feature url="/sdk/js/introduction" title="JavaScript SDK" subtitle="Write Contracts in JavaScript" image="smartcontract-js.png" />
  </Column>
</FeatureList>
This is an example on how you can make your smart contract buy a NFT on some marketplace (Paras this case).

:::info
Please note that in this example the contract will be the owner of the NFT, however, some marketplaces allow you to buy NFT for somebody else.
:::

```rust
const NFT_MARKETPLACE_CONTRACT: &str = "paras-marketplace-v2.testnet";

// Define the contract structure
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Contract {
  nft_marketplace_contract: AccountId
}

impl Default for Contract {
    // The default trait with which to initialize the contract
    fn default() -> Self {
        Self {
          nft_marketplace_contract: NFT_MARKETPLACE_CONTRACT.parse().unwrap()
        }
    }
}

// Validator interface, for cross-contract calls
#[ext_contract(ext_nft_contract)]
trait ExternalNftContract {
  fn buy(&self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option<AccountId>, price: Option<U128>) -> Promise;
}

// Implement the contract structure
#[near_bindgen]
impl Contract {
  #[payable]
  pub fn buy(&mut self, nft_contract_id: AccountId, token_id: TokenId, ft_token_id: Option<AccountId>, price: Option<U128>) -> Promise {
    let promise = ext_nft_contract::ext(self.nft_marketplace_contract.clone())
      .with_static_gas(Gas(30*TGAS))
      .with_attached_deposit(env::attached_deposit())
      .buy(nft_contract_id, token_id, ft_token_id, price);

    return promise.then( // Create a promise to callback query_greeting_callback
      Self::ext(env::current_account_id())
      .with_static_gas(Gas(30*TGAS))
      .buy_callback()
    )
  }

  #[private] // Public - but only callable by env::current_account_id()
  pub fn buy_callback(&self, #[callback_result] call_result: Result<(), PromiseError>) {
    // Check if the promise succeeded
    if call_result.is_err() {
      log!("There was an error contacting NFT contract");
    }
  }
}
```
An Open Invitation to the Harmony Community
COMMUNITY
July 29, 2022
The NEAR Foundation works tirelessly to create a stable ecosystem. A place for developers, founders, and community members to collectively build an Open Web world.

During this tumultuous period for Web3 and the broader global economy, many projects that launched or are actively building on the Harmony network are now facing uncertainty. Which is why NEAR Foundation is extending an open invitation to anyone currently building on Harmony to join the NEAR community, and make this vibrant ecosystem their new home.

As part of this invitation, NEAR Foundation and Proximity Labs have put together  sizable relief funds for projects from the Harmony ecosystem. If you’re looking to bring your project over to NEAR, here’s what you need to know.

Why choose NEAR? 
The NEAR blockchain is built with simplicity in mind. NEAR uses common coding languages like WebAssembly (WASM) and Rust to build its smart contracts. NEAR is also launching a Javascript SDK, making the switch simple for those who built with Harmony’s own Javascript implementation, or were considering it. Aurora, which is built on NEAR, is 100% EVM-compatible, and NEAR’s super fast transactions run on an infinitely scalable yet carbon neutral protocol. By switching to NEAR, your project would join over 700 apps building on NEAR. 

NEAR was built by developers for developers. NEAR Foundation and other ecosystem platforms, like Aurora and Pagoda, have vast offerings of class-leading resources for developers to begin building on NEAR. These include NEAR.University’s training and certification programs—to date, over 5,000 developers trained—and $45M+ in project grants within the NEAR ecosystem. 

The NEAR community also offers extensive documentation on building and deploying on the network, and much more.

NEAR’s developer resources
Interested in developing on NEAR? Great! A range of resources are at your disposal: 

Developer Tools – NEAR CLIs, SDKs, APIs and more.
Code Examples – Explore how to deploy Rust and AssemblyScript.  
Developer Bounties – Bug fixes, developer grants and other incentives. 
Grants Program – More than 800 projects funded and over $45 million awarded.
Office Hours – Talk to expert developers about your project. 
Education – Learn, watch and build.  
Ecosystem – Explore the more than 700 projects already being building in the NEAR ecosystem. 
Interested in learning more about how the NEAR Foundation team can help you make the switch? Please email [email protected] with the subject line, “Harmony Migration”, and one of the teams will respond within 24 hours.
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>

```js
const tokenData = 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", // URL to associated media, preferably to decentralized, content-addressed storage
    }
  },
  undefined,
  10000000000000000000000, // Depends on your NFT metadata
);
```

</TabItem>

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

```js
const tokenData = Near.call(
  "x.paras.near",
  "nft_mint",
  {
    token_series_id: "490641",
    receiver_id: "bob.near",
  },
  undefined,
  10000000000000000000000 // Depends on your NFT metadata
);
```

:::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">

```js
const tokenData = Near.call(
  "thomasettorreiv.mintbase1.near",
  "nft_batch_mint",
  {
    num_to_mint: 1,
    owner_id: "bob.near",
    metadata: {},
  },
  undefined,
  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>
---
sidebar_position: 4
sidebar_label: Shard
---

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

# `Shard` structure

## Definition

`IndexerShard` struct is ephemeral structure, there is no such entity in `nearcore`. We've introduces it as a container in [`near-indexer-primitives`](https://crates.io/crates/near-indexer-primitives). This container includes:

- shard ID
- [Chunk](chunk.mdx) that might be absent
- [ExecutionOutcomes](execution_outcome.mdx) for [Receipts](receipt.mdx) (these belong to a Shard not to a [Chunk](chunk.mdx) or a [Block](block.mdx))
- [StateChanges](state_change.mdx) for a Shard

## `IndexerShard`

<Tabs>
  <TabItem value="rust" label="Rust">

```rust links=1
pub struct IndexerShard {
    pub shard_id: types::ShardId,
    pub chunk: Option<IndexerChunkView>,
    pub receipt_execution_outcomes: Vec<IndexerExecutionOutcomeWithReceipt>,
    pub state_changes: views::StateChangesView,
}
```

  </TabItem>
  <TabItem value="typescript" value="TypeScript">

```ts links=1
export interface Shard {
  shard_id: number;
  chunk?: Chunk;
  receiptExecutionOutcomes: ExecutionOutcomeWithReceipt[];
  stateChanges: StateChange[];
};
```

  </TabItem>
</Tabs>
---
id: state-change
sidebar_position: 9
sidebar_label: StateChange
---

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

# `StateChange` Structure

## Definition

This entitiy from `nearcore` describes how account's state has changed and the reason

## `StateChangeWithCauseView`

<Tabs>
  <TabItem value="rust" label="Rust">

```rust links=1
pub struct StateChangeWithCauseView {
    pub cause: StateChangeCauseView,
    #[serde(flatten)]
    pub value: StateChangeValueView,
}

pub enum StateChangeCauseView {
    NotWritableToDisk,
    InitialState,
    TransactionProcessing { tx_hash: CryptoHash },
    ActionReceiptProcessingStarted { receipt_hash: CryptoHash },
    ActionReceiptGasReward { receipt_hash: CryptoHash },
    ReceiptProcessing { receipt_hash: CryptoHash },
    PostponedReceipt { receipt_hash: CryptoHash },
    UpdatedDelayedReceipts,
    ValidatorAccountsUpdate,
    Migration,
    Resharding,
}

pub enum StateChangeValueView {
    AccountUpdate {
        account_id: AccountId,
        #[serde(flatten)]
        account: AccountView,
    },
    AccountDeletion {
        account_id: AccountId,
    },
    AccessKeyUpdate {
        account_id: AccountId,
        public_key: PublicKey,
        access_key: AccessKeyView,
    },
    AccessKeyDeletion {
        account_id: AccountId,
        public_key: PublicKey,
    },
    DataUpdate {
        account_id: AccountId,
        #[serde(rename = "key_base64", with = "base64_format")]
        key: StoreKey,
        #[serde(rename = "value_base64", with = "base64_format")]
        value: StoreValue,
    },
    DataDeletion {
        account_id: AccountId,
        #[serde(rename = "key_base64", with = "base64_format")]
        key: StoreKey,
    },
    ContractCodeUpdate {
        account_id: AccountId,
        #[serde(rename = "code_base64", with = "base64_format")]
        code: Vec<u8>,
    },
    ContractCodeDeletion {
        account_id: AccountId,
    },
}
```

  </TabItem>

  <TabItem value="typescript" label="TypeScript">

```ts links=1
export type StateChange = {
  cause: {
    receiptHash: string;
    type: string;
  };
  change: {
    accountId: string;
    keyBase64: string;
    valueBase64: string;
  },
  type: string;
};
```

  </TabItem>
</Tabs>
NEAR Community Update: March 13th, 2020
COMMUNITY
March 13, 2020
In this community update, we introduce Flux, a prediction market built on NEAR, to show how we’ll make our internal operations public and share the latest and greatest on content.

Stay Healthy!
In light of the recent global volatility, Near closed its office in San Francisco and canceled all in-person events. Until further notice, we are moving all of our interactions online.

To create community experiences we are curious to know what type of things you want to learn and talk most about. Let us know in this week’s vote, and we’ll share the results on Tuesday.

Vote Here!

Flux
Flux announced their fully redesigned app built on top of their protocol (see the announcement here: https://twitter.com/Flux_Market/status/1235958316708302849?s=20). This app allows users to onboard into Flux via the NEAR wallet in seconds and trade on a range of markets. Use cases include politics, stock-markets, private companies, sports, esports, and even insurance. All trading is done in DAI, a stable coin pegged to the US Dollar.

In addition, ARterra an eSports engagement platform announced a partnership launching tailored eSports markets on top of Flux Protocol (go check it out here: https://twitter.com/ARterra_company/status/1237078763516694529?s=20).

Peter and Jasper — the founders of Flux
Content Highlight
“Not only should it feel like a Web2 backend, it should feel truly serverless.” — Sasha

Abel’s Abstracts recorded a podcast with Sasha on NEAR and the Open Web Collective! 

Tweet preview
Web: https://anchor.fm/abelsabstracts
Apple Podcasts: https://apple.co/38B6uNf – 
Spotify: https://spoti.fi/3cPDJiS 
Join Our Public Meetings
As part of being an open community, we are beginning to make our meetings public. You can see them on this calendar. Join to listen, make suggestions and start discussions (within the scope of the meeting). 

We are starting with the following meetings: Middleware Work Group (Wasm, Runtime, RPC, etc.) and Eth Bridge Work Group.

Additionally, we invite you to join our forum discussions: https://commonwealth.im/near/.

Welcome our new team member Huxley!
How You Can Get Involved
Join the NEAR Contributor Program. If you would like to host events, create content or provide developer feedback, we would love to hear from you! To learn more about the program and ways to participate, please head over to the website.

If you’re just getting started, learn more in The Beginner’s Guide to NEAR Protocol or read the official White Paper. Stay up to date with what we’re building by following us on Twitter for updates, joining the conversation on Discord and subscribing to our newsletter to receive updates right to your inbox.
# RuntimeConfig

The structure that holds the parameters of the runtime, mostly economics.

## storage_cost_byte_per_block

_type: Balance_

The cost to store one byte of storage per block.

## storage_cost_byte_per_block

_type: Balance_

Costs of different actions that need to be performed when sending and processing transaction
and receipts.

## poke_threshold

_type: BlockIndex_

The minimum number of blocks of storage rent an account has to maintain to prevent forced deletion.

## transaction_costs

_type: [RuntimeFeesConfig](RuntimeFeeConfig.md)_

Costs of different actions that need to be performed when sending and processing transaction and receipts.

## wasm_config

_type: [VMConfig](VMConfig.md),_

Config of wasm operations.

## account_length_baseline_cost_per_block

_type: Balance_

The baseline cost to store account_id of short length per block.
The original formula in NEP#0006 is `1,000 / (3 ^ (account_id.length - 2))` for cost per year.
This value represents `1,000` above adjusted to use per block
---
sidebar_position: 1
sidebar_label: Table of contents
---

# Structures. Table of Contents

The structures described in this section of the docs are indexer-related more than `nearcore` related. Some of the are artificial and are not a part of `nearcore`

:::note How data flows in NEAR Protocol

Don't skip the article about the [NEAR Data Flow](https://docs.near.org/concepts/data-flow/near-data-flow)

:::

**The main goal of this section is to describe `StreamerMessage` structure from [`near-indexer-primitives`](https://crates.io/crates/near-indexer-primitives)**

- `StreamerMessage`
  - [Block](./block.mdx)
    - [BlockHeader](./block.mdx#blockheaderview)
  - [Shards](./shard.mdx)
    - [Chunk](./chunk.mdx)
      - [ChunkHeader](./chunk.mdx#chunkheaderview)
      - [Transactions](./transaction.mdx)
      - [Receipts](./receipt.mdx)
    - [ExecutionOutcomes](./execution_outcome.mdx) for [Receipts](./receipt.mdx)
    - [StateChanges](./state_change.mdx)
```js
const tokenContract = "token.v2.ref-finance.near";
const tokenPriceResult = fetch(
  `https://indexer.ref.finance/get-token-price?token_id=${tokenContract}`
).body;
const tokenPriceValue = JSON.parse(tokenPriceResult);
```

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

```json
{
  "token_contract_id": "token.v2.ref-finance.near",
  "price": "0.08153090"
}
```

</p>

</details>

:::tip
Ref Finance has a method to [get all token prices at once](https://indexer.ref.finance/list-token-price).
:::
Zero to Hero NFT Series: Happy Holidays from DevRel!
DEVELOPERS
December 17, 2021
It’s been a great year for the NEAR ecosystem and our developer community. We’ve hosted our first MetaBUIDL hackathon, rocked the crypto-boat in Portugal with the NEARCON, enjoyed a daily dose of Q&A on our Office Hours, and had a coding rush with the NEARvember challenge.

The DevRel team is simply amazed by our dev community, and we are thankful for the support and time every developer spends building projects on NEAR. So, as a humble way to say “Thank You”, we’ve prepared an NFT tutorial series so you can go from Zero to NFT Hero before the new year knocks on your door.

If you are new to Rust and want to dive into smart contract development, this series is a great place to start, especially if you want to learn about non-fungible tokens. 

In this “NFT Zero to Hero” series, you’ll find a set of tutorials that will cover every aspect of a non-fungible token (NFT) smart contract. You’ll go from minting an NFT using a pre-deployed contract to building a fully-fledged NFT smart contract that supports every extension.

NFT tutorials
As a sneak peek, here’s a list of the NFT tutorials that will bring you from Zero to Hero in no time:

Pre-deployed contract: Get introduced to minting an NFT without the need to code, create, or deploy a smart contract.
Contract architecture: Learn the basic architecture of the NFT smart contract and you’ll compile this skeleton code with the Rust toolchain.
Minting: Flesh out the skeleton so the smart contract can mint a non-fungible token.
Upgrade a contract: Discover the process to upgrade an existing smart contract.
Enumeration: Explore different enumeration methods that can be used to return the smart contract’s states.
Core: Extend the NFT contract using the core standard, which will allow you to transfer non-fungible tokens.
Approvals: Expand the contract allowing other accounts to transfer NFTs on your behalf.
Royalty: Add the ability for non-fungible tokens to have royalties. This will allow people to get a percentage of the purchase price when an NFT is purchased.
Next steps
If you’re ready to start, jump into our Dev Docs and begin your Hero learning journey! If you already know about non-fungible tokens and smart contracts, feel free to skip and jump directly to the tutorial of your interest. 

These tutorials have been designed so you can start at any given point, so you don’t need to start from zero if you’re already a Hero. 🙂
Well hello, NEAR Academy!
COMMUNITY
March 24, 2021
We’re proud to announce the launch of near.academy, a keystone of our educational onramp at NEAR Protocol.

Powered by the same team and technology behind Ocean Academy and Tezos Academy, NEAR Academy is purpose-built for web 2 developers looking for a hands-on introduction to blockchain concepts and code.

101Labs has done an incredible job of crafting an approachable narrative with a twist: The Meme Museum.

The year is 2029. The new internet is running on top of public interoperable blockchains. It seems crazy to think how the perception towards these technologies has drastically changed. The Internet of Value is more tangible than ever. Knowing how blockchain works is not considered a competitive advantage nowadays. It is a must-have. 

Behind the welcoming facade of the meme museum are multiple smart contracts written specifically for this learning experience. These include a custom NFT token contract and an NFT generator. These contracts work together to create an immersive experience for developers learning about NEAR Protocol where anyone can enter and everyone leaves with an NFT.

The learning platform is friendly and responsive, making it easy for developers to set their own pace through the learning materials. Along the way, developers must confirm their understanding of the material using a playful and inviting interface.

Developers who complete this course will come to understand the basics of web 3, a high level overview of how NEAR Protocol works as well as an introduction to writing smart contracts for NEAR. The learning experience includes diagrams, code samples and links to resources for further study. A certificate of completion is issued for anyone who completes the course.

This is just the first of many modules we expect to launch with 101Labs this year and we welcome your feedback. Our single mission is to educate the world about web 3 technologies using NEAR Protocol.

Visit near.academy today for a tour of the future.

NEAR’s mission is to enable community-driven innovation to benefit people around the world. The NEAR platform provides a decentralized application platform that is secure enough to manage high value assets like money or identity and performant enough to make them useful for everyday people, putting the power of Open Finance and the Open Web in their hands.

The NEAR platform, NEAR Protocol, and associated tooling are being built by the NEAR Collective, a collection of the best engineers in the world who work across teams, companies and countries similar to other large scale open source projects.

If you’re a developer who wants to see what building on NEAR is all about, check out the NEAR documentation to get started.