From 5fddd606f38b55e6be20972060ef194323c2fc35 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:20:56 -0500 Subject: [PATCH 1/7] Update "Building Smart Contracts" Quickstart to use near-cli-rs Now uses near-cli-rs (https://github.com/near/near-cli-rs/issues/235) --- docs/2.develop/contracts/quickstart.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index e4a6d01d9ce..08a897575e7 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -23,18 +23,18 @@ This quickstart is dedicated to creating smart contracts. We also have one dedic Before starting, make sure you have the following installed: 1. [Node.js](https://nodejs.org/en/download), to use our scaffolding tool. -2. [NEAR CLI](/tools/near-cli#installation), to deploy and interact with the contract. +2. [NEAR CLI-RS]([/tools/near-cli-rs), to deploy and interact with the contract. 3. [cargo-near](https://github.com/near/cargo-near), to easily create testnet accounts. 4. (optional) [Rust](https://www.Rust-lang.org/tools/install), to create Rust contracts. :::tip Easy Install -Install both `near-cli` and `cargo-near` tools using `npm i -g near-cli cargo-near` +Install both `near-cli-rs` and `cargo-near` tools using `npm i -g near-cli-rs cargo-near` ::: :::info Testnet Account There is no need to have a testnet account to follow this tutorial. -However, if you want to create one, you can do so through [a wallet](https://testnet.mynearwallet.com), and use it from the `near-cli` by invoking `near login`. +However, if you want to create one, you can do so through [a wallet](https://testnet.mynearwallet.com), and use it from the `near-cli-rs` by invoking `near account`. ::: --- @@ -214,7 +214,7 @@ New account "lovely-event.testnet" created successfully. :::tip -Here we are creating a random account since we do not care about the account's name. Remember that you can create a named account through any wallet (i.e. [MyNearWallet](https://testnet.mynearwallet.com)) and then use it from the `near-cli` by invoking `near login`. +Here we are creating a random account since we do not care about the account's name. Remember that you can create a named account through any wallet (i.e. [MyNearWallet](https://testnet.mynearwallet.com)) and then use it from the `near-cli-rs` by invoking `near account`. ::: --- @@ -250,13 +250,13 @@ Having our account created, we can now deploy the contract into it: ## Interacting with the Contract -To interact with your deployed smart contract you can call its methods using the `near-cli` tool. +To interact with your deployed smart contract you can call its methods using the `near-cli-rs` tool. #### Get Greeting The `get_greeting` method is a [`view`](./anatomy.md#public-methods) method, meaning it only reads from the contract's state, and thus can be called for **free**. ```bash -> near view get_greeting +> near contract call-function as-read-only as-read-only get_greeting "Hello" # Response ``` @@ -265,12 +265,12 @@ The `get_greeting` method is a [`view`](./anatomy.md#public-methods) method, mea The `set_greeting` method is a [`change`](./anatomy.md#public-methods) method, meaning it modifies the contract's state, and thus requires a user to sign a transaction in order to be executed. ```bash -> near call set_greeting '{"greeting": "Hola"}' --accountId +> near contract call-function as-transaction set_greeting '{"greeting": "Hola"}' sign-as Log: Saving greeting "Hola" # Response ``` -In this case we are asking the account that stores the contract to call its own contract's method (`--accountId `). +In this case we are asking the account that stores the contract to call its own contract's method (`sign-as `). --- From b62dc7b3ef53ee12403770dca4900273a1423f36 Mon Sep 17 00:00:00 2001 From: gagdiez Date: Tue, 16 Jan 2024 16:31:42 +0000 Subject: [PATCH 2/7] Update docs/2.develop/contracts/quickstart.md --- docs/2.develop/contracts/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index 08a897575e7..c8b3619ed9d 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -256,7 +256,7 @@ To interact with your deployed smart contract you can call its methods using the The `get_greeting` method is a [`view`](./anatomy.md#public-methods) method, meaning it only reads from the contract's state, and thus can be called for **free**. ```bash -> near contract call-function as-read-only as-read-only get_greeting +> near contract call-function as-read-only get_greeting "Hello" # Response ``` From 78b00394b427f252bbc1a1947db9092c27d72b57 Mon Sep 17 00:00:00 2001 From: Damian Parrino Date: Wed, 17 Jan 2024 11:03:53 -0300 Subject: [PATCH 3/7] Update quickstart.md --- docs/2.develop/contracts/quickstart.md | 59 +++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index c8b3619ed9d..6799edac0c7 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -23,18 +23,23 @@ This quickstart is dedicated to creating smart contracts. We also have one dedic Before starting, make sure you have the following installed: 1. [Node.js](https://nodejs.org/en/download), to use our scaffolding tool. -2. [NEAR CLI-RS]([/tools/near-cli-rs), to deploy and interact with the contract. +2. [NEAR-CLI](/tools/near-cli#installation) or [NEAR CLI-RS]([/tools/near-cli-rs), to deploy and interact with the contract. 3. [cargo-near](https://github.com/near/cargo-near), to easily create testnet accounts. 4. (optional) [Rust](https://www.Rust-lang.org/tools/install), to create Rust contracts. :::tip Easy Install -Install both `near-cli-rs` and `cargo-near` tools using `npm i -g near-cli-rs cargo-near` + +- **NEAR-CLI:** Install both `near-cli` and `cargo-near` tools using `npm i -g near-cli cargo-near` +- **NEAR-CLI-RS:**Install both `near-cli-rs` and `cargo-near` tools using `npm i -g near-cli-rs cargo-near` + ::: :::info Testnet Account -There is no need to have a testnet account to follow this tutorial. -However, if you want to create one, you can do so through [a wallet](https://testnet.mynearwallet.com), and use it from the `near-cli-rs` by invoking `near account`. +There is no need to have a `testnet` account to follow this tutorial. + +However, if you want to create one, you can do so through [a wallet](https://testnet.mynearwallet.com), and use it from the `near-cli` by invoking `near login`. (if you prefer `near-cli-rs`, use `near account`) + ::: --- @@ -214,7 +219,9 @@ New account "lovely-event.testnet" created successfully. :::tip -Here we are creating a random account since we do not care about the account's name. Remember that you can create a named account through any wallet (i.e. [MyNearWallet](https://testnet.mynearwallet.com)) and then use it from the `near-cli-rs` by invoking `near account`. + +Here we are creating a random account since we do not care about the account's name. Remember that you can create a named account through any wallet (i.e. [MyNearWallet](https://testnet.mynearwallet.com)) and then use it from the `near-cli` by invoking `near login`. (if you prefer `near-cli-rs`, use `near account`) + ::: --- @@ -250,20 +257,56 @@ Having our account created, we can now deploy the contract into it: ## Interacting with the Contract -To interact with your deployed smart contract you can call its methods using the `near-cli-rs` tool. +To interact with your deployed smart contract you can call its methods using the `near-cli` or `near-cli-rs` tools. #### Get Greeting + The `get_greeting` method is a [`view`](./anatomy.md#public-methods) method, meaning it only reads from the contract's state, and thus can be called for **free**. + + + + +```bash +> near view get_greeting + +"Hello" # Response +``` + + + + + ```bash > near contract call-function as-read-only get_greeting "Hello" # Response ``` + + + + + #### Set Greeting + The `set_greeting` method is a [`change`](./anatomy.md#public-methods) method, meaning it modifies the contract's state, and thus requires a user to sign a transaction in order to be executed. + + + + +```bash +> near call set_greeting '{"greeting": "Hola"}' --accountId + +Log: Saving greeting "Hola" # Response +``` +In this case we are asking the account that stores the contract to call its own contract's method (`--accountId `). + + + + + ```bash > near contract call-function as-transaction set_greeting '{"greeting": "Hola"}' sign-as @@ -272,6 +315,10 @@ Log: Saving greeting "Hola" # Response In this case we are asking the account that stores the contract to call its own contract's method (`sign-as `). + + + + --- ## Moving Forward From 774708c45207b2e618491ce7d50b3090ec56c170 Mon Sep 17 00:00:00 2001 From: Damian Parrino Date: Wed, 17 Jan 2024 11:04:37 -0300 Subject: [PATCH 4/7] Update quickstart.md --- docs/2.develop/contracts/quickstart.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index 6799edac0c7..6348960f033 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -301,6 +301,7 @@ The `set_greeting` method is a [`change`](./anatomy.md#public-methods) method, m Log: Saving greeting "Hola" # Response ``` + In this case we are asking the account that stores the contract to call its own contract's method (`--accountId `). From 5dfa517de51b8046a6674ae264dfefca6e98dca1 Mon Sep 17 00:00:00 2001 From: Damian Parrino Date: Wed, 17 Jan 2024 11:31:06 -0300 Subject: [PATCH 5/7] Update quickstart.md --- docs/2.develop/contracts/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index 6348960f033..3132559e7aa 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -23,7 +23,7 @@ This quickstart is dedicated to creating smart contracts. We also have one dedic Before starting, make sure you have the following installed: 1. [Node.js](https://nodejs.org/en/download), to use our scaffolding tool. -2. [NEAR-CLI](/tools/near-cli#installation) or [NEAR CLI-RS]([/tools/near-cli-rs), to deploy and interact with the contract. +2. [NEAR-CLI](/tools/near-cli#installation) or [NEAR CLI-RS](/tools/near-cli-rs), to deploy and interact with the contract. 3. [cargo-near](https://github.com/near/cargo-near), to easily create testnet accounts. 4. (optional) [Rust](https://www.Rust-lang.org/tools/install), to create Rust contracts. From 3953e0a0998d0b4b7058ee31b0e8f45e7dddc8e6 Mon Sep 17 00:00:00 2001 From: Damian Parrino Date: Wed, 17 Jan 2024 11:33:04 -0300 Subject: [PATCH 6/7] Update quickstart.md --- docs/2.develop/contracts/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index 3132559e7aa..41bf87732e0 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -23,7 +23,7 @@ This quickstart is dedicated to creating smart contracts. We also have one dedic Before starting, make sure you have the following installed: 1. [Node.js](https://nodejs.org/en/download), to use our scaffolding tool. -2. [NEAR-CLI](/tools/near-cli#installation) or [NEAR CLI-RS](/tools/near-cli-rs), to deploy and interact with the contract. +2. [NEAR CLI](/tools/near-cli#installation) or [NEAR CLI-RS](/tools/near-cli-rs), to deploy and interact with the contract. 3. [cargo-near](https://github.com/near/cargo-near), to easily create testnet accounts. 4. (optional) [Rust](https://www.Rust-lang.org/tools/install), to create Rust contracts. From 6a8c2f8b4fcd02dd2bc96188a767493acb66a20c Mon Sep 17 00:00:00 2001 From: Damian Parrino Date: Wed, 17 Jan 2024 11:35:01 -0300 Subject: [PATCH 7/7] Update quickstart.md --- docs/2.develop/contracts/quickstart.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/2.develop/contracts/quickstart.md b/docs/2.develop/contracts/quickstart.md index 41bf87732e0..2beb995c20e 100644 --- a/docs/2.develop/contracts/quickstart.md +++ b/docs/2.develop/contracts/quickstart.md @@ -29,8 +29,15 @@ Before starting, make sure you have the following installed: :::tip Easy Install -- **NEAR-CLI:** Install both `near-cli` and `cargo-near` tools using `npm i -g near-cli cargo-near` -- **NEAR-CLI-RS:**Install both `near-cli-rs` and `cargo-near` tools using `npm i -g near-cli-rs cargo-near` +- **NEAR-CLI:** Install both `near-cli` and `cargo-near` tools using + ``` + npm i -g near-cli cargo-near + ``` + +- **NEAR-CLI-RS:** Install both `near-cli-rs` and `cargo-near` tools using + ``` + npm i -g near-cli-rs cargo-near + ``` :::