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

# Quickstart

> Deploy your first NEAR contract in 5 minutes

## 1. Create an Account

Go to [nearplay.app](https://nearplay.app) and sign in using one of the available options:

* **GitHub** - Sign in with your GitHub account
* **Google** - Sign in with your Google account
* **Email** - Enter your email and receive a magic link (passwordless)

For email login, check your inbox and click the link to complete sign in.

<Frame>
  <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/signup.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=3cb5f4b6ccc9a6d4e0c54da84cdea0fb" alt="Sign up screen" width="4082" height="2410" data-path="images/signup.png" />
</Frame>

## 2. Create a Project

Click **New Project** and either create a blank project or choose one of the available templates.

<Frame>
  <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/new-project.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=f91e0da31e2490196707111cf0e9d513" alt="New project dialog" width="4112" height="2410" data-path="images/new-project.png" />
</Frame>

## 3. Write Your Code

The editor opens with your project code. If you created a blank project, you can paste this example into `lib.rs`:

```rust theme={null}
// Find all our documentation at https://docs.near.org
use near_sdk::{log, near};

// Define the contract structure
#[near(contract_state)]
pub struct Contract {
    greeting: String,
}

// Define the default, which automatically initializes the contract
impl Default for Contract {
    fn default() -> Self {
        Self {
            greeting: "Hello".to_string(),
        }
    }
}

// Implement the contract structure
#[near]
impl Contract {
    // Public method - returns the greeting saved, defaulting to DEFAULT_GREETING
    pub fn get_greeting(&self) -> String {
        self.greeting.clone()
    }

    // Public method - accepts a greeting, such as "howdy", and records it
    pub fn set_greeting(&mut self, greeting: String) {
        log!("Saving greeting: {}", greeting);
        self.greeting = greeting;
    }
}

/*
 * The rest of this file holds the inline tests for the code above
 * Learn more about Rust tests: https://doc.rust-lang.org/book/ch11-01-writing-tests.html
 */
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn get_default_greeting() {
        let contract = Contract::default();
        // this test did not call set_greeting so should return the default "Hello" greeting
        assert_eq!(contract.get_greeting(), "Hello");
    }

    #[test]
    fn set_then_get_greeting() {
        let mut contract = Contract::default();
        contract.set_greeting("howdy".to_string());
        assert_eq!(contract.get_greeting(), "howdy");
    }
}
```

## 4. Compile

Click the **Compile** button. This will use our backend compilation service to:

* Build your Rust code to WASM using `cargo-near`
* Show any errors with line numbers
* Display the compiled contract size

You can see detailed compilation output in the terminal panel at the bottom of the project page. Click the **expand button** in the top-right corner of the terminal to open a detailed fullscreen view.

<Frame>
  <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/compile.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=f06e93c621b16e8faffc5b1234ce1355" alt="Compilation output" width="4082" height="2410" data-path="images/compile.png" />
</Frame>

## 5. Deploy

Click **Deploy** to send your contract to the blockchain.

<Tabs>
  <Tab title="Playground (Testnet)">
    Free deployment to NEAR testnet using our pre-funded playground wallet system.

    * **No wallet connection needed** - We handle everything for you
    * **Automatically funded** - 2 NEAR is transferred to your playground wallet
    * Your contract gets a unique address like `user-project-123.nearplay.testnet`

    Perfect for development and testing!

    <Frame>
      <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/deploy-testnet.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=e6f6dc50c3e3cae5d45dacc90d4d2198" alt="Testnet deploy dialog" width="4082" height="2410" data-path="images/deploy-testnet.png" />
    </Frame>
  </Tab>

  <Tab title="External Wallet (Mainnet)">
    <Warning>
      **Important: How Mainnet Deployment Works**

      NEAR accounts cannot deploy contracts directly through web wallets. This is because wallets only expose **function-call keys** to web applications for security reasons, not the **full-access keys** required for contract deployment.

      To enable mainnet deployment, we use a **factory contract** (`factory.nearplay-app.near`). When you deploy:

      1. Connect your Meteor wallet
      2. Your contract is deployed as a sub-account of the factory (e.g., `yourname-123.factory.nearplay-app.near`)
      3. You pay the deployment cost (\~2 NEAR) from your wallet

      **Not recommended for financially critical applications.** The factory pattern means you don't have full control over the contract account. For production applications handling significant value, deploy using NEAR CLI with full-access keys.
    </Warning>

    Connect Meteor wallet to deploy with real NEAR tokens.

    <Frame>
      <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/deploy-mainnet.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=fb1d62372570ac4c360686030a5cada4" alt="Mainnet deploy dialog" width="4082" height="2410" data-path="images/deploy-mainnet.png" />
    </Frame>
  </Tab>
</Tabs>

## 6. Interact

After deployment, the **Contract Interface** tab shows your contract methods. You can use this interface to:

* Call any contract method
* View the contract address
* Open the contract on NearBlocks explorer
* See your call history on that contract

<Note>
  **Testnet (Playground Mode):** No wallet connection needed. You can freely call any function - both view and change methods - using the playground wallet.
</Note>

<Note>
  **Mainnet (External Wallet):** View methods are free to call without wallet connection. Change methods require your connected wallet to sign transactions and pay gas fees.
</Note>

<Frame>
  <img src="https://mintcdn.com/nearplay/hkzsqd_V1LyMjkBt/images/contract-ui.png?fit=max&auto=format&n=hkzsqd_V1LyMjkBt&q=85&s=f26730099ea07b33af99658bdd211a21" alt="Contract interface" width="1760" height="1686" data-path="images/contract-ui.png" />
</Frame>

Try calling **get\_greeting** to see the default value, then use **set\_greeting** to change it!
