Skip to main content

1. Create an Account

Go to 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.
Sign up screen

2. Create a Project

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

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:
// 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.
Compilation output

5. Deploy

Click Deploy to send your contract to the blockchain.
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!
Testnet deploy dialog

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
Testnet (Playground Mode): No wallet connection needed. You can freely call any function - both view and change methods - using the playground wallet.
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.
Contract interface
Try calling get_greeting to see the default value, then use set_greeting to change it!