Skip to content

Commit

Permalink
Added near js commands for status-message example
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticTempest committed May 20, 2022
1 parent dce047c commit 92858a1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion examples/status-message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ npm run test

Suppose JSVM contract was deployed to `jsvm.test.near`. Developer want to deploy the status message contract to `status-message.test.near`. Create `status-message.test.near`, `alice.test.near` and `bob.test.near` locally. Then:

```sh
near js deploy --accountId status-message.test.near --base64File build/status-message.base64 --deposit 0.1 --jsvm jsvm.test.near
```

or with the raw CLI call command:
```sh
export NEAR_ENV=local
near call jsvm.test.near deploy_js_contract --accountId status-message.test.near --args $(cat build/status-message.base64) --base64 --deposit 0.1
```
Expand All @@ -31,17 +36,30 @@ near call jsvm.test.near deploy_js_contract --accountId status-message.test.near
Now we need to initialize the contract after deployment is ready, call the `init` method which will execute `new StatusMessage()` for the class.
Go back to the root dir of near-sdk-js, where we have a helper `encode-call.js`. Call it with:

```sh
near js call status-message.test.near init --deposit 0.1 --accountId status-message.test.near --jsvm jsvm.test.near
```

or with the raw CLI call command:
```sh
near call jsvm.test.near call_js_contract --accountId status-message.test.near --base64 --args $(node encode_call.js status-message.test.near init '')
```

## Call the contract
Under the root dir of near-sdk-js, call the `set_status` and `get_status` methods with:


```sh
near js call status-message.test.near set_status --args '["hello"]' --deposit 0.1 --accountId alice.test.near--jsvm jsvm.test.near

near js view status-message.test.near get_status --args '["alice.test.near"]' --deposit 0.1 --accountId bob.test.near --jsvm jsvm.test.near
```

or with the raw CLI call command:
```sh
near call jsvm.test.near call_js_contract --accountId alice.test.near --base64 --args $(node encode_call.js status-message.test.near set_status '["hello"]') --deposit 0.1

near call jsvm.test.near call_js_contract --accountId bob.test.near --base64 --args $(node encode_call.js status-message.test.near get_status '["alice.test.near"]')
```

Note that although `get_status` can be called as a view method with near-api-js, currently it cannot be called with near-cli because near-cli does not support base64 encoded arguments in view call.
Note that although `get_status` can be called as a view method with near-api-js, currently it cannot be called with near-cli because near-cli does not support base64 encoded arguments in view call.

0 comments on commit 92858a1

Please sign in to comment.