From 0f195fc6088757a679cbf2ac6f429b2f347cfc1e Mon Sep 17 00:00:00 2001 From: garikbesson Date: Fri, 28 Nov 2025 10:04:41 +0000 Subject: [PATCH 1/2] remove go language --- docs/smart-contracts/quickstart.md | 119 ----------------------------- 1 file changed, 119 deletions(-) diff --git a/docs/smart-contracts/quickstart.md b/docs/smart-contracts/quickstart.md index d95ef608871..f47f0dcb87d 100644 --- a/docs/smart-contracts/quickstart.md +++ b/docs/smart-contracts/quickstart.md @@ -105,41 +105,6 @@ curl -LsSf https://astral.sh/uv/install.sh | sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh ``` - - - -```bash -# Install Go (version <= 1.23.9) using GVM: https://github.com/moovweb/gvm -# or the official Go installation method: https://go.dev/doc/install - -# GVM Go installation method (recommended for managing different versions of Go) -sudo apt update -sudo apt install gcc make -sudo apt install bison -bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) -gvm install go1.23.9 -B -gvm use go1.23.9 --default - -# Install TinyGo: https://tinygo.org/getting-started/install/ - -# Linux AMD64 (x86_64) -wget https://github.com/tinygo-org/tinygo/releases/download/v0.37.0/tinygo_0.37.0_amd64.deb -sudo dpkg -i tinygo_0.37.0_amd64.deb - -# Linux ARM64 -wget https://github.com/tinygo-org/tinygo/releases/download/v0.37.0/tinygo_0.37.0_arm64.deb -sudo dpkg -i tinygo_0.37.0_arm64.deb - -# macOS -brew tap tinygo-org/tools -brew install tinygo - -# Install NEAR Go CLI to manage and interact with smart contracts easily -# Alternatively, download it from GitHub Releases and move it manually to your bin folder. - -curl -LO https://github.com/vlmoon99/near-cli-go/releases/latest/download/install.sh && bash install.sh - -``` @@ -275,25 +240,6 @@ Ensure you have [Emscripten](https://emscripten.org/) properly installed and ava ::: - - - -Create a new project using `near-go create`: - -```bash -near-go create -p "hello-world" -m "github.com/near/hello-world" -t "smart-contract-empty" -cd hello-world/contract -``` - -This creates a Go project with the following structure: - -```bash -hello-world/contract -├── go.mod -├── go.sum -└── main.go -``` - @@ -330,15 +276,6 @@ The `Hello World` smart contract stores a greeting in its state, and exposes two url="https://github.com/near-examples/hello-near-examples/blob/main/contract-py/contract.py" start="3" end="30" /> - - - - Edit a `main.go` file for your contract: - - - @@ -394,34 +331,6 @@ Building and testing the contract is as simple as running the `test` command. Th ::: - - - - Create a test file for your contract (make sure you are inside the hello-world/contract directory) : - - ```bash - # Create a tests directory - touch main_test.go - ``` - - Add the following content to `main_test.go`: - - - - Run the test (make sure you are inside the hello-world/contract directory): - - ```bash - # Test package level - near-go test package - - # Test project level - near-go test project - ``` - - - In the background, these commands are calling the build tools for each language and using a [Sandbox](./testing/integration-test.md) to test the contract. @@ -550,12 +459,6 @@ When you are ready to create a build of the contract run a one-line command depe ::: - - - ```bash - near-go build - ``` - --- @@ -623,28 +526,6 @@ Having our account created, we can now deploy the contract: - - - - ```bash - #Run (make sure you are inside the hello-world/contract directory) - - near-go build && near-go deploy -id "" -n "testnet" - ``` - - - ```bash - near deploy ./main.wasm - ``` - - - ```bash - near contract deploy use-file ./main.wasm without-init-call network-config testnet sign-with-keychain send - ``` - - - - **Congrats**! Your contract now lives in the NEAR testnet network. From a6ee578b8e61862e46b8250772f531c507411277 Mon Sep 17 00:00:00 2001 From: garikbesson Date: Fri, 28 Nov 2025 12:07:20 +0000 Subject: [PATCH 2/2] update tutorial with a new code template, add disclaimer about Python tutorial --- docs/smart-contracts/quickstart.md | 233 +++++++++++++++++++++++------ 1 file changed, 189 insertions(+), 44 deletions(-) diff --git a/docs/smart-contracts/quickstart.md b/docs/smart-contracts/quickstart.md index f47f0dcb87d..0c83b982f91 100644 --- a/docs/smart-contracts/quickstart.md +++ b/docs/smart-contracts/quickstart.md @@ -5,14 +5,14 @@ sidebar_label: Quickstart description: "Create your first contract using your favorite language." --- -import {Github} from '@site/src/components/UI/Codetabs'; +import {Github, Language} from '@site/src/components/UI/Codetabs'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import MovingForwardSupportSection from '@site/src/components/MovingForwardSupportSection'; Welcome! [NEAR accounts](../protocol/account-model.md) can store small apps known as smart contracts. In this quick tutorial, we will guide you in creating your first contract on the NEAR **testnet**! -Join us in creating a friendly contract that stores a greeting, and exposes functions to interact with it. +Join us in creating a friendly auction contract, which allows users to place bids, track the highest bidder and claim tokens at the end of the auction. :::tip Want to jump right into the code without setting up a local dev environment? @@ -72,7 +72,13 @@ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/release -```bash +:::note +Python quickstart tutorial is coming soon! + +In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. +::: + + @@ -183,6 +189,7 @@ hello-near ├── tests # sandbox testing │ └── test_basics.rs ├── Cargo.toml # package manager +├── Cargo.lock # package lock file ├── README.md └── rust-toolchain.toml ``` @@ -207,7 +214,13 @@ You can skip the interactive menu and create a new project with specific name ru -```bash +:::note +Python quickstart tutorial is coming soon! + +In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. +::: + + @@ -249,33 +262,38 @@ Ensure you have [Emscripten](https://emscripten.org/) properly installed and ava ## The Contract -The `Hello World` smart contract stores a greeting in its state, and exposes two functions to interact with it: -1. `set_greeting`: to change the greeting -2. `get_greeting`: to fetch the greeting +The auction smart contract allows users to place bids, track the highest bidder and claim tokens at the end of the auction. Therefore it exposes following methods to interact with it: +1. `init`: to initialize the contract with auction parameters +2. `bid`: to place a bid in the auction +3. `claim`: to claim tokens after the auction ends +4. `get_highest_bid`: to fetch the highest bid and bidder information +5. `get_auction_end_time`: to retrieve the auction end time +6. `get_auctioneer`: to get the auctioneer's account ID +7. `get_claimed`: to check if a bidder has claimed their tokens - - + url="https://github.com/near/create-near-app/blob/V9/templates/contracts/auction/ts/src/contract.ts" + start="9" end="72" /> - - + url="https://github.com/near/cargo-near/blob/update-new-template/cargo-near/src/commands/new/new-project-template/src/lib.rs" + start="23" end="103" /> + :::note + Python quickstart tutorial is coming soon! - + In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. + ::: + @@ -316,7 +334,13 @@ Building and testing the contract is as simple as running the `test` command. Th - ```bash + :::note + Python quickstart tutorial is coming soon! + + In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. + ::: + + @@ -408,7 +432,7 @@ When running the near account create-account command in a headless Linux environ When you are ready to create a build of the contract run a one-line command depending on your environment. - + ```bash @@ -434,7 +458,13 @@ When you are ready to create a build of the contract run a one-line command depe - ```bash + :::note + Python quickstart tutorial is coming soon! + + In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. + ::: + + @@ -508,7 +538,13 @@ Having our account created, we can now deploy the contract: - + :::note + Python quickstart tutorial is coming soon! + + In the meantime, please check out the [hello-near](https://github.com/near-examples/hello-near-examples/tree/main/contract-py) example. + ::: + + @@ -538,47 +574,47 @@ To interact with your deployed smart contract, you can call its functions throug
-#### Get Greeting -Let's start by fetching the greeting stored in the contract. The `get_greeting` function only reads from the contract's state, and can thus be called for **free**. +#### Initialize the Contract +Let's start by initializing the contract with the auction parameters. The `init` method sets up the auction with an end time and the auctioneer's account ID. It can be called only by contract's account itself. ```bash - > near view get_greeting - # "Hello, NEAR world!" + > near call init '{"end_time": "", "auctioneer": ""}' --accountId ``` ```bash - > near contract call-function as-read-only get_greeting json-args {} network-config testnet now - # "Hello, NEAR world!" + > near contract call-function as-transaction init json-args '{"end_time": "", "auctioneer": ""}' prepaid-gas '30.0 Tgas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send ``` +:::note + `` should be replaced with the account ID of the auctioneer, which can be the same as `` or a different account. +::: +
-#### Set Greeting +#### Place a Bid -We can now change the greeting stored in the contract. The `set_greeting` method writes on the contract's [storage](./anatomy/storage.md), and thus requires a user to sign a transaction in order to be executed. +We can now place a bid in the auction using the `bid` method. This method allows users to place their bids by attaching a deposit. The highest bid and bidder information will be updated accordingly and will be stored on the contract's [storage](./anatomy/storage.md), and thus requires a user to sign a transaction in order to be executed (as well as attaching a deposit). ```bash - > near call set_greeting '{"greeting": "Hola"}' --accountId - # {"success": true} + > near call bid '{}' --deposit 0.01 --accountId ``` ```bash - > near contract call-function as-transaction set_greeting json-args '{"greeting": "Hola"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send - # {"success": true} + > near contract call-function as-transaction bid json-args {} prepaid-gas '30.0 Tgas' attached-deposit '0.01 NEAR' sign-as network-config testnet sign-with-keychain send ``` @@ -589,6 +625,115 @@ Notice that we are signing the transaction using ``, so in this ::: +
+ +#### Claim + +After the auction ends, the highest bidder can claim their tokens using the `claim` method. Actually, anyone can call this method on behalf of the highest bidder to transfer the tokens to them. This method requires a signed transaction but does not require any deposit. + + + + + ```bash + > near call claim '{}' --accountId + ``` + + + + + ```bash + > near contract call-function as-transaction claim json-args {} prepaid-gas '30.0 Tgas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send + ``` + + + +
+ +#### Get Highest Bid + +The `get_highest_bid` function only reads from the contract's state, and can thus be called for **free**. + + + + + ```bash + > near view get_highest_bid '{}' + ``` + + + + + ```bash + > near contract call-function as-read-only get_highest_bid json-args {} network-config testnet now + ``` + + + +
+ +#### Get Auction End Time + +Same as `get_highest_bid`, the `get_auction_end_time` function only reads from the contract's state, and can thus be called for **free**. + + + + + ```bash + > near view get_auction_end_time '{}' + ``` + + + + + ```bash + > near contract call-function as-read-only get_auction_end_time json-args {} network-config testnet now + ``` + + + +
+ +#### Get Auctioneer + +Same as `get_highest_bid`, the `get_auctioneer` function only reads from the contract's state, and can thus be called for **free**. + + + + + ```bash + > near view get_auctioneer '{}' + ``` + + + + + ```bash + > near contract call-function as-read-only get_auctioneer json-args {} network-config testnet now + ``` + + + +
+ +#### Get Claimed + +Same as `get_highest_bid`, the `get_claimed` function only reads from the contract's state, and can thus be called for **free**. + + + + + ```bash + > near view get_claimed '{}' + ``` + + + + + ```bash + > near contract call-function as-read-only get_claimed json-args {} network-config testnet now + ``` + + --- @@ -606,10 +751,10 @@ If you prefer to see more examples, check our [examples](/tutorials/examples/cou At the time of this writing, this example works with the following versions: -- node: `20.18.0` -- rustc: `1.81.0` -- near-cli-rs: `0.17.0` -- cargo-near: `0.13.2` +- node: `22.18.0` +- rustc: `1.86.0` +- near-cli-rs: `0.22.0` +- cargo-near: `0.16.1` - Python: `3.13` - near-sdk-py: `0.7.3` - uvx nearc: `0.9.2`