Skip to content

Commit

Permalink
GITBOOK-10: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
kenrogers authored and gitbook-bot committed Feb 2, 2024
1 parent 5980d7f commit 2db4efe
Show file tree
Hide file tree
Showing 132 changed files with 11,408 additions and 14 deletions.
Binary file added .gitbook/assets/._lw3 faucet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/Diagram Feb 2 2024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions .gitbook/assets/_category_ (1).json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "References",
"position": 9,
"link": {
"type": "generated-index",
"description": "Stacks references."
}
}

8 changes: 8 additions & 0 deletions .gitbook/assets/_category_ (2).json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Noteworthy Contracts",
"position": 5,
"link": {
"type": "generated-index",
"description": "Specific deployed Clarity Contracts worth mentioning."
}
}
9 changes: 9 additions & 0 deletions .gitbook/assets/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "Services using Stacks",
"position": 8,
"link": {
"type": "generated-index",
"description": "An 'always incomplete' list of services that use Stacks."
}
}

Binary file added .gitbook/assets/clarinet structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/event log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/explorer view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/function call.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (10).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (11).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (12).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (13).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (14).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (15).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (16).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (7).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (8).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (9).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/initial screen.png
15 changes: 15 additions & 0 deletions .gitbook/assets/language functions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Functions
description: See a detailed list of all functions for the Clarity language.
sidebar_position: 3
tags:
- clarity
---

import { FunctionsReferences } from "@site/src/components/ApiReferences/FunctionsReferences.jsx";

## Functions

Detailed list of all functions for the Clarity language.

<FunctionsReferences toc={toc} />
17 changes: 17 additions & 0 deletions .gitbook/assets/language keywords.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Keywords
description: See a detailed list of all keywords for the Clarity language.
sidebar_position: 4
tags:
- clarity
---

import { KeywordsReferences } from "@site/src/components/ApiReferences/KeywordsReferences.jsx";

![Abstract image illustrate Clarity native keywords](/img/keywords.jpg)

## Keyword reference

Detailed list of all keywords for the Clarity language.

<KeywordsReferences toc={toc} />
Binary file added .gitbook/assets/loaded contract.png
Binary file added .gitbook/assets/lw3 faucet.png
Binary file added .gitbook/assets/new function.png
Binary file added .gitbook/assets/post condition.jpeg
Binary file added .gitbook/assets/quicknode endpoint.png
Binary file added .gitbook/assets/rollup comparison.png
Binary file added .gitbook/assets/tools new.png
Binary file added .gitbook/assets/tx call.png
Binary file added .gitbook/assets/tx proof.png
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/stacks-network/docs)
[![Crowdin](https://badges.crowdin.net/docsstacksco/localized.svg)](https://crowdin.com/project/docsstacksco)
# Start Here

# Stacks documentation
{% hint style="info" %}
Note that these docs describe how Stacks _currently_ works pre-Nakamoto. There is a significant undertaking to improve the functionality of the chain that will change some of this called the Nakamoto Release. To learn more about how Stacks will work after Nakamoto, check out the Nakamoto Upgrade section.
{% endhint %}

This repository stores the files for the Stacks documentation website on [docs.stacks.co](https://docs.stacks.co)
## Stacks Docs

![A screenshot of docs.stacks.co](/static/img/docs-homepage.png)
**Stacks is a Bitcoin L2 that brings smart contract functionality to Bitcoin, without modifying Bitcoin itself.**

## Contributing
These docs serve as:

If you are interested in contributing to the site and making changes, please refer to our [contributing guide here](https://docs.stacks.co/contribute).
1. An introduction to Stacks (what it is, why you should care, how to build Bitcoin apps with it),
2. A reference guide to various aspects of the Stacks ecosystem
3. A collection of tutorials and code samples to help you learn and build

If you are interested in contributing to the translations of this site to multiple languages, please refer to the [translations guide](https://docs.stacks.co/docs/contribute/translations)
They are divided up into several sections:

This website uses [Docusaurus 2](https://docusaurus.io/). A local version can be run by cloning this repo and typing the following commands.
### Nakamoto Upgrade

```
npm install
npx docusaurus start
```
There is currently a major upgrade to Stacks underway called the Nakamoto Release. This will bring significant improvements to both security and speed. Since this work is still in-progress, there is a dedicated section describing how it works. Once the release is live on mainnet, these docs will be adjusted to reflect the way the chain works.

### Stacks 101

If you are interested in the basics of how Stacks works, the Stacks 101 section contains the essential information to understand how everything works. Note that this section explains how Stacks operates pre-Nakamoto, and will be updated in conjunction with the release.

### Tutorials

For all you developers, we have a collection of tutorials here for you to explore, both hosted here on the docs site and some others from the community.

### Clarity Reference

Clarity is the smart contract programming language used on the Stacks chain. This section is a reference for Clarity keywords and functions, as well as a quick tutorial for wrapping your head around the language.

### sBTC

sBTC is the upcoming trust-minimized Bitcoin peg system build on top of Stacks. This section will give you all the information you need to understand how it works. For tutorials on building with it, be sure to check out the tutorials section.

### In-Depth Technical Explanations

Finally, for those of you interested in diving deep into how Stacks works, the in-depth technical explanations are drawn from the SIPs, the documents formally outlining the technical functionality of Stacks. This will get you as much information on how things work outside of reading the source code yourself.

### AI-Powered Semantic Search

Looking for something specific? These docs are integrated with AI-powered semantic search, hit `Cmd/Ctrl + K` to open up the search box and ask the docs whatever you like.
111 changes: 111 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Table of contents

* [Start Here](README.md)

## ⬆ Nakamoto Upgrade

* [What is the Nakamoto Release?](nakamoto-upgrade/what-is-the-nakamoto-release.md)
* [Nakamoto in 10 Minutes](nakamoto-upgrade/nakamoto-in-10-minutes.md)
* [Nakamoto In-Depth](nakamoto-upgrade/nakamoto-in-depth/README.md)
* [Stackers and Signing](nakamoto-upgrade/nakamoto-in-depth/stackers-and-signing.md)
* [Chain Structure and Synchronization](nakamoto-upgrade/nakamoto-in-depth/chain-structure-and-synchronization.md)
* [Block Structure and Validation](nakamoto-upgrade/nakamoto-in-depth/block-structure-and-validation.md)
* [Transactions](nakamoto-upgrade/nakamoto-in-depth/transactions.md)
* [Changes to PoX and Clarity](nakamoto-upgrade/nakamoto-in-depth/changes-to-pox-and-clarity.md)
* [Financial Incentives and Security Budget](nakamoto-upgrade/nakamoto-in-depth/financial-incentives-and-security-budget.md)
* [Testnets](nakamoto-upgrade/testnets/README.md)
* [Neon](nakamoto-upgrade/testnets/neon.md)
* [Argon](nakamoto-upgrade/testnets/argon.md)
* [Running a Signer](nakamoto-upgrade/running-a-signer.md)
* [Stacking Flow](nakamoto-upgrade/stacking-flow.md)

## 🎓 Stacks 101 (Pre-Nakamoto) <a href="#stacks-101" id="stacks-101"></a>

* [What Is Stacks?](stacks-101/what-is-stacks.md)
* [SIPs](stacks-101/sips.md)
* [Whitepapers](stacks-101/whitepapers.md)
* [Bitcoin Connection](stacks-101/bitcoin-connection.md)
* [Proof of Transfer](stacks-101/proof-of-transfer.md)
* [Mining](stacks-101/mining.md)
* [Network](stacks-101/network.md)
* [API](stacks-101/api.md)
* [Accounts](stacks-101/accounts.md)
* [Authentication](stacks-101/authentication.md)
* [Bitcoin Name System](stacks-101/bitcoin-name-system.md)
* [Transactions](stacks-101/transactions.md)
* [Post Conditions](stacks-101/post-conditions.md)
* [Stacking](stacks-101/stacking.md)
* [Testnet](stacks-101/testnet.md)
* [Technical Specifications](stacks-101/technical-specifications.md)

## 🛠 Tutorials

* [Hello Stacks (Quickstart Tutorial)](tutorials/hello-stacks-quickstart-tutorial.md)
* [Bitcoin Integration](tutorials/bitcoin-integration/README.md)
* [Sending Bitcoin with Leather Wallet](tutorials/bitcoin-integration/sending-bitcoin-with-leather-wallet.md)
* [Verifying a Bitcoin Transaction](tutorials/bitcoin-integration/verifying-a-bitcoin-transaction.md)
* [Parsing a Bitcoin Transaction](tutorials/bitcoin-integration/parsing-a-bitcoin-transaction.md)
* [Tokens](tutorials/tokens/README.md)
* [Creating a NFT](tutorials/tokens/creating-a-nft.md)
* [Creating a Fungible Token](tutorials/tokens/creating-a-fungible-token.md)
* [Frontend](tutorials/frontend/README.md)
* [Post Conditions with Stacks.js](tutorials/frontend/post-conditions-with-stacks.js.md)
* [Authentication with Stacks.js](tutorials/frontend/authentication-with-stacks.js.md)
* [Sending Transactions with Stacks.js](tutorials/frontend/sending-transactions-with-stacks.js.md)
* [Community Tutorials](tutorials/community-tutorials.md)

## 👓 Clarity

* [Overview](clarity/overview.md)
* [Clarity Crash Course](clarity/clarity-crash-course.md)
* [Types](clarity/types.md)
* [Functions](clarity/functions.md)
* [Keywords](clarity/keywords.md)
* [Decidability](clarity/decidability.md)
* [Example Contracts](clarity/example-contracts/README.md)
* [Audited Starter Contracts](clarity/example-contracts/audited-starter-contracts.md)
* [Stacking](clarity/example-contracts/stacking.md)
* [BNS](clarity/example-contracts/bns.md)

## ⛓ sBTC

* [Introduction](sbtc/introduction.md)
* [sBTC Design](sbtc/sbtc-design/README.md)
* [sBTC Requests and Responses](sbtc/sbtc-design/sbtc-requests-and-responses/README.md)
* [Commit-Reveal System](sbtc/sbtc-design/sbtc-requests-and-responses/commit-reveal-system.md)
* [Clarity Contracts](sbtc/sbtc-design/sbtc-requests-and-responses/clarity-contracts.md)
* [Stacker Responsibilities](sbtc/sbtc-design/stacker-responsibilities.md)
* [Security Model](sbtc/sbtc-design/security-model.md)
* [User Guides](sbtc/user-guides/README.md)
* [How to Deposit and Withdraw](sbtc/user-guides/how-to-deposit-and-withdraw.md)
* [How to Participate as a Stacker](sbtc/user-guides/how-to-participate-as-a-stacker.md)
* [Developer Guides](sbtc/developer-guides/README.md)
* [Quickstart](sbtc/developer-guides/quickstart.md)
* [Local Environment Setup](sbtc/developer-guides/local-environment-setup.md)
* [End to End Tutorial](sbtc/developer-guides/end-to-end-tutorial.md)
* [Initiating a Deposit](sbtc/developer-guides/initiating-a-deposit.md)
* [Initiating a Withdrawal](sbtc/developer-guides/initiating-a-withdrawal.md)
* [sBTC Releases](sbtc/sbtc-releases/README.md)
* [sBTC 0.1](sbtc/sbtc-releases/sbtc-0.1.md)
* [sBTC 1.0](sbtc/sbtc-releases/sbtc-1.0.md)
* [sBTC 1.1](sbtc/sbtc-releases/sbtc-1.1.md)

## 💻 Stacks In-Depth

* [Nodes and Miners](stacks-in-depth/nodes-and-miners/README.md)
* [Run a Node with Docker](stacks-in-depth/nodes-and-miners/run-a-node-with-docker.md)
* [Run a Node with Digital Ocean](stacks-in-depth/nodes-and-miners/run-a-node-with-digital-ocean.md)
* [Run a Node with a Hosted Provider](stacks-in-depth/nodes-and-miners/run-a-node-with-a-hosted-provider.md)
* [Run a Node with Quicknode](stacks-in-depth/nodes-and-miners/run-a-node-with-quicknode.md)
* [Stacks Node Configuration](stacks-in-depth/nodes-and-miners/stacks-node-configuration.md)
* [Mine Testnet Stacks Tokens](stacks-in-depth/nodes-and-miners/mine-testnet-stacks-tokens.md)
* [Mine Mainnet Stacks Tokens](stacks-in-depth/nodes-and-miners/mine-mainnet-stacks-tokens.md)
* [Verify Miner](stacks-in-depth/nodes-and-miners/verify-miner.md)
* [Miner Costs and Fees](stacks-in-depth/nodes-and-miners/miner-costs-and-fees.md)
* [Miner Prerequisites](stacks-in-depth/nodes-and-miners/miner-prerequisites.md)
* [Gaia](stacks-in-depth/gaia/README.md)
* [Configuration](stacks-in-depth/gaia/configuration.md)
* [Deploy Gaia Hub](stacks-in-depth/gaia/deploy-gaia-hub.md)
* [Amazon EC2](stacks-in-depth/gaia/amazon-ec2.md)
* [Linux](stacks-in-depth/gaia/linux.md)
* [Mac OS](stacks-in-depth/gaia/mac-os.md)
108 changes: 108 additions & 0 deletions clarity/clarity-crash-course.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Clarity Crash Course

You now understand why Clarity exists and what problems it was designed to solve. :::note If you didn't read the previous section, go ahead and do that first. :::

Now let's do a really quick introduction to Clarity so you can familiarize yourself with the language and syntax.

This crash course is designed for people who have some experience with programming but are new to Clarity. You don't need smart contract development experience, but if you do, with something like Solidity, you'll pick this up really quick.

Once you've familiarized yourself with the language, if you'd like to continue your journey and master Clarity to become a smart contract developer, we recommend either the book, [Clarity of Mind](https://book.clarity-lang.org/title-page.html), or the course, [Clarity Universe](https://clarity-lang.org/universe), which has both a self-paced and guided cohort-based version.

### Your First Clarity Smart Contract

We're going to build a basic Clarity smart contract using [Clarity Tools](https://clarity.tools/code/new), so you won't have to install anything for this introduction.

Visit that link, and it will open up a new contract for you.

Already we can take a look at a few basic features of both Clarity and Clarity Tools. First, on the left you'll see that our Clarity code is being evaluated in real-time for us. This is really nice for experimenting and demonstrating basic Clarity code.

Next up we can see our first bit of Clarity code.

Those two semicolons are how we denote comments in Clarity.

Then the next line down we have a public function declaration.

Here is out first glimpse of Clarity's syntax, which may be new to you depending on your development background.

For those new to Clarity, it's a little weird and uncomfortable at first, but one of the core design tenets of Clarity is simplicity and readability, and the more you work with it the more you come to appreciate the succinctness and _clarity_ (sorry) of the code you are writing.

Clarity takes inspiration from LISP, and you can think of everything in Clarity as a list inside of a list, or an expression inside of an expression. Everything in Clarity is wrapped in parentheses, function definitions, variable declarations, function parameters, etc.

So here we are saying that we want to:

1. Call a function called `define-read-only`. This is a built-in function, one of many that you can refer to in the docs.
2. Pass it a parameter of hello, which corresponds to the method signature type.
3. Pass it a parameter of "Hello", which corresponds to the function body.

You can refer to the [`define-read-only`](https://docs.stacks.co/docs/write-smart-contracts/clarity-language/language-functions#define-read-only) documentation to see these parameters.

Why am I describing this as if we are calling a function? Because we are, and it's an important concept in Clarity that everything is an expression inside of an expression.

Let's expand on this concept a bit by deleting this and writing a new function.

```clarity
(define-data-var count int 0)
(define-public (add-number (number int))
(let
(
(current-count count)
)
(var-set count (+ 1 number))
(ok (var-get count))
)
)
(add-number 5)
```

If you type that into Clarity Tools, you'll see the result that gets printed is 6.

Okay there are actually a lot of Clarity concepts packed into this simple code.

Let's go over what this code is doing, and you'll pick up some Clarity concepts along the way.

The first thing we are doing here is defining a new variable called `count` and setting its initial value to 0.

This will be a persistent state variable, so this is actually getting written to the blockchain. If you are new to smart contract development, the fact that data is persisted within the file like this might take some getting used to.

So if we were to write and deploy this contract (which you can do in the Stacks Explorer if you like), as soon as it gets deployed, it will run through the contract line by line executing anything at the root level.

Remember that Clarity is interpreted, not compiled, so there's not compile step when developing Clarity contracts.

So this `define-data-var` will be evaluated and the `count` variable will be initialized with a value of 0.

Next we are defining a public function called `add-number`, which will be created (but not called) on deploy as well.

:::note In Clarity, we have public, private, and read only functions. Public allow you to modify chain state and can be called from anywhere, private do the same except they can only be called from within the contract, and read only will fail if they attempt to modify state. :::

This function is taking a single parameter, called `number` that is a type of `int`.

Now, what is this `let` business all about? Remember that we said that everything in Clarity is an expression and declaring new functions is just a matter of calling the `define-public` function?

Well the second argument to this is the function body, but it can only evaluate a single expression.

So this `let` function is a way of wrapping a multi-step function into a single argument.

But it does one other crucial thing at the beginning. This line:

```clarity
(current-count count)
```

Sets a variable that only exists in the context of this particular function. So here we are saying, create a new variable called `current-count` and set it equal to the value of `count`.

Then we use that in our actual function body down below.

In the next step we are setting the value of our `count` variable to 1 plus whatever number we passed in. The `+` is just another call to a function where the parameters are the numbers we want to add.

Then, finally, we are returning the new value of `count` with our `ok` response, indicating that the function completed successfully.

Then in the very last line we are actually calling this function, passing in 5.

This was a very brief overview of Clarity just to get your feet wet and give you a taste of how it works.

If you are interested in diving into the details, we highly recommend going through either the [Clarity Book](https://book.clarity-lang.org/title-page.html) or [Clarity Universe](https://clarity-lang.org/universe), depending on your learning style.

If you prefer to dive directly into the docs, you can continue on ahead and check out the types, keywords, and functions available in Clarity, as well as a few sample contracts.
Loading

0 comments on commit 2db4efe

Please sign in to comment.