Rust SDK
The Rust SDK for building smart contracts.
NEAR's only official smart-contract SDK is near-sdk-rs, the NEAR SDK for Rust. It provides APIs for contract state, serialization, cross-contract calls, and the NEAR runtime.
[!TIP]
The best place to start learning is our QuickStart Guide.
[card] Rust SDK
Rust SDK reference documentation.
Smart contracts on NEAR
This is how a smart contract written in Rust using the NEAR SDK looks like:
#[near(contract_state)]
pub struct Contract {
greeting: String,
}
impl Default for Contract {
fn default() -> Self {
Self { greeting: "Hello".to_string(), }
}
}
#[near]
impl Contract {
pub fn get_greeting(&self) -> String {
self.greeting.clone()
}
pub fn set_greeting(&mut self, greeting: String) {
self.greeting = greeting;
}
}
Ready to start developing?
Start from our Smart Contract QuickStart Guide, and let it guide you through all our documentation on building smart contracts.
Want to see examples?
We have a section dedicated to tutorials and examples that will help you understand diverse use cases and how to implement them.
Reference docs
If you need to find a specific function signature, or understand the SDK structs and classes, visit the Rust SDK reference.