### Install Bitcoin Core Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Installs Bitcoin Core using Homebrew. This is a prerequisite for running Charms applications. ```shell brew install bitcoin ``` -------------------------------- ### Install jq Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Installs the `jq` command-line JSON processor using Homebrew. `jq` is used to parse the JSON output from `bitcoin-cli`. ```shell brew install jq ``` -------------------------------- ### Install Charms CLI Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Installs the Charms CLI version 0.3.0 using Cargo. It sets a temporary target directory for the build process. ```shell export CARGO_TARGET_DIR=$(mktemp -d)/target cargo install --locked charms --version=0.3.0 ``` -------------------------------- ### Wallet Management Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Commands to create and load a Bitcoin wallet using `bitcoin-cli`. A wallet is necessary for managing keys and transactions. ```shell b createwallet testwallet b loadwallet testwallet ``` -------------------------------- ### Install Prerequisites (macOS) Source: https://github.com/charmsdev/charms/blob/main/charms-lib/README.md Installs LLVM, Rust Wasm target support, and the wasm-bindgen CLI using Homebrew. Ensures LLVM is accessible in the system's PATH. ```sh brew install llvm rustup target add wasm32-unknown-unknown cargo install wasm-bindgen-cli export PATH="/opt/homebrew/opt/llvm/bin:$PATH" ``` -------------------------------- ### Create and Verify Charms App Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Creates a new Charms application named 'my-token' and then prints its verification key. This process is done outside the main `charms` repository. ```shell charms app new my-token cd ./my-token charms app vk ``` -------------------------------- ### Test Charms App: NFT Mint Example Source: https://github.com/charmsdev/charms/blob/main/example-projects/charmix/README.md Demonstrates how to test a Charms application by minting an NFT. This involves setting environment variables for the verification key, input UTXO, and address, then running the minting spell. ```sh export app_vk=$(charms app vk) # set to a UTXO you're spending (you can see what you have by running `b listunspent`) export in_utxo_0="a2889190343435c86cd1c2b70e58efed0d101437a753e154dff1879008898cd2:2" export app_id=$(echo -n "${in_utxo_0}" | sha256sum | cut -d' ' -f1) export addr_0="tb1p3w06fgh64axkj3uphn4t258ehweccm367vkdhkvz8qzdagjctm8qaw2xyv" cat ./spells/mint-nft.yaml | envsubst | charms app run ``` -------------------------------- ### Install Charms CLI using Cargo Source: https://github.com/charmsdev/charms/blob/main/README.md Installs the Charms CLI tool using Cargo, Rust's package manager. It first sets up a temporary target directory for the compilation. ```sh export CARGO_TARGET_DIR=$(mktemp -d)/target cd $(mktemp -d) cargo install --locked charms ``` -------------------------------- ### Alias bitcoin-cli Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Creates a shell alias 'b' for the `bitcoin-cli` command to simplify interactions with the Bitcoin node. ```shell alias b=bitcoin-cli ``` -------------------------------- ### Build and Run Charms App on Testnet Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Builds the Charms application binaries and runs an NFT minting spell on Bitcoin testnet. It uses a specified funding UTXO and logs information during the process. ```shell app_bins=$(charms app build) funding_utxo_id="8c1d638a7ff6b6a977580beec47fcc9b8a93e44893c27ab69935c14e9316a735:1" cat ./spells/mint-nft.yaml | envsubst | RUST_LOG=info charms wallet cast --app-bins=${app_bins} --funding-utxo-id=${funding_utxo_id} ``` -------------------------------- ### Get New Bitcoin Address Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Generates a new Bitcoin address associated with the loaded wallet. This address is used to receive testnet Bitcoin. ```shell b getnewaddress ``` -------------------------------- ### Submit Bitcoin Transaction Package Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Submits a package of Bitcoin transactions to the network. This typically includes a commit transaction and an execute transaction generated by Charms. ```shell b submitpackage '["020000000001015f...57505efa00000000", "020000000001025f...e14c656300000000"]' ``` -------------------------------- ### Run Charms Library Tests Source: https://github.com/charmsdev/charms/blob/main/charms-lib/README.md Executes the tests for the Charms library using Node.js. This command assumes the test file is correctly located and the build has been completed. ```sh node test/extractAndVerifySpell.node.test.js ``` -------------------------------- ### Get Charms Application Verification Key Source: https://github.com/charmsdev/charms/blob/main/example-projects/charmix/README.md Retrieves the verification key for the Charms application. This key is essential for verifying the application's integrity. ```sh charms app vk ``` -------------------------------- ### Bitcoin Node Configuration Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Provides the essential `bitcoin.conf` settings for a Bitcoin node to interact with Charms. These settings enable server mode, testnet, transaction indexing, and specific address types. ```plaintext server=1 testnet4=1 txindex=1 addresstype=bech32m changetype=bech32m ``` -------------------------------- ### Build Charms Library for WebAssembly Source: https://github.com/charmsdev/charms/blob/main/charms-lib/README.md Compiles the Charms library in release mode for the WebAssembly target. It then uses wasm-bindgen to generate Node.js compatible WebAssembly bindings. ```sh RUSTFLAGS="-C target-cpu=generic" cargo build --release --target wasm32-unknown-unknown wasm-bindgen --out-dir target/wasm-bindgen-nodejs --target nodejs ../target/wasm32-unknown-unknown/release/charms_lib.wasm ``` -------------------------------- ### Run NFT Minting Spell Source: https://github.com/charmsdev/charms/blob/main/hello-world.md Executes an NFT minting spell using a Charms application. It sets environment variables for the application's verification key and an input UTXO, then pipes the modified spell YAML to `charms app run`. ```shell export app_vk=$(charms app vk) export in_utxo_0="dc78b09d767c8565c4a58a95e7ad5ee22b28fc1685535056a395dc94929cdd5f:1" export app_id=$(sha256 -s "${in_utxo_0}") export addr_0=$(b getnewaddress) cat ./spells/mint-nft.yaml | envsubst | charms app run ``` -------------------------------- ### Create New Charms App Source: https://github.com/charmsdev/charms/blob/main/charms-sdk/README.md Command to initialize a new Charms application. Creates a new directory with a basic project structure. ```sh charms app new my-app ``` -------------------------------- ### Create a New Token App with Charms CLI Source: https://github.com/charmsdev/charms/blob/main/README.md Demonstrates how to create a new token application using the Charms CLI. It generates a new app named 'my-token', changes the directory into it, and lists the created files. ```sh charms app new my-token cd ./my-token ls -l ``` -------------------------------- ### Display Charms CLI Help Information Source: https://github.com/charmsdev/charms/blob/main/README.md Fetches and displays the help message for the Charms CLI, providing an overview of available commands and options. ```sh charms --help ``` -------------------------------- ### Build Charms Application Source: https://github.com/charmsdev/charms/blob/main/example-projects/charmix/README.md Builds the Charms application into a Wasm binary. The output Wasm binary is typically found in the target directory. ```sh charms app build ``` -------------------------------- ### Main Entry Point for Charms App (Rust) Source: https://github.com/charmsdev/charms/blob/main/charms-sdk/README.md The primary Rust code for a Charms application, using the charms_sdk::main! macro to define the application's entry point. ```rust #![no_main] charms_sdk::main!(my_app::app_contract); ``` -------------------------------- ### Charms App Cargo.toml Dependencies Source: https://github.com/charmsdev/charms/blob/main/charms-sdk/README.md Specifies the necessary dependency for a Charms application in the Cargo.toml file, including the charms-sdk version. ```toml [dependencies] charms-sdk = { version = "0.3.0" } ``` -------------------------------- ### Token Metadata Structure (YAML) Source: https://github.com/charmsdev/charms/blob/main/CHIPs/CHIP-0420/README.md This YAML structure defines the recommended minimum fields for reference NFT data in Charms. It includes optional fields like name, description, ticker, URLs for images and general information, image hashes, decimal places for fungible tokens, and references to upstream data. ```yaml name: ? description: ? ticker: ? url: ? image: ? image_hash: ? decimals: ? ref: ? ``` -------------------------------- ### Charms App Contract Logic (Rust) Source: https://github.com/charmsdev/charms/blob/main/charms-sdk/README.md The core contract function for a Charms app. It handles different transaction types (NFT, TOKEN) by dispatching to specific contract satisfaction functions. ```rust use charms_sdk::data::{ check, App, Data, Transaction, NFT, TOKEN, }; pub fn app_contract(app: &App, tx: &Transaction, x: &Data, w: &Data) -> bool { match app.tag { NFT => { check!(nft_contract_satisfied(app, tx, x, w)) } TOKEN => { check!(token_contract_satisfied(app, tx, x, w)) } _ => todo!(), } true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.