You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/contracts/js/quickstart.md
+41-3Lines changed: 41 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -259,24 +259,62 @@ You can now deploy the contract and start interacting with it!
259
259
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.
260
260
261
261
```
262
-
near js dev-deploy --base64File <build/contract.base64> --deposit 0.1
262
+
near js dev-deploy --base64File build/contract.base64 --deposit 0.1
263
263
```
264
264
Alternatively, if you have an account already, you can specify the account you want to deploy to:
265
265
266
266
```
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
268
268
```
269
269
270
270
> **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.
271
271
272
272
### Interacting
273
273
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.
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
+
```
276
290
291
+
This should return something similar to:
277
292
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`:
0 commit comments