diff --git a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/relayer-gas-example.md b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/relayer-gas-example.md
index bd1983f8453..0fe8dcf124a 100644
--- a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/relayer-gas-example.md
+++ b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/relayer-gas-example.md
@@ -96,7 +96,7 @@ Python and Rust output different hex RLP encoded transactions.
+ start="24" end="38" />
diff --git a/docs/2.build/2.smart-contracts/anatomy/actions.md b/docs/2.build/2.smart-contracts/anatomy/actions.md
index 9c4f11fb67b..56d29792e34 100644
--- a/docs/2.build/2.smart-contracts/anatomy/actions.md
+++ b/docs/2.build/2.smart-contracts/anatomy/actions.md
@@ -41,16 +41,15 @@ You can send $NEAR from your contract to any other account on the network. The G
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
- use near_sdk::{near_bindgen, AccountId, Promise, Balance};
+ use near_sdk::{near, AccountId, Promise, NearToken};
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
#[near_bindgen]
impl Contract {
- pub fn transfer(&self, to: AccountId, amount: Balance){
+ pub fn transfer(&self, to: AccountId, amount: NearToken){
Promise::new(to).transfer(amount);
}
}
@@ -125,12 +124,11 @@ right in the callback.
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{near_bindgen, env, log, Promise, Gas, PromiseError};
use serde_json::json;
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
const HELLO_NEAR: &str = "hello-nearverse.testnet";
@@ -205,16 +203,15 @@ Sub-accounts are simply useful for organizing your accounts (e.g. `dao.project.n
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
- use near_sdk::{near_bindgen, env, Promise, Balance};
+ use near_sdk::{near, env, Promise, NearToken};
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
const MIN_STORAGE: Balance = 1_000_000_000_000_000_000_000; //0.001Ⓝ
- #[near_bindgen]
+ #[near]
impl Contract {
pub fn create(&self, prefix: String){
let account_id = prefix + "." + &env::current_account_id().to_string();
@@ -277,18 +274,17 @@ the `create_account` method of `near` or `testnet` root contracts.
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
- use near_sdk::{near_bindgen, Promise, Gas, Balance };
+ use near_sdk::{near, Promise, Gas, NearToken };
use serde_json::json;
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
const CALL_GAS: Gas = Gas(28_000_000_000_000);
const MIN_STORAGE: Balance = 1_820_000_000_000_000_000_000; //0.00182Ⓝ
- #[near_bindgen]
+ #[near]
impl Contract {
pub fn create_account(&self, account_id: String, public_key: String){
let args = json!({
@@ -317,17 +313,16 @@ When creating an account you can also batch the action of deploying a contract t
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
- use near_sdk::{near_bindgen, env, Promise, Balance};
+ use near_sdk::{near_bindgen, env, Promise, NearToken};
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
const MIN_STORAGE: Balance = 1_100_000_000_000_000_000_000_000; //1.1Ⓝ
const HELLO_CODE: &[u8] = include_bytes!("./hello.wasm");
- #[near_bindgen]
+ #[near]
impl Contract {
pub fn create_hello(&self, prefix: String){
let account_id = prefix + "." + &env::current_account_id().to_string();
@@ -462,16 +457,15 @@ There are two scenarios in which you can use the `delete_account` action:
```rust
- use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
- use near_sdk::{near_bindgen, env, Promise, Balance, AccountId};
+ use near_sdk::{near, env, Promise, Neartoken, AccountId};
- #[near_bindgen]
- #[derive(Default, BorshDeserialize, BorshSerialize)]
+ #[near(contract_state)]
+ #[derive(Default)]
pub struct Contract { }
const MIN_STORAGE: Balance = 1_000_000_000_000_000_000_000; //0.001Ⓝ
- #[near_bindgen]
+ #[near]
impl Contract {
pub fn create_delete(&self, prefix: String, beneficiary: AccountId){
let account_id = prefix + "." + &env::current_account_id().to_string();
diff --git a/docs/2.build/2.smart-contracts/anatomy/crosscontract.md b/docs/2.build/2.smart-contracts/anatomy/crosscontract.md
index 963e245c502..ef3543ba9cf 100644
--- a/docs/2.build/2.smart-contracts/anatomy/crosscontract.md
+++ b/docs/2.build/2.smart-contracts/anatomy/crosscontract.md
@@ -33,9 +33,10 @@ While making your contract, it is likely that you will want to query information
+ start="22" end="51" />
+ url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/external.rs"
+ start="2" end="12" />
@@ -57,9 +58,10 @@ Calling another contract passing information is also a common scenario. Bellow y
+ start="53" end="80" />
+ url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/external.rs"
+ start="2" end="12" />
diff --git a/docs/2.build/2.smart-contracts/quickstart.md b/docs/2.build/2.smart-contracts/quickstart.md
index 5257fdf8f67..6c115cea045 100644
--- a/docs/2.build/2.smart-contracts/quickstart.md
+++ b/docs/2.build/2.smart-contracts/quickstart.md
@@ -158,7 +158,7 @@ Your new smart contract stores a `greeting: string` attribute in their state, an
+ start="4" end="32" />
diff --git a/docs/3.tutorials/examples/count-near.md b/docs/3.tutorials/examples/count-near.md
index f95b192cb37..bc9fa1a196f 100644
--- a/docs/3.tutorials/examples/count-near.md
+++ b/docs/3.tutorials/examples/count-near.md
@@ -125,7 +125,7 @@ The contract presents 4 methods: `get_num`, `increment`, `decrement`, and `reset
+ start="5" end="37" />
diff --git a/docs/3.tutorials/examples/donation.md b/docs/3.tutorials/examples/donation.md
index 7ac8b4558c0..9f5ec92cbc4 100644
--- a/docs/3.tutorials/examples/donation.md
+++ b/docs/3.tutorials/examples/donation.md
@@ -117,7 +117,7 @@ NEAR wallet to accept a transaction.
## Smart Contract
-The contract exposes methods to donate tokens (`donate`), and methods to retrieve the recorded donations (e.g. `get_donation_by_number`).
+The contract exposes methods to donate tokens (`donate`), and methods to retrieve the recorded donations (e.g. `get_donation_for_account`).
@@ -128,7 +128,7 @@ The contract exposes methods to donate tokens (`donate`), and methods to retriev
+ start="17" end="74" />
diff --git a/docs/3.tutorials/examples/xcc.md b/docs/3.tutorials/examples/xcc.md
index 28b06cd376b..84b14312164 100644
--- a/docs/3.tutorials/examples/xcc.md
+++ b/docs/3.tutorials/examples/xcc.md
@@ -87,9 +87,10 @@ The contract exposes methods to query the greeting and change it. These methods
+ start="22" end="51" />
+ url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/external.rs"
+ start="2" end="12" />
diff --git a/docs/sdk/rust/contract-structure/collections.md b/docs/sdk/rust/contract-structure/collections.md
index 8683a8bf1e3..c61ccd60867 100644
--- a/docs/sdk/rust/contract-structure/collections.md
+++ b/docs/sdk/rust/contract-structure/collections.md
@@ -53,13 +53,13 @@ Example of `HashMap`:
```rust
/// Using Default initialization.
-#[near_bindgen]
-#[derive(BorshDeserialize, BorshSerialize, Default)]
+#[near(contract_state)]
+#[derive(Default)]
pub struct Contract {
pub status_updates: HashMap,
}
-#[near_bindgen]
+#[near]
impl Contract {
pub fn set_status(&mut self, status: String) {
self.status_updates.insert(env::predecessor_account_id(), status);
@@ -80,13 +80,13 @@ impl Contract {
Example of `UnorderedMap`:
```rust
-#[near_bindgen]
-#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
+#[near(contract_state)]
+#[derive(PanicOnDefault)]
pub struct Contract {
pub status_updates: UnorderedMap,
}
-#[near_bindgen]
+#[near]
impl Contract {
#[init]
pub fn new() -> Self {
@@ -194,13 +194,13 @@ This can be done using iterators with [`Skip`](https://doc.rust-lang.org/std/ite
Example of pagination for `UnorderedMap`:
```rust
-#[near_bindgen]
-#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
+#[near(contract_state)]
+#[derive(PanicOnDefault)]
pub struct Contract {
pub status_updates: UnorderedMap,
}
-#[near_bindgen]
+#[near]
impl Contract {
/// Retrieves multiple elements from the `UnorderedMap`.
/// - `from_index` is the index to start from.
@@ -252,21 +252,20 @@ like other persistent collections.
Compared to other collections, `LazyOption` only allows you to initialize the value during initialization.
```rust
-#[near_bindgen]
-#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
+#[near(contract_state)]
+#[derive(PanicOnDefault)]
pub struct Contract {
pub metadata: LazyOption,
}
-#[derive(Serialize, Deserialize, BorshDeserialize, BorshSerialize)]
-#[serde(crate = "near_sdk::serde")]
+#[near(serializers=[borsh, json])]
pub struct Metadata {
data: String,
image: Base64Vec,
blobs: Vec,
}
-#[near_bindgen]
+#[near]
impl Contract {
#[init]
pub fn new(metadata: Metadata) -> Self {
diff --git a/docs/sdk/rust/cross-contract/callbacks.md b/docs/sdk/rust/cross-contract/callbacks.md
index 0c9a8fb7821..420e7da228d 100644
--- a/docs/sdk/rust/cross-contract/callbacks.md
+++ b/docs/sdk/rust/cross-contract/callbacks.md
@@ -53,7 +53,7 @@ mod ext_calculator {
Let's assume the calculator is deployed on `calc.near`, we can use the following:
```rust
-#[near_bindgen]
+#[near]
impl Contract {
pub fn sum_a_b(&mut self, a: U128, b: U128) -> Promise {
let calculator_account_id: AccountId = "calc.near".parse().unwrap();
@@ -94,7 +94,7 @@ fn get_account_to_check() -> AccountId {
```
```rust
-#[near_bindgen]
+#[near]
impl Contract {
pub fn xcc_use_promise_result() -> Promise {
// Call the method `is_allowlisted` on the allowlisted contract. Static GAS is only attached to the callback.