> ## Documentation Index
> Fetch the complete documentation index at: https://docs.near.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Your First Smart Contract

> Create your first contract using your favorite language.

export const Github = ({url, start, end, fname, withSourceLink = true}) => {
  const [code, setCode] = useState(null);
  function toRaw(ref) {
    const fullUrl = ref.slice(ref.indexOf('https'));
    const [url] = fullUrl.split('#');
    const [org, repo, , branch, ...pathSeg] = new URL(url).pathname.split('/').slice(1);
    return `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${pathSeg.join('/')}`;
  }
  async function fetchCode(url, fromLine, toLine) {
    let res;
    if (typeof window !== 'undefined') {
      const validUntil = localStorage.getItem(`${url}-until`);
      if (validUntil && Number(validUntil) > Date.now()) {
        res = localStorage.getItem(url);
      }
    }
    if (!res) {
      try {
        res = await (await fetch(url)).text();
        if (typeof window !== 'undefined') {
          localStorage.setItem(url, res);
          localStorage.setItem(`${url}-until`, String(Date.now() + 60000));
        }
      } catch {
        return 'Error fetching code, please try reloading';
      }
    }
    let body = res.split('\n');
    const from = fromLine ? Number(fromLine) - 1 : 0;
    const to = toLine ? Number(toLine) : body.length;
    body = body.slice(from, to);
    const precedingSpace = body.reduce((prev, line) => {
      if (line.length === 0) return prev;
      const spaces = line.match(/^\s+/);
      if (spaces) return Math.min(prev, spaces[0].length);
      return 0;
    }, Infinity);
    return body.map(line => line.slice(precedingSpace === Infinity ? 0 : precedingSpace)).join('\n');
  }
  function buildSourceUrl(url, start, end) {
    const base = url.split('#')[0];
    if (start && end) return `${base}#L${start}-L${end}`;
    if (start) return `${base}#L${start}`;
    return base;
  }
  useEffect(() => {
    const rawUrl = toRaw(url);
    fetchCode(rawUrl, start, end).then(res => setCode(res));
  }, [url, start, end]);
  const sourceUrl = buildSourceUrl(url, start, end);
  const startLine = start ? Number(start) : 1;
  const fileName = fname ?? sourceUrl.split('/').pop();
  return <div className="rounded-[0.625rem] border border-[#d0d7de] dark:border-[#30363d] overflow-hidden my-5 text-[0.8125rem] font-mono shadow-sm dark:shadow-[0_4px_24px_rgba(0,0,0,0.18)]">

      {}
      <div className="flex items-center justify-between py-2 px-[0.875rem] bg-[#f6f8fa] dark:bg-[#161b22] border-b border-[#d0d7de] dark:border-[#30363d]">
        <div className="flex items-center gap-2 text-[#656d76] dark:text-[#8b949e]">
          <svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor">
            <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
          </svg>
          <span className="text-xs font-medium text-[#1f2328] dark:text-[#e6edf3]">
            {fileName}
          </span>
        </div>
        {start && end && <span className="text-[0.6875rem] text-[#656d76] dark:text-[#8b949e] bg-[#eaeef2] dark:bg-[#21262d] border border-[#d0d7de] dark:border-[#30363d] rounded-full py-0.5 px-2">
            Lines {start}–{end}
          </span>}
      </div>

      {}
      <div className="overflow-auto max-h-[480px] bg-white dark:bg-[#0d1117] [&_tr]:border-b-0 [&_td]:border-b-0">
        {code === null ? <div className="py-5 px-4 text-xs text-[#656d76] dark:text-[#6e7681]">
            Loading...
          </div> : <table className="w-full border-collapse leading-[1.6]">
            <tbody>
              {code.split('\n').map((line, i) => <tr key={i} className="align-top border-0">
                  <td style={{
    minWidth: '60px'
  }} className="select-none pl-2 pr-3 text-right text-[0.7rem] text-[#8c959f] dark:text-[#3d444d] w-[1%] whitespace-nowrap border-r border-0 border-r-[#d0d7de] dark:border-r-[#21262d]">
                    {startLine + i}
                  </td>
                  <td className="pl-4 pr-6 text-[0.8125rem] text-[#1f2328] dark:text-[#e6edf3] whitespace-pre">
                    {line || ' '}
                  </td>
                </tr>)}
            </tbody>
          </table>}
      </div>

      {}
      {withSourceLink && <div className="flex justify-end py-1.5 px-[0.875rem] bg-[#f6f8fa] dark:bg-[#161b22] border-t border-[#d0d7de] dark:border-[#21262d]">
          <a href={sourceUrl} target="_blank" rel="noreferrer noopener" className="text-[0.6875rem] font-medium text-[#656d76] dark:text-[#8b949e] no-underline flex items-center gap-[0.3rem] hover:text-[#1f2328] dark:hover:text-[#e6edf3] transition-colors">
            View on GitHub
            <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
              <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
              <polyline points="15 3 21 3 21 9" />
              <line x1="10" y1="14" x2="21" y2="3" />
            </svg>
          </a>
        </div>}
    </div>;
};

Welcome! [NEAR accounts](../protocol/accounts-contracts/account-model) 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 auction contract, which allows users to place bids, track the highest bidder and claim tokens at the end of the auction.

<Tip>
  **Which language should I use?**

  In this tutorial we provide instructions to create contracts in multiple languages.

  We **strongly recommend using [Rust](https://www.rust-lang.org/)** for production apps — it offers the most mature tooling, best performance, and the strongest safety guarantees when handling real assets. If you are prototyping or learning, feel free to use **JavaScript**, **Python**, or **Go**!
</Tip>

<Accordion title="Prefer an online IDE?">
  Want to jump right into the code without setting up a local dev environment?

  Check out [NEAR Playground](https://nearplay.app/) for an easy-to-use online IDE with pre-configured templates.

  <img src="https://mintcdn.com/neardocs/qO2GD-gji1aakHqN/assets/docs/smart-contracts/NEAR-Playground.png?fit=max&auto=format&n=qO2GD-gji1aakHqN&q=85&s=86ab27aecb541051be7f535eec46aa92" alt="NEAR Playground" width="1351" height="1078" data-path="assets/docs/smart-contracts/NEAR-Playground.png" />

  [![Try a Counter Example in NearPlay](https://img.shields.io/badge/Open%20in%20NearPlay-14b8a6?style=for-the-badge\&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0ibTE4IDcgNCA0LTQgNE00IDEybDQgNC00LTQgNC00Ii8+PC9zdmc+\&logoColor=white)](https://nearplay.app/embed/3450a8a0-57dc-4d3a-b5d0-7bed58a0c2a9)
</Accordion>

***

## Prerequisites

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

<Tabs>
  <Tab title="🦀 Rust">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # 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 NEAR CLI-RS 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
    ```
  </Tab>

  <Tab title="🌐 JavaScript">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # Install Node.js using nvm (more options in: https://nodejs.org/en/download)
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    nvm install latest

    # ⚠️ For Mac Silicon users only, Rosetta is needed to compile contracts
    # /usr/sbin/softwareupdate --install-rosetta --agree-to-license

    # Install NEAR CLI to deploy and interact with the contract
    npm install -g near-cli-rs@latest
    ```
  </Tab>

  <Tab title="🐍 Python">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # Install Python (if not already installed)
    # Use your system's package manager or download from https://www.python.org/downloads/

    # Install Emscripten (required for compiling Python contracts to WebAssembly)
    # For Linux/macOS:
    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk
    ./emsdk install latest
    ./emsdk activate latest
    source ./emsdk_env.sh
    # Add to your .bashrc or .zshrc for permanent installation:
    # echo 'source "/path/to/emsdk/emsdk_env.sh"' >> ~/.bashrc
    cd ..

    # For Windows:
    # Download and extract: https://github.com/emscripten-core/emsdk
    # Then in Command Prompt:
    # cd emsdk
    # emsdk install latest
    # emsdk activate latest
    # emsdk_env.bat

    # Verify installation with:
    emcc --version

    # Install uv for Python package management
    curl -LsSf https://astral.sh/uv/install.sh | sh

    # Install NEAR CLI-RS 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
    ```
  </Tab>

  <Tab title="🐹 GO">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    #For Linux arm/x64
    sudo apt update && sudo apt upgrade -y
    sudo apt install -y build-essential curl wget git libssl-dev pkg-config checkinstall
    sudo apt install bison

    #For Mac
    xcode-select --install
    brew update
    brew install mercurial
    brew install binaryen

    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    gvm install go1.25.4 -B
    gvm use go1.25.4 --default

    curl -LO https://github.com/vlmoon99/near-cli-go/releases/latest/download/install.sh && bash install.sh
    ```
  </Tab>
</Tabs>

***

## Creating the Contract

Create a smart contract by using one of the scaffolding tools and following their instructions:

<Tabs>
  <Tab title="🦀 Rust">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cargo near
    ```

    <img src="https://mintcdn.com/neardocs/qO2GD-gji1aakHqN/assets/docs/smart-contracts/hello-near-rs.gif?s=c99cfef45ddbad5bce160e2a7e405d5d" alt="img" width="1702" height="1120" data-path="assets/docs/smart-contracts/hello-near-rs.gif" />

    *Creating a project using `cargo near new`*
  </Tab>

  <Tab title="🌐 JavaScript">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    npx create-near-app@latest
    ```

    <img src="https://mintcdn.com/neardocs/qO2GD-gji1aakHqN/assets/docs/smart-contracts/hello-near-ts.gif?s=96ae390336fd4eaf250d9db76eb703a1" alt="img" width="1342" height="926" data-path="assets/docs/smart-contracts/hello-near-ts.gif" />

    *Creating a project using `npx create-near-app@latest`*

    <Note>
      When prompted to choose a template, select the basic `Auction` template to scaffold the auction contract
    </Note>
  </Tab>

  <Tab title="🐍 Python">
    <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.
    </Note>
  </Tab>

  <Tab title="🐹 GO">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near-go create --project-name auction --module-name auction --project-type smart-contract-empty
    ```

    *Creating a project using `near-go create`*

    This will generate a project with the following structure:

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    auction/
    └── contract/
        ├── go.mod    # Go module definition with near-sdk-go dependency
        ├── go.sum
        └── main.go   # Main contract file — replace this with the auction contract below
    ```

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cd auction/contract
    ```

    <Important>
      Replace the contents of `main.go` with the auction contract code shown in the sections below.
    </Important>
  </Tab>
</Tabs>

<Tip>
  For this tutorial we chose to name the project `auction`, but feel free to use any name you prefer
</Tip>

***

## Anatomy of the Contract

The auction smart contract allows users to place bids, track the highest bidder and claim tokens at the end of the auction.

Let's take a look at the different components of the contract and how they work together to implement this functionality.

### Contract State & Initialization

The contract stores the highest bid, auction end time, auctioneer address, and a flag to track if proceeds have been claimed. In order to set these parameters, an `init` function is provided, which must be called first to initialize the contract state.

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.rs" language="rust" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-rs/01-basic-auction/src/lib.rs" start="7" end="35" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-ts/01-basic-auction/src/contract.ts" start="5" end="21" />
  </Tab>

  <Tab title="🐍 Python">
    <Github fname="contract.py" language="python" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-py/01-basic-auction/contract.py" start="1" end="18" />
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/auction/main.go" start="11" end="40" />
  </Tab>
</Tabs>

### Placing Bids

In order to place a bid, users will need to call the `bid` function while attaching a deposit representing their bid amount.

The `bid` function will then validate that the auction is ongoing, if the user bid a higher amount than the one stored, it will record the new bid and refund the previous bidder.

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.rs" language="rust" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-rs/01-basic-auction/src/lib.rs" start="37" end="64" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-ts/01-basic-auction/src/contract.ts" start="23" end="43" />
  </Tab>

  <Tab title="🐍 Python">
    <Github fname="contract.py" language="python" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-py/01-basic-auction/contract.py" start="20" end="45" />
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/auction/main.go" start="42" end="78" />
  </Tab>
</Tabs>

### Claiming Proceeds

Once the auction ends, any user can call `claim` to transfer the winning bid to the auctioneer:

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.rs" language="rust" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-rs/01-basic-auction/src/lib.rs" start="65" end="76" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-ts/01-basic-auction/src/contract.ts" start="45" end="52" />
  </Tab>

  <Tab title="🐍 Python">
    <Github fname="contract.py" language="python" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-py/01-basic-auction/contract.py" start="47" end="59" />
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/auction/main.go" start="80" end="101" />
  </Tab>
</Tabs>

### View Methods

At all times, users can query the current state of the auction by calling its view methods (`get_highest_bid`, `get_auction_end_time`, `get_auctioneer`, `get_claimed`):

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.rs" language="rust" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-rs/01-basic-auction/src/lib.rs" start="78" end="92" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-ts/01-basic-auction/src/contract.ts" start="54" end="71" />
  </Tab>

  <Tab title="🐍 Python">
    <Github fname="contract.py" language="python" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-py/01-basic-auction/contract.py" start="62" end="90" />
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/auction/main.go" start="103" end="121" />
  </Tab>
</Tabs>

***

## Test the Contract

Lets make sure the contract is working as expected by running its tests. Simply run the `test` command, the contract will then be compiled and deployed to a local sandbox for testing:

<Tabs>
  <Tab title="🦀 Rust">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cargo test
    ```
  </Tab>

  <Tab title="🌐 JavaScript">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    npm run test
    ```

    <Accordion title="Failing tests?">
      Make sure that you are using `node v24 / 22 / 20`, and that you have installed `Rosetta` if you have a Mac with Apple Silicon
    </Accordion>
  </Tab>

  <Tab title="🐍 Python">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    uv run pytest
    ```
  </Tab>

  <Tab title="🐹 GO">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near-go test project
    ```
  </Tab>
</Tabs>

Feel free to check the test files to see how they interact with the contract. In short, a local NEAR sandbox is created, the contract is deployed, and different methods are called to verify the expected behavior.

***

## Build & Deploy the Contract

Now that we know the tests are passing, let us deploy the contract! First, we need to compile it into WebAssembly:

<Tabs>
  <Tab title="🦀 Rust">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cargo near build non-reproducible-wasm
    ```
  </Tab>

  <Tab title="🌐 JavaScript">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    npm run build
    ```
  </Tab>

  <Tab title="🐍 Python">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # Build with nearc through the uv executor (no installation needed)
    uvx nearc contract.py
    ```

    The above command will compile your Python contract into WebAssembly (WASM) that can be deployed to the NEAR blockchain.

    <Info>
      The default `nearc` build configuration is appropriate for most contracts. You don't need to install nearc separately as we're using `uvx` to run it directly.
    </Info>

    <Important>
      This step requires [Emscripten](https://emscripten.org/) to be installed and accessible in your `PATH`. If you encounter errors during compilation, verify that Emscripten is properly installed with `emcc --version`.

      Common compilation errors and solutions:

      * `emcc: command not found` - Emscripten is not in your PATH. Run `source /path/to/emsdk/emsdk_env.sh` to add it temporarily.
      * `error: invalid version of emscripten` - Your Emscripten version might be too old. Try updating with `./emsdk install latest && ./emsdk activate latest`.
      * `Could not find platform micropython-dev-wasm32` - This typically means the Emscripten installation is incomplete or not properly activated.
    </Important>
  </Tab>

  <Tab title="🐹 GO">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near-go build
    ```

    <Info>
      **Near Go SDK Build Process**

      1. All code from the main package, including imports from other modules, is combined into a single **generated\_build.go** file.
      2. The **generated\_build.go** file is compiled into `wasm32-unknown-unknown` via **TinyGo**.
    </Info>

    <Info>
      **Customizing the Build**

      The default `near-go build` command works for most standard projects, compiling source code from the current directory into `main.wasm`.

      However, if you want to specify a custom output name or **inspect the intermediate glue code** (generated JSON serialization and SDK integration wrappers) for debugging purposes, you can use the available flags:

      ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
      near-go build --output my_contract.wasm --keep-generated
      ```
    </Info>
  </Tab>
</Tabs>

### Create an Account

Let us now create a NEAR account where we will deploy the contract:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Replace <contract-acc.testnet> with a name for your contract account
near create-account <contract-acc.testnet> --useFaucet
```

<Tip>
  **Already have a testnet account?**

  If you already have a `testnet` account and would like to use it instead, you can log in with the command `near login`.
</Tip>

<Accordion title="Got an error on Windows?">
  When working on `WSL` - or any other headless Linux environment - you might encounter issues when trying to create an account as the `cli` tries to save the keys into the system's keychain.

  In such cases, you can try the following command to create the account:

  ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  near account create-account sponsor-by-faucet-service <your-account-id.testnet> autogenerate-new-keypair save-to-legacy-keychain network-config testnet create
  ```
</Accordion>

### Deploy it!

With the contract ready, we can now deploy it to the `testnet` account we created earlier:

<Tabs>
  <Tab title="🦀 Rust">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near deploy <contract-acc.testnet> ./target/near/auction.wasm
    ```
  </Tab>

  <Tab title="🌐 JavaScript">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near deploy <contract-acc.testnet> ./build/auction.wasm
    ```
  </Tab>

  <Tab title="🐍 Python">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near deploy <created-account> ./auction.wasm
    ```
  </Tab>

  <Tab title="🐹 GO">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near deploy <contract-acc.testnet> ./main.wasm
    ```
  </Tab>
</Tabs>

**Congrats!** Your contract now lives in the NEAR testnet network.

***

## Interacting with the Contract

To interact with your deployed smart contract, you can call its functions through the command line.

#### Initialize the Contract

Let us initialize the auction by setting when it ends and who receives the funds (the auctioneer):

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Get a timestamp for 5 minutes from now (in nanoseconds)
FIVE_MINUTES_FROM_NOW=$(( $(date +%s%N) + 5 * 60 * 1000000000 ))

# Initialize the auction
near call <contract-acc.testnet> init "{\"end_time\": \"$FIVE_MINUTES_FROM_NOW\", \"auctioneer\": \"influencer.testnet\"}" --useAccount <contract-acc.testnet>
```

<Tip>
  Feel free to replace `influencer.testnet` with any valid testnet account — this is where the winning bid will be sent
</Tip>

#### Place a Bid

We can now place a bid in the auction by calling the `bid` method while attaching some NEAR deposit. On each bid, the highest bid and bidder information will be recorded in the contract's [storage](./anatomy/storage).

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Create a new account to place the bid
near create-account <bidder-account.testnet> --useFaucet

# Place a bid of 0.01 NEAR
near call <contract-acc.testnet> bid '{}' --deposit 0.01  --useAccount <bidder-account.testnet>
```

<Note>
  Note how in this case we are using the `<bidder-account.testnet>` account (remember to rename it!) to call the `bid` function, while attaching a deposit of `0.01` NEAR as our bid
</Note>

#### Get Highest Bid

The `get_highest_bid` function only reads from the contract state, so it does not require a transaction or signature:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near view <contract-acc.testnet> get_highest_bid '{}'
```

<Accordion title="Expected Output">
  ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "bidder": "<bidder-account.testnet>",
    "amount": "10000000000000000000000"
  }
  ```
</Accordion>

<Tip>
  Feel free to create as many bidder accounts as you want and place more bids to see how the highest bid changes!
</Tip>

#### Claim

After the auction ends, anyone can call the `claim` method, which will transfer the `highest bid` amount to the auctioneer and end the auction.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near call <contract-acc.testnet> claim '{}' --useAccount <contract-acc.testnet>
```

<Info>
  **Who won?**

  After the auction ends, the highest bidder can be determined by simply calling the `get_highest_bid` method again
</Info>

***

## Common Questions

#### What about mainnet?

You can deploy a contract to mainnet using the same commands, just make sure to create a mainnet account and use `--networkId mainnet` flag in the `near` CLI commands.

#### How much does it cost to deploy?

The cost of deploying a contract depends on the contract's size, approximately 1Ⓝ \~100Kb.

#### Can I update a contract after deploying?

Yes. Redeploy with `near deploy <account> <wasm-file>`. The account stays the same, code updates.

#### Which language should I choose?

We **strongly recommend [Rust](https://www.rust-lang.org/)** for production apps — it provides the most mature tooling, best performance, and strongest safety guarantees when handling real assets on-chain. If you are prototyping or learning, you can use **JavaScript**, **Python**, or **Go**.

#### How do I test without deploying?

All languages support sandbox testing (shown in this guide). Tests run locally with a simulated NEAR environment.

***

## Moving Forward

<CardGroup cols={3}>
  <Card title="Create a Frontend" href="../web3-apps/tutorials/mastering-near/2.1-frontend">
    Check the auction frontend tutorial to learn how to build a simple web app that interacts with the auction contract
  </Card>

  <Card title="Extend the Contract" href="../web3-apps/tutorials/mastering-near/3.1-nft">
    Follow the auction NFT tutorial to award the highest bidder a Non-Fungible Token (NFT) and allow users to bid using Fungible Tokens (FT)
  </Card>

  <Card title="Learn More about the SDK" href="./anatomy/anatomy">
    Check our Anatomy of a Contract page to understand the different components that make up a NEAR smart contract
  </Card>
</CardGroup>

<br />

<Accordion title="Versioning for this article">
  At the time of this writing, this example works with the following versions:

  * 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`
  * emscripten: `4.0.9` (required for Python contracts)
  * Go: `1.25.4`
  * near-go (near-cli-go): `v0.1.1`
  * near-sdk-go: `v0.1.1`
</Accordion>
