Skip to content

Commit e88c083

Browse files
committed
finished first pass
1 parent 07e479c commit e88c083

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

docs/develop/contracts/js/quickstart.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,62 @@ You can now deploy the contract and start interacting with it!
259259
Start by deploying the contract using the following command. This will create a [dev account](/docs/concepts/account#dev-accounts) and deploy the contract to it.
260260

261261
```
262-
near js dev-deploy --base64File <build/contract.base64> --deposit 0.1
262+
near js dev-deploy --base64File build/contract.base64 --deposit 0.1
263263
```
264264
Alternatively, if you have an account already, you can specify the account you want to deploy to:
265265

266266
```
267-
near js deploy --accountId <YOUR_ACCOUNT_ID> --base64File <build/contract.base64> --deposit 0.1
267+
near js deploy --accountId <YOUR_ACCOUNT_ID> --base64File build/contract.base64 --deposit 0.1
268268
```
269269

270270
> **Note**: When deploying the smart contract using the enclave approach, it will live on top of a virtual machine smart contract that is deployed to `jsvm.testnet`. This will act as a "middleman" and to interact with your contract, you'll need to go through the `jsvm` contract.
271271
272272
### Interacting
273273

274-
Now that your contract is deployed,
274+
Now that your contract is deployed, you can start interacting with it. The first thing to do is initialize the contract. For simplicity, export the account ID that the contract is deployed to into an environment variable.
275275

276+
```bash
277+
export JS_CONTRACT="dev-1653584404106-63749024395789"
278+
```
279+
You'll now initialize the contract such that the default greeting is set. If you try to interact with the contract before it's initialized, you'll be thrown an error saying "Contract state is empty".
280+
281+
```bash
282+
near js call $JS_CONTRACT init --accountId $JS_CONTRACT --deposit 0.1
283+
```
284+
285+
Once the contract is initialized, you can view the current greeting by performing a view call:
286+
287+
```bash
288+
near js view $JS_CONTRACT get_greeting --accountId $JS_CONTRACT
289+
```
276290

291+
This should return something similar to:
277292

293+
```bash
294+
View call in JSVM[jsvm.testnet]: dev-1653584404106-63749024395789.get_greeting()
295+
Log [jsvm.testnet]: current greeting is Hello
296+
'Hello'
297+
```
298+
299+
Now that you know how to get the current greeting, you can go ahead and call the setter `set_greeting`:
278300

301+
```bash
302+
near js call $JS_CONTRACT set_greeting '["GO TEAM!"]' --accountId $JS_CONTRACT --deposit 0.1
303+
```
304+
305+
This should return something similar to:
306+
307+
```bash
308+
Scheduling a call in JSVM[jsvm.testnet]: dev-1653584404106-63749024395789.set_greeting(["GO TEAM!"]) with attached 0.1 NEAR
309+
Receipts: 8w9tNKgqtAnJd9UW5WMCFuGsTXHo83vvPHD5Ph36yWJM, E9CJED2cpLC7uaTb6s67i3KKbinDzcjUQXspK7Jj7CdF
310+
Log [jsvm.testnet]: Saving greeting GO TEAM!
311+
Transaction Id 8gr8gtWDvCGzwS9HQ9GerKxBqDbnbwaWr5bBjdDpDBYg
312+
To see the transaction in the transaction explorer, please open this url in your browser
313+
https://explorer.testnet.near.org/transactions/8gr8gtWDvCGzwS9HQ9GerKxBqDbnbwaWr5bBjdDpDBYg
314+
''
315+
```
279316

317+
Your contract is now finished and you've learned how to interact with it using the NEAR-CLI!
280318

281319
> Got a question?
282320
> <a href="https://stackoverflow.com/questions/tagged/nearprotocol"> > <h8>Ask it on StackOverflow!</h8></a>

0 commit comments

Comments
 (0)