Skip to content

EasyA-Tech/stacks-handbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

The Stacks handbook.

Welcome. This is EasyA's legendary handbook. If you want to learn Stacks like a legend, then you're in the right place.

Purpose

This handbook serves as a guide to the Stacks ecosystem, geared towards those just joining for the first time. It isn't just a beginners' handbook; it's a legendary handbook. Even if you've already immersed yourself in the ecosystem, you'll find tons of helpful tidbits around here!

The EasyA App

Of course, the best place to start is always the EasyA app! Download it here for the fastest and most fun way to learn about Stacks. Download it directly right here!

Table of Contents

Introduction

What is Stacks:

  • Stacks Overview - Fundamentals of Stacks and its integration with Bitcoin.

Getting Started

The no-fluff starter:

Core Concepts

Explanation of fundamental concepts in the Stacks ecosystem:

Development Tools

Key tools and environments for Stacks:

  • Clarinet - CLI tool for developing and testing Clarity smart contracts.
  • Hiro Platform - Browser-based IDE for streamlined Clarity development.
  • Stacks.js - Powerful JavaScript libraries for interacting with the Stacks blockchain.

Smart Contracts

How to write and deploy smart contracts on Stacks:

Stacks Blockchain

Going into the blockchain level:

  • Stacks API - Comprehensive API for interacting with the Stacks blockchain and retrieving data.
  • Hiro Explorer - User-friendly interface for browsing Stacks blockchain data.
  • STX Scan - Feature-rich explorer for Stacks transactions and blockchain information.

Ecosystem Projects

Cool projects built on Stacks:

  • ALEX - Open-source DeFi protocol modeled on the world's financial markets.
  • Arkadiko - Open source protocol that mints a stablecoin, generating Bitcoin yield.
  • Bitflow - The decentralized exchange for Bitcoiners.
  • Blocksurvey - AI-driven survey platform with focus on data ownership and privacy.
  • btc.us - An application for .btc names.
  • Console - Decentralized community application.
  • Gamma - Explore, collect, and sell NFTs secured by Bitcoin.
  • GoSats - Bitcoin Cashback Rewards application that enables stacking fractional bitcoin every time you shop.
  • Hermetica - A Bitcoin-backed, yield-bearing synthetic dollar protocol.
  • Light Finance - The only stablecoin with native yield for Bitcoin.
  • MultiSafe - MultiSafe is a shared crypto vault for managing Stacks (STX) and Bitcoin (BTC).
  • Owl Link - An application to create linking page for BNS names.
  • Sigle - De-centralised and open-source Web 3.0 writing platform.
  • Stacking DAO - Liquid stacking on Stacks.
  • STX20 - The STX20 protocol introduces a novel approach to creating and sharing digital artifacts on the Stacks blockchain.
  • Velar - Velar is a multi-feature DeFi app with Bitcoin finality, built on Stacks.
  • Zest Protocol - Zest Protocol is a lending protocol, built for Bitcoin.

Resources

Extra stuff:

  • Clarity Universe - Immersive learning experience for mastering Clarity development.
  • Clarity of Mind Book - Comprehensive guide to writing efficient and secure Clarity smart contracts.

Handy Code Snippets

Some code snippets which you can copy/paste to kickstart your project:

Clarity Smart Contract

;; Define a simple counter contract

;; Define a data var to store the counter
(define-data-var counter uint u0)

;; Public function to get the current count
(define-read-only (get-count)
  (var-get counter))

;; Public function to increment the counter
(define-public (increment)
  (begin
    (var-set counter (+ (var-get counter) u1))
    (ok (var-get counter))))

;; Public function to decrement the counter
(define-public (decrement)
  (begin
    (if (> (var-get counter) u0)
      (var-set counter (- (var-get counter) u1))
      (var-set counter u0))
    (ok (var-get counter))))

Interacting with Stacks using JavaScript

import { StacksTestnet } from '@stacks/network';
import { callReadOnlyFunction, cvToValue, uintCV } from '@stacks/transactions';

// Set up the network (testnet in this example)
const network = new StacksTestnet();

// Define contract details
const contractAddress = 'ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH';
const contractName = 'counter';
const functionName = 'get-count';

// Call a read-only function
async function getCount() {
  const result = await callReadOnlyFunction({
    network,
    contractAddress,
    contractName,
    functionName,
    functionArgs: [],
    senderAddress: contractAddress,
  });
  
  console.log('Current count:', cvToValue(result));
}

getCount();

These examples showcase:

  1. A simple Clarity smart contract for a counter.
  2. JavaScript code to interact with a Stacks smart contract.

Contributing

We welcome contributions to make this handbook even more legendary! Here's how you can contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-addition)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-addition)
  6. Create a new Pull Request

Please ensure your contributions align with our code of conduct and contribution guidelines.

Credit/Inspiration

This handbook was inspired by the famous awesome lists by sindresorhus. We need awesome lists for Web3 ecosystems, with more of a hacker's guide to how they work. This is the answer to that need.

About

EasyA's legendary handbook.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published