Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru authored Jan 23, 2023
2 parents 4cddc14 + 4bbfdd3 commit b02d2d0
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 56 deletions.
6 changes: 3 additions & 3 deletions docs/how-to-guides/how-to-add-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Clarinet can handle adding a new contract and its configuration to your project
$ clarinet contract new bbtc
```

Clarinet will add 2 files to your project:
Clarinet will add two files to your project:
- the contract file in the `contracts` directory
- the contract test file in the `tests` directory

Expand All @@ -25,13 +25,13 @@ Clarinet will add 2 files to your project:
└── bbtc_test.ts
```

Clarinet will also add a configuration to the `Clarinet.toml` file for your contract.
Clarinet will also add your contract configuration in the `Clarinet.toml`.

```toml
[contracts.my-contract]
path = "contracts/my-contract.clar"
```

You can add contracts to your project by adding the files manually, however, you must make sure to add the appropriate configuration
You can add contracts to your project by adding the files manually; however, you must make sure to add the appropriate configuration
to `Clarinet.toml` for Clarinet to recognize the contracts.

8 changes: 4 additions & 4 deletions docs/how-to-guides/how-to-check-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Clarinet provides syntax and semantics checkers for Clarity. You can verify if t
$ clarinet check
```

This command uses the `Clarinet.toml` file to locate and analyze all of the contracts in the project.
If the Clarity code is valid, then the command will indicate success with the response below.
This command uses the `Clarinet.toml` file to locate and analyze all the contracts in the project.
If the Clarity code is valid, the command will indicate success with the response below.

```
✔ 2 contracts checked
Expand All @@ -23,12 +23,12 @@ You may also perform a syntax-check on a single file by using the command below.
$ clarinet check <path/to/file.clar>
```

If there are no syntax errors, the output of the command will be a success message.
The command output will be a success message if there are no syntax errors.

```
✔ Syntax of contract successfully checked
```

Any syntactical errors in the Clarity code will be reported, but type-checking and other semantic checks are not performed.
This is because Clarinet is only looking at this one contract, and does not have the full context to perform a complete check.
This is because Clarinet is only looking at this one contract and needs the full context to perform a complete check.

7 changes: 3 additions & 4 deletions docs/how-to-guides/how-to-create-new-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Once you have installed Clarinet, you may then use Clarinet to create a new proj
clarinet new my-project && cd my-project
```

Clarinet creates a project directory with the following directory layout: 
Clarinet creates a project directory with the following directory layout:

```bash
.
Expand All @@ -22,8 +22,7 @@ Clarinet creates a project directory with the following directory layout: 
```


The `Clarinet.toml` file contains configuration files for the smart contracts in your project. When you create contracts in your project, Clarinet will add them to this file.
The `Clarinet.toml` file contains configuration files for the smart contracts in your project. Clarinet will add contracts to this file when you create contracts in your project.

The `settings/Devnet.toml` file contains configuration for accounts in the Clarinet console, including the seed
phrases and initial balances. Initial balances are in microstacks (uSTX).
The `settings/Devnet.toml` file contains configuration for accounts in the Clarinet console, including the seed phrases and initial balances. Initial balances are in microstacks (uSTX).

10 changes: 5 additions & 5 deletions docs/how-to-guides/how-to-debug-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ title: Debug Contract

## VS Code Debugger

Clarinet supports the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) (DAP), which enables you to debug your smart contracts inside of Visual Studio Code (VS Code), or any code editor supporting the DAP protocol.
Clarinet supports the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/) (DAP), which enables you to debug your smart contracts inside of Visual Studio Code (VS Code) or any code editor supporting the DAP protocol.

To set up a debug session, you will first need to create a `launch.json` file to tell VS Code what you want to debug.
To set up a debug session, you will need to create a `launch.json` file to tell VS Code what you want to debug.
The easiest way to accomplish this is to let VS Code generate the template for you by opening the "Run and Debug" view and clicking "create a launch.json file".

![Run and Debug View](../images/run-and-debug.png)
Expand All @@ -31,7 +31,7 @@ This will create the file `.vscode/launch.json` with the default template:
}
```

Depending on your needs, you will want to set the `name` field to whatever makes sense for your project, then set the `expression` to the Clarity expression that you would like to debug. In the case of the default example shown in the template above, the debugger would start executing the `bar` function of the `foo` contract, passing the argument `42`. Once this file is configured, the debugger works as expected for any [VS Code debugging](https://code.visualstudio.com/docs/editor/debugging).
Depending on your needs, you will want to set the `name` field to whatever makes sense for your project, then set the `expression` to the Clarity expression you would like to debug. In the case of the default example shown in the template above, the debugger would start executing the `bar` function of the `foo` contract, passing the argument `42`. Once this file is configured, the debugger works as expected for any [VS Code debugging](https://code.visualstudio.com/docs/editor/debugging).

Execution begins paused at the first expression. The debug toolbar includes buttons to continue,
step over, step into, step out, restart, and stop, in that order.
Expand All @@ -42,11 +42,11 @@ Breakpoints can be set by clicking in the left gutter next to the code or using

![breakpoint](../images/breakpoint.png)

Data watchpoints may also be set, by clicking the "+" in the Watch section of the Debug sidebar and typing the contract variable to watch in the format `<principal>.<contract>.<name>`, or using the shortcut for a local contract, `.<contract>.<name>`. When a watchpoint is set on a contract variable, execution will pause when its value will change.
Data watchpoints may also be set by clicking the "+" in the Watch section of the Debug sidebar and typing the contract variable to watch in the format `<principal>.<contract>.<name>`, or using the shortcut for a local contract, `.<contract>.<name>`. When a watchpoint is set on a contract variable, execution will pause when its value changes.

![watchpoint](../images/watchpoint.png)

During execution, the values of the current contract's variables, the current function's arguments, and any local variables (i.e. from a `let` expression) are shown in the sidebar. The current watchpoints are also shown with their current values. In both cases, the contents of a map are not shown but can be queried in the Debug Console. The call stack is also updated to show the call stack of the current execution.
During execution, the values of the current contract's variables, the current function's arguments, and any local variables (i.e., from a `let` expression) are shown in the sidebar. The current watchpoints are also shown with their current values. In both cases, the contents of a map are not shown but can be queried in the Debug Console. The call stack is also updated to show the call stack of the current execution.

![view of the sidebar, showing variables, watchpoints, and call stack](../images/sidebar.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/how-to-deploy-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Deploy Contracts

You can use Clarinet to publish your contracts to Devnet / Testnet / Mainnet environment for testing and evaluation on a blockchain.

The first step is to generate a deployment plan, with the command below.
The first step is to generate a deployment plan with the command below.

```bash
$ clarinet deployment generate --mainnet
Expand Down
13 changes: 5 additions & 8 deletions docs/how-to-guides/how-to-deploy-with-subnets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
title: Deploy Clarinet with Subnets
---

Clarinet may be used for facilitating experimentation with [subnets](https://www.youtube.com/watch?v=PFPwuVCGGuI).
To get started with subnets, in your `Devnet.toml`, enable the flag
Clarinet may facilitate experimentation with [subnets](https://www.youtube.com/watch?v=PFPwuVCGGuI).
To get started with subnets, enable the flag in your `Devnet.toml` by adding the configuration below.

```toml
[devnet]
# ...
enable_subnet_node = true
```

This same file can be used for customizing the subnet-node (miner, etc).

When running the command below, Clarinet will spin up a subnet node.
You can use the `Devnet.toml` to customize the subnet-node (miner, etc).
Spin up your subnet node with the command below.

```bash
$ clarinet integrate
```

More information on how to use and interact with this incoming L2 can be found on the [subnet repository](https://github.com/hirosystems/stacks-subnets).
You can find more information on using and interacting with Subnets in the [subnets repository](https://github.com/hirosystems/stacks-subnets).
24 changes: 11 additions & 13 deletions docs/how-to-guides/how-to-run-integration-environment.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
---
title: "Run a local Integration Environment"
title: "Run local Integration Environment"
---

Once you have reached a point where your Clarity smart contract is functional, you may want to develop a web frontend against your contract. This can be challenging, as the contract must be deployed to a live blockchain to fully
interact with it from a web app. Clarinet provides an easy method to deploy your contract to a blockchain that
runs locally on your machine that is configurable and controllable. This integration feature is called DevNet.
Once you have reached a point where your Clarity smart contract is functional, you can develop a web frontend against your contract. This can be challenging, as the contract must be deployed to a live blockchain to interact with it from a web app fully. Clarinet provides an easy method to deploy your contract to a blockchain that is configurable and controllable locally on your machine. This integration feature is called DevNet.

DevNet allows you to perform frontend development and integration testing without the need to deploy your contract to public testnet. This is valuable if you are in the early stages of developing a product, or if you are developing a contract and app in stealth. DevNet uses Docker to launch local instances of Bitcoin, Stacks, Stacks API, Explorer, and Bitcoin Explorer, and provides total configuration control over all those instances. Once running, DevNet automatically deploys your contracts and creates Stacks accounts with pre-defined balances.
DevNet allows you to perform frontend development and integration testing without the need to deploy your contract to public testnet. This is valuable if you are in the early stages of developing a product, contract, or app in stealth. DevNet uses Docker to launch local instances of Bitcoin, Stacks, Stacks API, Explorer, and Bitcoin Explorer and provides total configuration control over all those instances. Once running, DevNet automatically deploys your contracts and creates Stacks accounts with pre-defined balances.

The services launched by DevNet represent a full instance of the Stacks blockchain with the Proof of Transfer consensus mechanism running against a locally running Bitcoin testnet. DevNet allows you to control block times, PoX transactions, and contract deployments. Because DevNet is running locally, it can be reset or re-configured at any time. This allows for rapid frontend development without the need to interact with the public blockchain.
The services launched by DevNet represent a full instance of the Stacks blockchain with the Proof of Transfer consensus mechanism running against a locally running Bitcoin testnet. DevNet allows you to control block times, PoX transactions, and contract deployments. Because DevNet is running locally, it can be reset or reconfigured anytime. This allows for rapid frontend development without interacting with the public blockchain.

## Prerequisites

In order to run DevNet, you must have [Clarinet installed](../getting-started.md), and you also should have Docker installed locally. Refer to the [Docker documentation](https://docs.docker.com/get-docker/) for instructions on installing Docker on your development machine.
To run DevNet, you must have [Clarinet installed](../getting-started.md), and you also should have Docker installed locally. Refer to the [Docker documentation](https://docs.docker.com/get-docker/) for instructions on installing Docker on your development machine.

## Launching DevNet

Clarinet provides sensible a sensible default configuration for DevNet. If you wish to use the default configuration, you can launch DevNet from the root of your Clarinet project with the command:
Clarinet provides a sensible default configuration for DevNet. If you wish to use the default configuration, you can launch DevNet from the root of your Clarinet project with the command:

```sh
clarinet integrate
```

Clarinet fetches the appropriate Docker images for the Bitcoin node, Stacks node, Stacks API node, and the Bitcoin and Explorers. This can take several minutes on first launch. Once the images are launched, the DevNet interface is displayed in your terminal window. The contracts in your project are deployed to the DevNet blockchain in the second block of the chain, so you may need to wait for the third block before launching your frontend development environment.
Clarinet fetches the appropriate Docker images for the Bitcoin node, Stacks node, Stacks API node, and the Bitcoin and Explorers. This can take several minutes on the first launch. Once the images are launched, the DevNet interface is displayed in your terminal window. The contracts in your project are deployed to the DevNet blockchain in the second block of the chain, so you may need to wait for the third block before launching your frontend development environment.

Review the following sections for information about the DevNet interface and configuration options for DevNet.

Expand All @@ -34,7 +32,7 @@ The DevNet interface is displayed as a terminal GUI and consists of four primary

The system log provides a log of events happening throughout the DevNet stack. You can use this log to monitor the health of the local blockchain and review any events that occur. For services that provide a web interface, the URL for the local service is displayed next to the container name. You can connect to these URLs using a web browser to access the service.

The service status provides a status summary for the Docker containers that make up the DevNet stack. A green icon next to the container indicates that it is in a healthy state, a yellow icon indicates that the container is booting, and a red icon indicates that there is a problem with the service.
The service status provides a status summary for the Docker containers that make up the DevNet stack. A green icon next to the container indicates that it is in a healthy state, a yellow icon indicates that the container is booting, and a red icon indicates a problem with the service.

The mempool summary displays a list of transactions in the mempool. These include historical transactions from the beginning of the blockchain.

Expand All @@ -47,7 +45,7 @@ containers.

## Configuring DevNet

By default, DevNet launches a local Stacks 2.0 testnet with a fixed block time of 30 seconds. It runs Docker images that host a Bitcoin node, a Stacks Node, the Stacks API, the Explorer, and the Bitcoin Explorer. The default settings should be adequate for most developers, but you can change many of the settings to customize your development environment.
By default, DevNet launches a local Stacks 2.0 testnet with a fixed block time of 30 seconds. It runs Docker images that host a Bitcoin node, a Stacks Node, the Stacks API, the Explorer, and the Bitcoin Explorer. The default settings should be adequate for most developers, but you can change many settings to customize your development environment.

DevNet settings are located in the `settings/Devnet.toml` file. The file defines the wallets that are created in the
DevNet blockchain, the Stacks miner configuration, Proof of Transfer activity, and many other options.
Expand All @@ -71,7 +69,7 @@ the latest development images for each of the Stacks and Bitcoin nodes. These pa

> **_NOTE:_**
>
> If any of the parameters are not supplied in the configuration file, the default value is used.
> The default value is used if any of the parameters are not supplied in the configuration file.

- `pox_stacking_orders`: defined by [stacking orders](../../smart-contracts/devnet.md#stacking-orders) headings later in the file
Expand Down Expand Up @@ -112,7 +110,7 @@ You can configure any of the wallets in the DevNet to participate in stacking to

Each [stacking order](../../smart-contracts/devnet.md#stacking-orders) is defined under the heading `[devnet.pox_stacking_orders]`. This heading is repeated for as many stacking orders that are necessary for your configuration.

- `start_at_cycle`: the stacking cycle that the wallet should start particiating in. The wallet's stacking order occurs at the block preceding the beginning of that cycle.
- `start_at_cycle`: the stacking cycle that the wallet should start participating in. The wallet's stacking order occurs at the block preceding the beginning of that cycle.
- `duration`: the stacking duration for the stacking cycle
- `wallet`: the alias of the wallet participating
- `slots`: the number of stacking slots that the wallet will participate in
Expand Down
Loading

0 comments on commit b02d2d0

Please sign in to comment.