Browse Source

language updates

update-clarity-tutorial
Alex Graebe 5 years ago
parent
commit
96d2abfe01
  1. 4
      _core/smart/tutorial-counter.md
  2. 6
      _core/smart/tutorial.md

4
_core/smart/tutorial-counter.md

@ -85,7 +85,7 @@ Let's get familiar with the tests to understand what the new smart contract shou
counterClient = new Client("SP3GWX3NE58KXHESRYE4DYQ1S31PQJTCRXB3PE9SB.counter", "counter", provider);
```
That tells us that the new smart contract is named `counter` and that the referenced smart contract should be found in the following file: `contracts/counter.clar`. Note that the `contracts` folder is assumed as the base folder and that every Clarity file has the suffix `.clar`.
That tells us that the new smart contract is named `counter` and that it should be found in the following file: `contracts/counter.clar`. Note that the `contracts` folder is assumed as the base folder and that every Clarity file has the suffix `.clar`.
The file was already created during the project setup.
@ -101,7 +101,7 @@ Let's get familiar with the tests to understand what the new smart contract shou
The first line initializes a new integer variable `counter` with the value set to `0` using the [`define-data-var`](https://docs.blockstack.org/core/smart/clarityref#define-data-var) statement. It is important to note that all definition statements in Clarity need to be at the top of the file.
To provide access to the variable from outside of the current smart contract, we need to declare a public get function for this variable. The last lines of the code add a public `get-counter` function. The [`var-get`](https://docs.blockstack.org/core/smart/clarityref#var-get) statement looks for a variable in the contract's data map and returns it.
To provide access to the `counter` variable from outside of the current smart contract, we need to declare a public get function. The last lines of the code add a public `get-counter` function. The [`var-get`](https://docs.blockstack.org/core/smart/clarityref#var-get) statement looks for a variable in the contract's data map and returns it.
With that, you are ready to rerun the tests!

6
_core/smart/tutorial.md

@ -68,7 +68,7 @@ Now, let's have a look at a Clarity smart contract and get familiar with the bas
ls contracts
```
This directory contains a hello world Clarity contract. Note that all Clarity files have a `.clar` suffix.
This directory contains one file for the hello world smart contract. Note that all Clarity files have a `.clar` suffix.
2. Let's review the contents of `hello-world.clar` with the `cat` command.
@ -164,9 +164,11 @@ helloWorldClient = new Client("SP3GWX3NE58KXHESRYE4DYQ1S31PQJTCRXB3PE9SB.hello-w
Take a look at the client initialization. It requires a contract id and name in the following format: `{owner_stacks_address}.{contract_identifier}`. The second parameter indicates the location of the smart contract file, without the `.clar` suffix. By default, the location is assumed to be relative to the `contracts` folder.
As you can see above, a sample stacks address and contract identifier is already provided for you. You don't need to modify anything.
### Checking syntax
Next, we check the contract for valid syntax with:
Next, we check the contract for valid syntax. If the smart contract implementation has syntax error (bugs), this check would fail:
```js
await helloWorldClient.checkContract();

Loading…
Cancel
Save