Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Mar 12, 2024
1 parent 1b983e7 commit d26b341
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions contract-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,54 @@ class HelloNear {

<br />

## 1. Build and Deploy the Contract
You can automatically compile and deploy the contract in the NEAR testnet by running:
## 1. Build and Test the Contract
You can automatically compile and test the contract by running:

```bash
npm run build
npm run deploy
```

Once finished, check the `neardev/dev-account` file to find the address in which the contract was deployed:
<br />

## 2. Create an Account and Deploy the Contract
You can create a new account and deploy the contract by running:

```bash
cat ./neardev/dev-account
# e.g. dev-1659899566943-21539992274727
near create-account <your-account.testnet> --useFaucet
near deploy <your-account.testnet> build/release/hello_near.wasm
```

<br />

## 2. Retrieve the Greeting

## 3. Retrieve the Greeting

`get_greeting` is a read-only method (aka `view` method).

`View` methods can be called for **free** by anyone, even people **without a NEAR account**!

```bash
# Use near-cli to get the greeting
near view <dev-account> get_greeting
near view <your-account.testnet> get_greeting
```

<br />

## 3. Store a New Greeting
## 4. Store a New Greeting
`set_greeting` changes the contract's state, for which it is a `call` method.

`Call` methods can only be invoked using a NEAR account, since the account needs to pay GAS for the transaction.

```bash
# Use near-cli to set a new greeting
near call <dev-account> set_greeting '{"greeting":"howdy"}' --accountId <dev-account>
near call <your-account.testnet> set_greeting '{"greeting":"howdy"}' --accountId <your-account.testnet>
```

**Tip:** If you would like to call `set_greeting` using your own account, first login into NEAR using:
**Tip:** If you would like to call `set_greeting` using another account, first login into NEAR using:

```bash
# Use near-cli to login your NEAR account
near login
```

and then use the logged account to sign the transaction: `--accountId <your-account>`.
and then use the logged account to sign the transaction: `--accountId <another-account>`.

0 comments on commit d26b341

Please sign in to comment.