Skip to content

Commit

Permalink
Update quickstart.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Jan 17, 2024
1 parent b62dc7b commit 78b0039
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions docs/2.develop/contracts/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

:::

---
Expand Down Expand Up @@ -214,7 +219,9 @@ New account "lovely-event.testnet" created successfully.
</details>
:::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`)

:::

---
Expand Down Expand Up @@ -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**.
<Tabs>
<TabItem value="near-cli">
```bash
> near view <created-account> get_greeting
"Hello" # Response
```
</TabItem>
<TabItem value="near-cli-rs">
```bash
> near contract call-function as-read-only <created-account> get_greeting
"Hello" # Response
```
</TabItem>
</Tabs>
#### 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.

<Tabs>

<TabItem value="near-cli">

```bash
> near call <created-account> set_greeting '{"greeting": "Hola"}' --accountId <created-account>
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 <created-account>`).
</TabItem>
<TabItem value="near-cli-rs">
```bash
> near contract call-function as-transaction <created-account> set_greeting '{"greeting": "Hola"}' sign-as <created-account>
Expand All @@ -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 <created-account>`).

</TabItem>

</Tabs>

---

## Moving Forward
Expand Down

0 comments on commit 78b0039

Please sign in to comment.