Skip to content

Commit

Permalink
Add auction series (#2183)
Browse files Browse the repository at this point in the history
* add auction series

* add more content

* updates

* more additions

* small changes

* add updates (#2190)

* add auction series

* add more content

* updates

* more additions

* accept changes

* Monday additions

* Tuesday changes

---------

Co-authored-by: PiVortex <[email protected]>
Co-authored-by: Guille <[email protected]>

* wip: proposal

* Wednesday changes

* finish part 1 and part 2

* small changes + remove future tutorials from sidebar

* fix spelling mistake

* update part 3

* hide nft tuotrial on intro page

* improved part 4

* complete part 3 & 4 (hidden)

* change cusd to dai

* add frontend docs WIP

* spelling

* update 5-frontend

* add showSingleFName

* add factory contract docs

* wip: re-structuring

* add indexing page

* finished 1st part

* finished 1st part

* rename files

* fix: links

* Update docs/6.integrations/create-transactions.md

Co-authored-by: Damián Parrino <[email protected]>

---------

Co-authored-by: PiVortex <[email protected]>
Co-authored-by: gagdiez <[email protected]>
Co-authored-by: Damián Parrino <[email protected]>
  • Loading branch information
4 people authored Sep 16, 2024
1 parent 83dadcf commit a6d8c7e
Show file tree
Hide file tree
Showing 20 changed files with 1,896 additions and 15 deletions.
19 changes: 13 additions & 6 deletions docs/2.build/2.smart-contracts/anatomy/anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Let's illustrate the basic anatomy of a simple "Hello World" contract. The code

<Block highlights='{"js": "4-17", "rust":"5-7,20-31"}' fname="hello-near">

### Contract's Class / Structure
The contract is described through a `Class` / `Struct` :
### Contract's Main Structure
The contract is described through a structure:
- The attributes define which data the contract stores
- The functions define its public (and private) interface

Expand All @@ -38,8 +38,9 @@ Let's illustrate the basic anatomy of a simple "Hello World" contract. The code
1. What to fetch from storage when the contract is loaded
2. What to store when the contract is done executing
3. The methods that are exposed to the outside world
4. If the contract needs to be initialized (we will cover this later)

**Note:** Only one class can be decorated with the `@NearBindgen` decorator.
**Note:** Only one class can be decorated with the `@NearBindgen` decorator

</Block>

Expand Down Expand Up @@ -86,7 +87,13 @@ Let's illustrate the basic anatomy of a simple "Hello World" contract. The code

</Block>

<Block highlights='{"js": "8-10", "rust": "22-24"}' fname="hello-near">
<Block highlights='{"js": "7-9"}' fname="hello-near">

Javascript contracts need to further include a `schema` object that defines the contract's state and its types. This object is used by the SDK to correctly serialize and deserialize the contract's state.

</Block>

<Block highlights='{"js": "12-14", "rust": "22-24"}' fname="hello-near">

### Read Only Functions
Contract's functions can be read-only, meaning they don't modify the state. Calling them is free for everyone, and does not require to have a NEAR account.
Expand All @@ -95,7 +102,7 @@ Let's illustrate the basic anatomy of a simple "Hello World" contract. The code

</Block>

<Block highlights='{"js": "13-16", "rust": "27-30"}' fname="hello-near">
<Block highlights='{"js": "17-20", "rust": "27-30"}' fname="hello-near">

### State Mutating Functions
Functions that modify the state or call other contracts are considered state mutating functions. It is necessary to have a NEAR account to call them, as they require a transaction to be sent to the network.
Expand All @@ -106,7 +113,7 @@ Let's illustrate the basic anatomy of a simple "Hello World" contract. The code

<File language="js" fname="hello-near"
url="https://github.com/near-examples/hello-near-examples/blob/main/contract-ts/src/contract.ts"
start="2" end="18" />
start="2" end="32" />

<File language="rust" fname="hello-near"
url="https://github.com/near-examples/hello-near-examples/blob/main/contract-rs/src/lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion docs/2.build/2.smart-contracts/anatomy/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The environment exposes three different ways to tell the pass of time, each repr

### Timestamp

The `timestamp` attribute represents the approximated **UNIX timestamp** at which this call was executed. It quantifies time passing in a human way, enabling to check if a specific date has passed or not.
The `timestamp` attribute represents the approximated **UNIX timestamp** in **nanoseconds** at which this call was executed. It quantifies time passing in a human way, enabling us to check if a specific date has passed or not.

### Current Epoch

Expand Down
8 changes: 4 additions & 4 deletions docs/2.build/2.smart-contracts/what-is.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ Besides, smart contracts can store data in the account's storage. This allows co

## What are they used for?
Smart contracts are useful to create **decentralized applications**. Some traditional examples include:
- [Decentralized Autonomous Organizations](https://dev.near.org/nearcatalog.near/widget/Index?cat=dao), where users create and vote proposals
- [Marketplaces](https://dev.near.org/nearcatalog.near/widget/Index?cat=marketplaces), where users create and commercialize digital art pieces
- [Decentralized exchanges](https://dev.near.org/nearcatalog.near/widget/Index?cat=exchanges), where users can trade different currencies
- [And many more...](https://dev.near.org/nearcatalog.near/widget/Index)
- [Decentralized Autonomous Organizations](https://dev.near.org/applications?cat=dao), where users create and vote proposals
- [Marketplaces](https://dev.near.org/applications?cat=marketplaces), where users create and commercialize digital art pieces
- [Decentralized exchanges](https://dev.near.org/applications?cat=exchanges), where users can trade different currencies
- [And many more...](https://dev.near.org/applications)

For instance, you can easily create a crowdfunding contract that accepts $NEAR. If the goal is met in time, the creator can claim the funds. Otherwise, the backers are refunded.

Expand Down
117 changes: 117 additions & 0 deletions docs/3.tutorials/auction/0-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
id: introduction
title: A Step-by-Step Guide to Mastering NEAR
sidebar_label: Introduction
---

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

Welcome! In this guide we will help you navigate NEAR tech stack, so you can build Web3 applications from start to finish in no-time.

We'll start from a simple auction contract and slowly build on top of it a full Web3 application to carry on-chain auctions.

By the time you finish this tutorial, you will have learned how to use several key primitives and concepts along the way:

- Building and testing a contract
- Deploying, updating and locking a contract
- Creating a frontend to interact with the contract
- Using an indexing API to keep track of the contract's activity
- Creating a factory to deploy new contracts

<!-- - Making cross-contract calls
- Using Non-Fungible Tokens
- Using Fungible Tokens
- Creating a frontend for a contract
- Setting up an indexer
- Creating a factory contract -->

---

## Prerequisites

Before starting, make sure to set up your development environment!

<details>
<summary>Working on Windows?</summary>

See our blog post [getting started on NEAR using Windows](/blog/getting-started-on-windows) for a step-by-step guide on how to setup WSL and your environment

</details>

<Tabs groupId="code-tabs">
<TabItem value="js" label="🌐 JavaScript">

```bash
# Install Node.js using nvm (more option in: https://nodejs.org/en/download)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install latest

# Install the NEAR CLI to deploy and interact with the contract
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
```

</TabItem>

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

```bash
# Install Rust: https://www.rust-lang.org/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Contracts will be compiled to wasm, so we need to add the wasm target
rustup target add wasm32-unknown-unknown

# Install the NEAR CLI to deploy and interact with the contract
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh

# Install cargo near to help building the contract
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
```

</TabItem>

</Tabs>

We will be using the tool [NEAR CLI](../../4.tools/cli.md) to interact with the blockchain through the terminal, and you can choose between JavaScript or Rust to write the contract.


---

## Overview

This series will touch on different level of the NEAR tech stack. Each section will be independent of the previous one, so feel free to jump into the section that interests you the most.

#### 1. Smart Contract
1. [The Auction Contract](./1-basic.md): We cover a simple auction smart contract
2. [Updating and Locking a Contract](./2-locking.md): Discover what it means to lock a contract
3. Giving an NFT to the Winner (soon) : Give the highest bidder an NFT to signal their win
4. Integrating Fungible Tokens (soon) : Allow people to use fungible tokens to bid (e.g. stable coins)

#### 2. Frontend

1. Creating the frontend : Lets learn how to connect a frontend with your smart contract
2. Easily query on-chain data : Use open APIs to keep track of the users and their bidding price

#### 3. Factory
1. Creating a factory: Allow users to easily deploy and initialize their own auction contracts


---

## Next steps

Ready to start? Let's jump to the [The Auction Contract](./1-basic.md) and begin your learning journey!

:::note Versioning for this article

- near-cli: `0.12.0`
- near-sdk-js: `2.0.0`
- near-sdk-rs: `5.1.0`
- near-workspaces-js: `3.5.0`
- node: `21.6.1`
- near-workspaces-rs: `0.10.0`
- rustc: `1.78.0`
- cargo-near: `0.6.2`

:::
Loading

0 comments on commit a6d8c7e

Please sign in to comment.