Browse Source

Revert "Updates clarity and tweek wallet link"

feat/clarity-updates
Moxiegirl 5 years ago
committed by GitHub
parent
commit
ef666503ae
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      _core/smart/clarityCLI.md
  2. 2
      _core/smart/functions.md
  3. 14
      _core/smart/overview.md
  4. 2
      _core/smart/principals.md
  5. 2
      _core/smart/sdk-quickstart.md
  6. 44
      _core/smart/tutorial.md
  7. 2
      _org/wallet-install.md

22
_core/smart/clarityCLI.md

@ -3,10 +3,10 @@ layout: core
description: "Blockstack smart contracting language"
permalink: /:collection/:path.html
---
# clarity command line
# clarity-cli command line
{:.no_toc}
You use the `clarity` command to work with smart contracts within the Blockstack virtual environment. This command has the following subcommands:
You use the `clarity-cli` command to work with smart contracts within the Blockstack virtual environment. This command has the following subcommands:
* TOC
{:toc}
@ -14,7 +14,7 @@ You use the `clarity` command to work with smart contracts within the Blockstack
## initialize
```bash
clarity initialize [vm-state.db]
clarity-cli initialize [vm-state.db]
```
Initializes a local VM state database. If the database exists, this command throws an error.
@ -22,7 +22,7 @@ Initializes a local VM state database. If the database exists, this command thro
## mine_block
```bash
clarity mine_block [block time] [vm-state.db]
clarity-cli mine_block [block time] [vm-state.db]
```
Simulates mining a new block.
@ -30,7 +30,7 @@ Simulates mining a new block.
## get_block_height
```bash
clarity get_block_height [vm-state.db]
clarity-cli get_block_height [vm-state.db]
```
Prints the simulated block height.
@ -38,7 +38,7 @@ Prints the simulated block height.
## check
```bash
clarity check [program-file.scm] (vm-state.db)
clarity-cli check [program-file.scm] (vm-state.db)
```
Type checks a potential contract definition.
@ -46,7 +46,7 @@ Type checks a potential contract definition.
## launch
```bash
clarity launch [contract-name] [contract-definition.scm] [vm-state.db]
clarity-cli launch [contract-name] [contract-definition.scm] [vm-state.db]
```
Launches a new contract in the local VM state database.
@ -54,7 +54,7 @@ Launches a new contract in the local VM state database.
## eval
```bash
clarity eval [context-contract-name] (program.scm) [vm-state.db]
clarity-cli eval [context-contract-name] (program.scm) [vm-state.db]
```
Evaluates, in read-only mode, a program in a given contract context.
@ -69,7 +69,7 @@ Type check and evaluate an expression for validity inside of a function’s sour
## repl
```bash
clarity repl
clarity-cli repl
```
Type check and evaluate expressions in a stdin/stdout loop.
@ -77,7 +77,7 @@ Type check and evaluate expressions in a stdin/stdout loop.
## execute
```bash
clarity execute [vm-state.db] [contract-name] [public-function-name] [sender-address] [args...]
clarity-cli execute [vm-state.db] [contract-name] [public-function-name] [sender-address] [args...]
```
Executes a public function of a defined contract.
@ -85,7 +85,7 @@ Executes a public function of a defined contract.
## generate_address
```bash
clarity generate_address
clarity-cli generate_address
```
Generates a random Stacks public address for testing purposes.

2
_core/smart/functions.md

@ -13,7 +13,7 @@ Clarity includes _defines_ and native functions for creating user-defined funct
## define and define-public functions
Functions specified via `define-public` statements are public functions. Functions without these designations, simple `define` statements, are private functions. You can run a contract's public functions directly via the `clarity execute` command line directly or from other contracts. You can use the `clarity eval` or `clarity eval_raw` commands to evaluate private functions via the command line.
Functions specified via `define-public` statements are public functions. Functions without these designations, simple `define` statements, are private functions. You can run a contract's public functions directly via the `clarity-cli execute` command line directly or from other contracts. You can use the `clarity eval` or `clarity eval_raw` commands to evaluate private functions via the command line.
Public functions return a Response type result. If the function returns an `ok` type, then the function call is considered valid, and any changes made to the blockchain state will be materialized. If the function returns an `err` type, it is considered invalid, and has no effect on the smart contract's state.

14
_core/smart/overview.md

@ -44,7 +44,7 @@ Clarity is a list processing (LISP) language, as such it is not compiled. Omitti
Clarity is in pre-release and does not yet directly interact with the live Stacks blockchain. For the pre-release period you need a test environment to run Clarity contracts. Blockstack provides a Docker image called `clarity-developer-preview` that you can use or you can build a test environment locally from code. Either the Docker image or a local environment is sufficient for testing Clarity programming for standalone contracts.
You use the `clarity` command line to check, launch, and execute standalone Clarity contracts. You can use this same command line to create simulate mining Stacks and inspecting a blockchain.
You use the `clarity-cli` command line to check, launch, and execute standalone Clarity contracts. You can use this same command line to create simulate mining Stacks and inspecting a blockchain.
Blockstack expects that some decentralized applications (DApp) will want to make use of Clarity contracts as part of their applications. For this purpose, you should use the Clarity SDK, also in pre-release. The SDK is a development environment, testing framework, and deployment tool. It provides a library for safe interactions with Clarity contracts from a DApp written with the blockstack.js library.
@ -72,7 +72,7 @@ You can add comments to your Clarity contracts using `;;` (double semi-colons).
(transfer! tx-sender recipient amount)) ;; returns: boolean
```
You use the `clarity` command to check and launch a Clarity (`.clar`) program.
You use the `clarity-cli` command to check and launch a Clarity (`.clar`) program.
## hello-world example
@ -85,11 +85,11 @@ The easiest program to run in any language is a hello world program. In Clarity,
This program defines a single `hello-world` expression that is excuted when the contract launches. The `begin` is a native Clarity function that evaluates the expressions input to it and returns the value of the last expression. Here there is a single `print` expression. Both the `begin` and the `print` are enclosed in `()` parentheses.
For the pre-release, the Blockstack test environment includes the `clarity` command for interacting with the contract and SQLite to support the data space. You create a SQLLite database to hold data related to Clarity contracts. This database simulates the blockchain by recording the contract activity.
For the pre-release, the Blockstack test environment includes the `clarity-cli` command for interacting with the contract and SQLite to support the data space. You create a SQLLite database to hold data related to Clarity contracts. This database simulates the blockchain by recording the contract activity.
You can't run even an a hello-world program without first initializing a Clarity contract's data space within the database. You can use the `clarity initialize` command to set up the database.
You can't run even an a hello-world program without first initializing a Clarity contract's data space within the database. You can use the `clarity-cli initialize` command to set up the database.
```clarity initialize /data/db```
```clarity-cli initialize /data/db```
This command initializes the `db` database which resides in the `/data` directory of the container. You can name the database anything you like, the name `db` is not required. You can use SQLite to query this database:
@ -103,12 +103,12 @@ sqlite>
After you initialize the contract's data space, you can `check` a Clarity program for problems.
```clarity check ./hello.clar /data/db```
```clarity-cli check ./hello.clar /data/db```
As the name implies, the `check` ensures the contract definition passes a type check; passing programs will returns an exit code of `0` (zero). Once a contract passes a check, you `launch` it.
```bash
root@4224dd95b5f5:/data# clarity launch hello ./hello.clar /data/db
root@4224dd95b5f5:/data# clarity-cli launch hello ./hello.clar /data/db
Buffer(BuffData { data: [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100] })
Contract initialized!
```

2
_core/smart/principals.md

@ -38,7 +38,7 @@ The principal's signature is not checked by the smart contract, but by the virtu
Smart contracts themselves are principals and are represented by the smart contract's identifier. You create the identifier when you launch the contract, for example, the contract identifier here is `hanomine`.
```bash
clarity launch hanomine /data/hano.clar /data/db
clarity-cli launch hanomine /data/hano.clar /data/db
```
A smart contract may use the special variable `contract-name` to refer to its own principal.

2
_core/smart/sdk-quickstart.md

@ -131,7 +131,7 @@ describe("hello world contract test suite", () => {
The `hello-world.ts` test file is a client that runs the `hello-world.clar` contract. Tests are critical for smart contracts as they are intended to manipulate assets and their ownership. These manipulations are irreversible within a blockchain. As you create a contracts, you should not be surprise if you end up spending more time and having more code in your `tests` than in your `contracts` directory. The `tests/hello-world.ts` file in the scaffold has the following content:
The first part of the test (lines 1 -10) sets up the test environment. It defines a Clarity `provider` and launches it (line 9). The Client instance contains a contract name and the path to the sample code. This test also checks the client (line 14) and then launches it (line 19), this is equivalent to running `clarity check` with the command line. The remaining test code exercises the contract. Try running this test.
The first part of the test (lines 1 -10) sets up the test environment. It defines a Clarity `provider` and launches it (line 9). The Client instance contains a contract name and the path to the sample code. This test also checks the client (line 14) and then launches it (line 19), this is equivalent to running `clarity-cli check` with the command line. The remaining test code exercises the contract. Try running this test.
```sh

44
_core/smart/tutorial.md

@ -69,7 +69,7 @@ The first line of the `tokens.clar` program contains a user-defined `get-balance
(default-to 0 (get balance (fetch-entry tokens (tuple (account account))))))
```
`get-balance` is a private function because it is constructed with the `define` call. To create public functions, you would use the `define-public` function. Public functions can be called from other contracts or even from the command line with the `clarity`.
`get-balance` is a private function because it is constructed with the `define` call. To create public functions, you would use the `define-public` function. Public functions can be called from other contracts or even from the command line with the `clarity-cli`.
Notice the program is enclosed in `()` (parentheses) and each statement as well. The `get-balance` function takes an `account` argument of the special type `principal`. Principals represent a spending entity and are roughly equivalent to a Stacks address.
@ -124,12 +124,12 @@ Which `tokens.clar` function is being called?
## Task 3: Initialize data-space and launch contracts
In this task, you interact with the the contracts using the `clarity` command line.
In this task, you interact with the the contracts using the `clarity-cli` command line.
1. Initialize a new `db` database in the `/data/` directory
```bash
# clarity initialize /data/db
# clarity-cli initialize /data/db
Database created
```
@ -138,7 +138,7 @@ In this task, you interact with the the contracts using the `clarity` command li
2. Type check the `names.clar` contract.
```bash
# clarity check sample-programs/names.clar /data/db
# clarity-cli check sample-programs/names.clar /data/db
```
You should get an error:
@ -152,7 +152,7 @@ In this task, you interact with the the contracts using the `clarity` command li
3. Type check the `tokens.clar` contract, it should pass a check as it does not use the `contract-call` function:
```bash
# clarity check sample-programs/tokens.clar /data/db
# clarity-cli check sample-programs/tokens.clar /data/db
Checks passed.
```
@ -163,7 +163,7 @@ In this task, you interact with the the contracts using the `clarity` command li
You use the `launch` command to instantiate a contract on the Stacks blockchain. If you have dependencies between contracts, for example names.clar is dependent on tokens.clar, you must launch the dependency first.
```bash
# clarity launch tokens sample-programs/tokens.clar /data/db
# clarity-cli launch tokens sample-programs/tokens.clar /data/db
Contract initialized!
```
@ -172,7 +172,7 @@ In this task, you interact with the the contracts using the `clarity` command li
5. Recheck the `names.clar` contract.
```bash
# clarity check sample-programs/names.clar /data/db
# clarity-cli check sample-programs/names.clar /data/db
```
The program should pass validation because its dependency on `tokens.clar` is fulfilled.
@ -180,7 +180,7 @@ In this task, you interact with the the contracts using the `clarity` command li
6. Instantiate the `names.clar` contract as well.
```bash
# clarity launch names sample-programs/names.clar /data/db
# clarity-cli launch names sample-programs/names.clar /data/db
```
## Task 4. Examine the SQLite database
@ -188,13 +188,13 @@ In this task, you interact with the the contracts using the `clarity` command li
The test environment uses a SQLite database to represent the blockchain. You initialized this database when you ran this earlier:
```bash
clarity initialize /data/db
clarity-cli initialize /data/db
```
As you work the contracts, data is added to the `db` database because you pass this database as a parameter, for example:
```bash
clarity launch tokens sample-programs/tokens.clar /data/db
clarity-cli launch tokens sample-programs/tokens.clar /data/db
```
The database exists on your local workstation and persists through restarts of the container. You can use this database to examine the effects of your Clarity programs. The tables in the SQLite database are the following:
@ -242,7 +242,7 @@ In this section, you use the public `mint!` function in the `tokens` contract t
1. Use the `clarity_cli` command to create a demo address.
```
# clarity generate_address
# clarity-cli generate_address
SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG
```
@ -255,7 +255,7 @@ In this section, you use the public `mint!` function in the `tokens` contract t
3. Get the current balance of your new address.
```bash
# echo "(get-balance '$DEMO_ADDRESS)" | clarity eval tokens /data/db
# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db
Program executed successfully! Output:
0
```
@ -265,15 +265,15 @@ In this section, you use the public `mint!` function in the `tokens` contract t
4. Try minting some tokens and sending them to an address we'll use for our demo.
```bash
# clarity execute /data/db tokens mint! $DEMO_ADDRESS 100000
# clarity-cli execute /data/db tokens mint! $DEMO_ADDRESS 100000
```
This executes the public `mint!` function defined in the tokens contract, sending 100000 tokens to you `$DEMO_ADDRESS`.
5. Use the `clarity eval` command to check the result of this call.
5. Use the `clarity-cli eval` command to check the result of this call.
```bash
# echo "(get-balance '$DEMO_ADDRESS)" | clarity eval tokens /data/db
# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db
Program executed successfully! Output:
100000
```
@ -287,7 +287,7 @@ Now, let's register a name using the `names.clar` contract. Names are just integ
You'll _salt_ the hash with the salt `8888`:
```bash
# echo "(hash160 (xor 10 8888))" | clarity eval names /data/db
# echo "(hash160 (xor 10 8888))" | clarity-cli eval names /data/db
Program executed successfully! Output:
0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde
```
@ -301,7 +301,7 @@ Now, let's register a name using the `names.clar` contract. Names are just integ
2. Preorder the name using the _execute_ command:
```bash
# clarity execute /data/db names preorder $DEMO_ADDRESS 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde 1000
# clarity-cli execute /data/db names preorder $DEMO_ADDRESS 0xb572fb1ce2e9665f1efd0994fe077b50c3a48fde 1000
Transaction executed and committed. Returned: 0
```
@ -310,7 +310,7 @@ Now, let's register a name using the `names.clar` contract. Names are just integ
3. Check the demo address' new balance:
```bash
# echo "(get-balance '$DEMO_ADDRESS)" | clarity eval tokens /data/db
# echo "(get-balance '$DEMO_ADDRESS)" | clarity-cli eval tokens /data/db
Program executed successfully! Output:
99000
```
@ -318,14 +318,14 @@ Now, let's register a name using the `names.clar` contract. Names are just integ
4. Register the name by executing the _register_ function:
```bash
# clarity execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
Transaction executed and committed. Returned: 0clarity execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
# clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
Transaction executed and committed. Returned: 0clarity-cli execute /data/db names register $DEMO_ADDRESS \'$DEMO_ADDRESS 10 8888
```
5. Lookup the "owner address" for the name:
```bash
# echo "(get owner (fetch-entry name-map (tuple (name 10))))" | clarity eval names /data/db
# echo "(get owner (fetch-entry name-map (tuple (name 10))))" | clarity-cli eval names /data/db
Program executed successfully! Output:
(some 'SP26CHZZ26Q25WDD1CFJYSED169PS9HTNX445XKDG)
```
@ -334,4 +334,4 @@ Now, let's register a name using the `names.clar` contract. Names are just integ
{:.no_toc}
* <a href="clarityRef.html">Clarity Language Reference</a>
* <a href="clarityRef.html">clarity command line</a>
* <a href="clarityRef.html">clarity-cli command line</a>

2
_org/wallet-install.md

@ -20,7 +20,7 @@ by Blockstack PBC." %}
## Mac Installation
1. Select <a href="https://wallet.blockstack.org" target="\_blank"><strong>the MacOS Download</strong> button on this page</a>.
1. Select the **MacOS Download** button <a href="https://wallet.blockstack.org" target="\_blank">on this page</a>.
This button downloads the software to your computer.

Loading…
Cancel
Save