├── CAT20 ├── CAT20_Token_Mint_Guide.md ├── CAT_CLI_Guide.md └── OP_CAT.md ├── Ordinal ├── BRC20-Token-Management.md └── README.md ├── README.md ├── Rune └── README.md └── sCrypt └── README.md /CAT20/CAT20_Token_Mint_Guide.md: -------------------------------------------------------------------------------- 1 | ## How to Mint CAT20 Token Based on CAT Protocol of Fractal Mainnet 2 | 3 | The following are step-by-step instructions on how to mint your CAT20 token on the Fractal Mainnet. This guide provides detailed steps for setting up the necessary environment, installing required components, and executing the minting process. 4 | 5 | **Prerequisites** 6 | 7 | Before beginning, ensure that you have: 8 | 9 | - A system running a supported operating system with internet connectivity. 10 | - Docker and Docker Compose installed. 11 | - Administrative privileges to install software packages. 12 | 13 | ### Step-by-Step Instructions 14 | 15 | #### 1. Install Docker 16 | 17 | Begin by installing Docker on your system to manage containerized applications. 18 | 19 | ```bash 20 | sudo apt update && sudo apt install -y curl 21 | curl -fsSL https://get.docker.com -o get-docker.sh 22 | sudo sh get-docker.sh 23 | ``` 24 | 25 | #### 2. Install Docker Compose 26 | 27 | Docker Compose is essential for defining and running multi-container Docker applications. It can be installed using the following commands: 28 | 29 | ```bash 30 | sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 31 | sudo chmod +x /usr/local/bin/docker-compose 32 | ``` 33 | 34 | #### 3. Install Node.js and Yarn 35 | 36 | Node.js and Yarn are required for managing dependencies and scripts. 37 | 38 | - Install `npm`: 39 | 40 | ```bash 41 | sudo apt-get install npm -y 42 | ``` 43 | 44 | - Globally install the `n` package manager and switch to a stable Node.js version: 45 | 46 | ```bash 47 | sudo npm i n -g 48 | sudo n stable 49 | ``` 50 | 51 | - Globally install Yarn: 52 | 53 | ```bash 54 | sudo npm i -g yarn 55 | ``` 56 | 57 | #### 4. Clone the CAT Protocol Repository 58 | 59 | Download the CAT Protocol repository containing all necessary code. 60 | 61 | ```bash 62 | git clone https://github.com/CATProtocol/cat-token-box && cd cat-token-box 63 | ``` 64 | 65 | #### 5. Build and Set Up the Project 66 | 67 | Install project dependencies and build the source code: 68 | 69 | ```bash 70 | sudo yarn install && yarn build 71 | ``` 72 | 73 | #### 6. Run the Fractal Bitcoin Node 74 | 75 | Navigate to the tracker directory, assign necessary permissions, and start the Fractal Bitcoin node using Docker Compose. 76 | 77 | ```bash 78 | cd packages/tracker 79 | sudo chmod 777 docker/data && sudo chmod 777 docker/pgdata 80 | sudo docker compose up -d 81 | ``` 82 | 83 | #### 7. Build the Docker Image 84 | 85 | From the project root directory, build the necessary Docker image. 86 | 87 | ```bash 88 | cd $HOME/cat-token-box && sudo docker build -t tracker:latest . 89 | ``` 90 | 91 | #### 8. Start the Tracker Container 92 | 93 | Run the tracker container to facilitate communication with the blockchain network. 94 | 95 | ```bash 96 | sudo docker run -d \ 97 | --name tracker \ 98 | --add-host="host.docker.internal:host-gateway" \ 99 | -e DATABASE_HOST="host.docker.internal" \ 100 | -e RPC_HOST="host.docker.internal" \ 101 | -p 3000:3000 \ 102 | tracker:latest 103 | ``` 104 | If the cli command is not working well, you have to restart tracker by using this command 105 | 106 | ``` 107 | docker restart tracker 108 | ``` 109 | #### 9. Configure Your Wallet 110 | 111 | Navigate to the CLI directory and create a configuration file for managing wallet settings. 112 | 113 | ```bash 114 | cd $HOME/cat-token-box/packages/cli 115 | ``` 116 | 117 | Create a `config.json` using the following template: 118 | 119 | ```bash 120 | cat < config.json 121 | { 122 | "network": "fractal-mainnet", 123 | "tracker": "http://127.0.0.1:3000", 124 | "dataDir": ".", 125 | "maxFeeRate": 30, 126 | "rpc": { 127 | "url": "http://127.0.0.1:8332", 128 | "username": "Leionion", 129 | "password": "Qazxswedc" 130 | } 131 | } 132 | EOF 133 | ``` 134 | 135 | #### 10. Create or Import a Wallet 136 | 137 | Use Yarn CLI to create a new wallet or import an existing Taproot Bitcoin wallet. 138 | 139 | - To create a new wallet: 140 | 141 | ```bash 142 | sudo yarn cli wallet create 143 | ``` 144 | 145 | - To import an existing Taproot wallet, modify the following command with your mnemonic phrase: 146 | 147 | Here, Hdpath("m/86'/0'/0'/0/0") is corresponding to Unisat wallet first account's taproot address. 148 | 149 | ```bash 150 | cat < wallet.json 151 | { 152 | "accountPath": "m/86'/0'/0'/0/0", 153 | "name": "leionion", 154 | "mnemonic": "MNEMONIC (12 words)" 155 | } 156 | EOF 157 | ``` 158 | 159 | Retrieve your wallet address using: 160 | 161 | ```bash 162 | sudo yarn cli wallet address 163 | ``` 164 | 165 | #### 11. Obtain $FB CAT20 Tokens 166 | 167 | Using this command, you can get your CAT20 token in your taproot wallet. 168 | 169 | ```bash 170 | sudo yarn cli mint -i 1be69768c1120bd8f7477d7f1a14dc7c5b5c1c26c37306a660ad9fe472d2d36c_0 5 --fee-rate 120 171 | ``` 172 | 173 | Here, 1be69768c1120bd8f7477d7f1a14dc7c5b5c1c26c37306a660ad9fe472d2d36c_0 meaning is inscription_id(transaction_id + vout). 174 | To mint specific token (token ID : 1be69768c1120bd8f7477d7f1a14dc7c5b5c1c26c37306a660ad9fe472d2d36c_0), you have to own minter UTXO for that token ID (1be69768c1120bd8f7477d7f1a14dc7c5b5c1c26c37306a660ad9fe472d2d36c_0)... 175 | 176 | #### 12. Check your $FB CAT20 Token 177 | 178 | ```bash 179 | sudo yarn cli wallet balances 180 | ``` 181 | 182 | The subsequent manual will focus on the CAT Protocol CLI Command Guide. In the [CAT_CLI_Guide](CAT_CLI_Guide.md), I will provide a comprehensive explanation on how to utilize the CAT protocol CLI commands. 183 | 184 | 185 | ### Contact info: 186 | 187 | If you encounter any new technical issues or need development inquiries, please contact me. 188 | 189 | - Telegram: https://t.me/inscNix/ 190 | - Twitter: https://x.com/chain_sats/ 191 | 192 | -------------------------------------------------------------------------------- /CAT20/CAT_CLI_Guide.md: -------------------------------------------------------------------------------- 1 | ## Ultimate Guide on Using the CAT CLI Command 2 | 3 | The CAT CLI provides a comprehensive interface for interacting with CATs (Chia Asset Tokens). Below is a step-by-step guide to using the CAT command line interface effectively: 4 | 5 | #### Step 1: Configuration 6 | 7 | Begin by copying the example configuration file to your working configuration file. This step ensures that your CLI commands will use the correct settings. 8 | 9 | - **Copy Configuration File**: Duplicate the provided `config.example.json` file and rename it to `config.json`. 10 | - **Update Configuration**: Modify `config.json` with your specific configuration settings as needed for your environment. 11 | 12 | The CLI commands will default to using `config.json` in the current directory. However, if you prefer to use a different configuration file, specify it using the `--config=your.json` option. 13 | 14 | #### Step 2: Creating a Wallet 15 | 16 | To create a new wallet, execute the following command: 17 | 18 | ```bash 19 | yarn cli wallet create 20 | ``` 21 | 22 | Upon execution, you should receive an output similar to the following: 23 | 24 | ``` 25 | What is the mnemonic value of your account? (default: generate a new mnemonic) ******** 26 | Your wallet mnemonic is: ******** 27 | exporting address to the RPC node ... 28 | successfully. 29 | ``` 30 | 31 | This output indicates that a mnemonic for your wallet has been generated, which is crucial for recovering your wallet if necessary. Ensure to save this mnemonic in a secure location. 32 | 33 | #### Step 3: Displaying Your Address 34 | 35 | To show the address of your wallet, use the following command: 36 | 37 | ```bash 38 | yarn cli wallet address 39 | ``` 40 | 41 | The expected output will be similar to: 42 | 43 | ``` 44 | Your address is bc1plfkwa8r7tt8vvtwu0wgy2m70d6cs7gwswtls0shpv9vn6h4qe7gqjjjf86 45 | ``` 46 | 47 | This address is where you'll receive funds and interact with specific CATs. 48 | 49 | #### Step 4: Funding Your Address 50 | 51 | To perform transactions using your wallet, deposit a certain amount of satoshis to the displayed address. This step is essential for enabling further interactions with the network. 52 | 53 | #### Step 5: Displaying Token Balances 54 | 55 | You can check the balances of your tokens within the wallet using the following command: 56 | 57 | ```bash 58 | yarn cli wallet balances 59 | ``` 60 | 61 | The output should look like this: 62 | 63 | ``` 64 | ┌──────────────────────────────────────────────────────────────────────┬────────┬─────────┐ 65 | │ tokenId │ symbol │ balance │ 66 | ┼──────────────────────────────────────────────────────────────────────┼────────┼─────────┤ 67 | │ '45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b_0' │ 'CAT' │ '18.91' │ 68 | ┴──────────────────────────────────────────────────────────────────────┴────────┴─────────┘ 69 | ``` 70 | 71 | This tabular representation provides a clear view of each token's ID, symbol, and the respective balance available in your wallet. 72 | 73 | #### 6. Deploy Token 74 | 75 | To deploy a token within the CAT protocol, you have the option to utilize a metadata JSON file or specify parameters directly through command line options. 76 | 77 | ##### Deploy Using Metadata JSON: 78 | 79 | To deploy a token with pre-defined metadata, include the JSON file specifying the necessary details: 80 | 81 | ```bash 82 | yarn cli deploy --metadata=example.json 83 | ``` 84 | 85 | Below is an example of the `example.json` file: 86 | 87 | ```json 88 | { 89 | "name": "cat", 90 | "symbol": "CAT", 91 | "decimals": 2, 92 | "max": "21000000", 93 | "limit": "5", 94 | "premine": "0" 95 | } 96 | ``` 97 | 98 | ##### Deploy With Command Line Options: 99 | 100 | Alternatively, deploy your token by specifying attributes directly in the command line: 101 | 102 | ```bash 103 | yarn cli deploy --name=cat --symbol=CAT --decimals=2 --max=21000000 --premine=0 --limit=5 104 | ``` 105 | 106 | **Expected Output:** 107 | Upon successful deployment, you will receive confirmation similar to the following: 108 | 109 | ``` 110 | Token CAT has been deployed. 111 | TokenId: 45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b_0 112 | Genesis txid: 45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b 113 | Reveal txid: 9a3fcb5a8344f53f2ba580f7d488469346bff9efe7780fbbf8d3490e3a3a0cd7 114 | ``` 115 | 116 | **Important:** Ensure that the product of `max` and 10 raised to the power of `decimals` is less than 2^31, due to constraints of Bitcoin Script which supports only 32-bit signed integers. Efforts are underway to extend this support to 64-bit or larger integers. 117 | 118 | #### 7. Mint Token 119 | 120 | The minting process allows for the creation of new tokens. If the `amount` parameter is not specified, the default is to mint the number of tokens specified by `limit`. 121 | 122 | ```bash 123 | yarn cli mint -i [tokenId] [amount?] 124 | ``` 125 | 126 | **Expected Output:** 127 | Upon successful minting, you will see a confirmation like: 128 | 129 | ``` 130 | Minting 5.00 CAT tokens in txid: 4659529141de4996ad8482910ef3e0cf63665c39e62b86f17d5d398b5748b66b ... 131 | ``` 132 | 133 | **Note:** Due to UTXO contention, there is a possibility of a minting failure if another user attempts to mint simultaneously with the same minter UTXO. In case of failure, retry until success is achieved. For more details, refer to [UTXO contention](https://catprotocol.org/cat20#parallel-mint). 134 | 135 | #### 8. Send Token 136 | 137 | Sending tokens to another address is straightforward. Specify the tokenId, receiver's address, and the amount to send. 138 | 139 | ```bash 140 | yarn cli send -i [tokenId] [receiver] [amount] 141 | ``` 142 | 143 | **Expected Output:** 144 | Upon successful sending, you will receive an output along the lines of: 145 | 146 | ``` 147 | Sending 1.11 CAT tokens to bc1pmc274s6lalf6afrll2e23m2qmk50dwaj6srjupe5vyu4dcy66zyss2r3dy 148 | in txid: 94e3254c1237ba7cd42eaeeae713c646ee5dd1cd6c4dd6ef07241d5336cd2aa7 149 | ``` 150 | 151 | ### Fee Rate 152 | 153 | For the `deploy`, `mint`, and `send` commands, you can specify a fee rate by using the `--fee-rate` option to customize the transaction fees according to network conditions. 154 | 155 | 156 | ### Contact info: 157 | 158 | If you encounter any new technical issues or need development inquiries, please contact me. 159 | 160 | - Telegram: https://t.me/inscNix/ 161 | - Twitter: https://x.com/chain_sats/ 162 | 163 | -------------------------------------------------------------------------------- /CAT20/OP_CAT.md: -------------------------------------------------------------------------------- 1 | # CAT-20 Token Standard: OP_CAT Opcode Guide 2 | 3 | ## Introduction 4 | 5 | The CAT-20 token standard introduces a innovative framework for managing fungible tokens on the Bitcoin blockchain, leveraging the OP_CAT opcode for efficient and streamlined token operations. This provides an in-depth guide on how the OP_CAT opcode functions within the CAT-20 standards, and offers practical examples for deploying, minting, and transferring tokens. 6 | 7 | ## How OP_CAT Works 8 | 9 | OP_CAT plays a crucial role in the CAT-20 protocol, facilitating the concatenation of values on the Bitcoin stack, which is essential for various token operations: 10 | 11 | 1. **Stack Preparation**: Components of a token operation, such as the protocol identifier, operation type, and ticker, are sequentially pushed onto the Bitcoin stack. 12 | 2. **Concatenation Process**: Using OP_CAT, the script concatenates the top two stack items, pushing the result back onto the stack. This continues iteratively until the entire operation string is constructed. 13 | 3. **Final Result**: The concatenated string represents the token operation—deployment, minting, or transfer—and is inscribed on the blockchain for execution. 14 | 15 | ## Significance of CAT-20 16 | 17 | The CAT-20 standard marks a significant advancement in token management on Bitcoin by integrating the OP_CAT opcode, which reduces reliance on off-chain systems and enhances Bitcoin's native scripting capabilities. It is a versatile protocol that encourages community participation and developer innovation. 18 | 19 | ## Deploying a CAT-20 Token 20 | 21 | To deploy a new CAT-20 token, initialize it with parameters like ticker, maximum supply, mint limit, and decimal precision. 22 | 23 | ### Deployment Script 24 | 25 | ```shell 26 | OP_FALSE OP_IF 27 | OP_PUSH "ord" 28 | OP_PUSH 1 29 | OP_PUSH "text/plain;charset=utf-8" 30 | OP_PUSH 0 31 | 32 | OP_PUSH "cat20:" 33 | OP_CAT 34 | 35 | OP_PUSH "deploy:" 36 | OP_CAT 37 | 38 | OP_PUSH "CAT=" 39 | OP_CAT 40 | 41 | OP_PUSH "210000000," 42 | OP_CAT 43 | 44 | OP_PUSH "lim=1," 45 | OP_CAT 46 | 47 | OP_PUSH "dec=8" 48 | OP_CAT 49 | 50 | OP_ENDIF 51 | ``` 52 | 53 | **Concatenated String**: `"cat20:deploy:CAT=210000000,lim=1,dec=8"` 54 | 55 | This script, upon inscription, deploys a new CAT-20 token with specified parameters. 56 | 57 | ## Minting CAT-20 Tokens 58 | 59 | Minting involves creating new tokens according to the limits established during deployment. 60 | 61 | ### Minting Script 62 | 63 | ```shell 64 | OP_FALSE OP_IF 65 | OP_PUSH "ord" 66 | OP_PUSH 1 67 | OP_PUSH "text/plain;charset=utf-8" 68 | OP_PUSH 0 69 | 70 | OP_PUSH "cat20:" 71 | OP_CAT 72 | 73 | OP_PUSH "mint:" 74 | OP_CAT 75 | 76 | OP_PUSH "CAT=" 77 | OP_CAT 78 | 79 | OP_PUSH "1" 80 | OP_CAT 81 | 82 | OP_ENDIF 83 | ``` 84 | 85 | **Concatenated String**: `"cat20:mint:CAT=1"` 86 | 87 | This script mints 1 CAT token, complying with the deployment limits. 88 | 89 | ## Transferring CAT-20 Tokens 90 | 91 | Transferring tokens moves a specific amount from one wallet to another. 92 | 93 | ### Transfer Script 94 | 95 | ```shell 96 | OP_FALSE OP_IF 97 | OP_PUSH "ord" 98 | OP_PUSH 1 99 | OP_PUSH "text/plain;charset=utf-8" 100 | OP_PUSH 0 101 | 102 | OP_PUSH "cat20:" 103 | OP_CAT 104 | 105 | OP_PUSH "transfer:" 106 | OP_CAT 107 | 108 | OP_PUSH "CAT=" 109 | OP_CAT 110 | 111 | OP_PUSH "5" 112 | OP_CAT 113 | 114 | OP_ENDIF 115 | ``` 116 | 117 | **Concatenated String**: `"cat20:transfer:CAT=5"` 118 | 119 | This script transfers 5 CAT tokens from the sender to the receiver. 120 | 121 | ## Advanced Example: Combined Operations 122 | 123 | For complex scenarios, mint and transfer operations can be combined into a single script. 124 | 125 | ### Combined Operations Script 126 | 127 | ```shell 128 | OP_FALSE OP_IF 129 | OP_PUSH "ord" 130 | OP_PUSH 1 131 | OP_PUSH "text/plain;charset=utf-8" 132 | OP_PUSH 0 133 | 134 | OP_PUSH "cat20:" 135 | OP_CAT 136 | 137 | OP_PUSH "mint:" 138 | OP_CAT 139 | 140 | OP_PUSH "CAT=" 141 | OP_CAT 142 | 143 | OP_PUSH "1" 144 | OP_CAT 145 | 146 | OP_PUSH "cat20:" 147 | OP_CAT 148 | 149 | OP_PUSH "transfer:" 150 | OP_CAT 151 | 152 | OP_PUSH "CAT=" 153 | OP_CAT 154 | 155 | OP_PUSH "2" 156 | OP_CAT 157 | 158 | OP_ENDIF 159 | ``` 160 | 161 | **Concatenated String**: `"cat20:transfer:CAT=5"` 162 | 163 | **Final Concatenated Strings**: 164 | - Mint: `"cat20:mint:CAT=1"` 165 | - Transfer: `"cat20:transfer:CAT=2"` 166 | 167 | ## Conclusion 168 | 169 | The CAT-20 standard, through the innovative use of the OP_CAT opcode, offers a robust framework for managing tokens directly on the Bitcoin blockchain. This approach minimizes reliance on off-chain solutions, enhancing security, and decentralization. As the community engages with and builds upon this open standard, the potential for novel applications and improvements in token management will continue to expand. 170 | 171 | Developers are encouraged to explore, test, and expand upon the basic scripts provided in this guide to tailor solutions to their specific needs. The evolving landscape of CAT-20 on the Bitcoin blockchain promises to deliver exciting opportunities for innovation and growth in the cryptocurrency ecosystem. 172 | 173 | 174 | ### Contact info: 175 | 176 | If you encounter any new technical issues or need development inquiries, please contact me. 177 | 178 | - Telegram: https://t.me/inscNix/ 179 | - Twitter: https://x.com/chain_sats/ 180 | 181 | -------------------------------------------------------------------------------- /Ordinal/BRC20-Token-Management.md: -------------------------------------------------------------------------------- 1 | # BRC20-Token-Management-Fractal 2 | 3 | In this guide, I just mentioned about core part to deploy/mint/transfer BRC20 tokens on Fractal Ecosystem. 4 | 5 | - **BRC20 Send Function** 6 | 7 | ```typescript 8 | 9 | /** 10 | * reveal a brc20 txid 11 | * 12 | * @param {Signer} keypair - The number of keypair 13 | * @param {string} p - The mark of inscription, like ord 14 | * @param {string} data - The data inside an brc20 15 | * @param {string} txid - The txid used to reveal 16 | * @param {string} network - The network used for taproot address 17 | * @returns {{ p2tr, redeem }} - return an taproot address and its reedem script 18 | */ 19 | export async function brc20_send(keypair: Signer, p: string, data: string, txid: string, network: string) { 20 | const ins_script = [ 21 | toXOnly(keypair.publicKey), 22 | opcodes.OP_CHECKSIG, 23 | opcodes.OP_0, 24 | opcodes.OP_IF, 25 | // in normal situation, p = 'ord' 26 | Buffer.from(p), 27 | 1, 28 | Buffer.from('text/plain;charset=utf-8'), 29 | opcodes.OP_0, 30 | Buffer.from(data), 31 | opcodes.OP_ENDIF 32 | ]; 33 | let { p2tr, redeem } = taproot_address_from_asm(script.compile(ins_script), keypair, network) 34 | let addr = p2tr.address ?? ""; 35 | 36 | const utxos = await getUTXOfromTx(txid, addr) 37 | console.log(`Using UTXO ${utxos.txid}:${utxos.vout}`); 38 | 39 | const psbt = new bitcoin.Psbt({ network: choose_network(network) }); 40 | 41 | psbt.addInput({ 42 | hash: utxos.txid, 43 | index: utxos.vout, 44 | witnessUtxo: { value: utxos.value, script: p2tr.output! }, 45 | }); 46 | 47 | psbt.updateInput(0, { 48 | tapLeafScript: [ 49 | { 50 | leafVersion: redeem.redeemVersion, 51 | script: redeem.output, 52 | controlBlock: p2tr.witness![p2tr.witness!.length - 1], 53 | }, 54 | ], 55 | }); 56 | 57 | psbt.addOutput({ value: utxos.value - 150, address: p2tr.address! }); 58 | psbt.signInput(0, keypair); 59 | 60 | // Finalize and send out tx 61 | txBroadcastVeify(psbt, addr) 62 | } 63 | 64 | 65 | ``` 66 | 67 | - **BRC20 Token Mint Function** 68 | 69 | ```typescript 70 | 71 | // using rpc to send/mint/deploy brc20 transaction 72 | export async function brc20_mint_rpc(receiveAddress: string, feeRate: number, outputValue: number, devAddress: string, devFee: number, brc20Ticker: string, brc20Amount: string, count: number) { 73 | return new Promise((resolve, reject) => { 74 | const data = { 75 | headers: { "Authorization": `Bearer ${API_KEY}` }, 76 | jsonrpc: "2.0", 77 | body: { 78 | receiveAddress, 79 | feeRate, 80 | outputValue, 81 | devAddress, 82 | devFee, 83 | brc20Ticker, 84 | brc20Amount, 85 | count 86 | } 87 | } 88 | let _URL = URL + "inscribe/order/create/brc20-mint" 89 | try { 90 | axios.post(_URL, data).then( 91 | firstResponse => { 92 | console.log(firstResponse.data) 93 | resolve(JSON.parse(JSON.stringify(firstResponse.data)).result) 94 | }); 95 | } catch (error) { 96 | reject(error); 97 | } 98 | }) 99 | } 100 | 101 | 102 | ``` 103 | 104 | - **BRC20 Token Deploy Function** 105 | 106 | ```typescript 107 | 108 | export async function brc20_deploy_rpc(receiveAddress: string, feeRate: number, outputValue: number, devAddress: string, devFee: number, brc20Ticker: string, brc20Max: string, brc20Limit: string) { 109 | return new Promise((resolve, reject) => { 110 | const data = { 111 | headers: { "Authorization": `Bearer ${API_KEY}` }, 112 | jsonrpc: "2.0", 113 | body: { 114 | receiveAddress, 115 | feeRate, 116 | outputValue, 117 | devAddress, 118 | devFee, 119 | brc20Ticker, 120 | brc20Max, 121 | brc20Limit 122 | } 123 | } 124 | let _URL = URL + "inscribe/order/create/brc20-deploy" 125 | try { 126 | axios.post(_URL, data).then( 127 | firstResponse => { 128 | console.log(firstResponse.data) 129 | resolve(JSON.parse(JSON.stringify(firstResponse.data)).result) 130 | }); 131 | } catch (error) { 132 | reject(error); 133 | } 134 | }) 135 | } 136 | 137 | ``` 138 | 139 | - **BRC20 Token Transfer Function** 140 | 141 | ```typescript 142 | 143 | export async function brc20_transfer_rpc(receiveAddress: string, feeRate: number, outputValue: number, devAddress: string, devFee: number, brc20Ticker: string, brc20Amount: string) { 144 | return new Promise((resolve, reject) => { 145 | const data = { 146 | headers: { "Authorization": `Bearer ${API_KEY}` }, 147 | jsonrpc: "2.0", 148 | body: { 149 | receiveAddress, 150 | feeRate, 151 | outputValue, 152 | devAddress, 153 | devFee, 154 | brc20Ticker, 155 | brc20Amount 156 | } 157 | } 158 | let _URL = URL + "inscribe/order/create/brc20-transfer" 159 | try { 160 | axios.post(_URL, data).then( 161 | firstResponse => { 162 | console.log(firstResponse.data) 163 | resolve(JSON.parse(JSON.stringify(firstResponse.data)).result) 164 | }); 165 | } catch (error) { 166 | reject(error); 167 | } 168 | }) 169 | } 170 | 171 | ``` 172 | - **BRC20 Builder Constructor Function** 173 | 174 | ```typescript 175 | 176 | /** 177 | * Basic brc20 builder 178 | * 179 | * @param {Signer} keypair - The number of keypair 180 | * @param {string} data - The data inside an inscription 181 | * @param {string} network - The network used for taproot address 182 | * @returns {{ p2tr, redeem }} - return an taproot address and its reedem script 183 | */ 184 | export function brc_builder(keypair: Signer, data: string, network: string) { 185 | const ins_script = [ 186 | toXOnly(keypair.publicKey), 187 | opcodes.OP_CHECKSIG, 188 | opcodes.OP_FALSE, 189 | opcodes.OP_IF, 190 | Buffer.from("ord"), 191 | 1, 192 | 1, 193 | Buffer.from("application/json"), 194 | opcodes.OP_0, 195 | Buffer.from(data), 196 | opcodes.OP_ENDIF 197 | ]; 198 | 199 | let { p2tr, redeem } = taproot_address_from_asm(script.compile(ins_script), keypair, network) 200 | return { p2tr, redeem } 201 | } 202 | 203 | 204 | ``` 205 | - **BRC20 Switch Deploy/Mint/Transfer Function** 206 | 207 | ```typescript 208 | 209 | /** 210 | * The opcode of brc20 211 | * 212 | * @param {string} op - The command type, like deploy, mint, transfer 213 | * @param {string} tick - The name of brc20 token 214 | * @param {string} amt - The amount of brc20 215 | * @param {string} lim - The limit of brc20, only useful in deploy 216 | * @returns {string} - return the opcode of brc20 command in string format 217 | */ 218 | export function brc20_op(op: string, tick: string, amt: string, lim: string) { 219 | switch (op) { 220 | case "deploy": 221 | return `{"p":"brc-20","op":"mint","tick":"${tick}","max":"${amt}","lim":"${lim}"}` 222 | case "mint": 223 | return `{"p":"brc-20","op":"mint","tick":"${tick}","amt":"${amt}"}` 224 | case "transfer": 225 | return `{"p":"brc-20","op":"transfer","tick":"${tick}","amt":"${amt}"}` 226 | } 227 | } 228 | 229 | 230 | ``` 231 | 232 | ## Contact Info 233 | I've shared some sections of the code, but not the entire codebase due to an NDA and security considerations. If you require technical support or have development inquiries, please feel free to reach out to me. 234 | 235 | - Telegram: https://t.me/inscNix/ -------------------------------------------------------------------------------- /Ordinal/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leionion/Fractal-bitcoin-development-guide/8f082652837b92b5e699e93e320ee637ff82efeb/Ordinal/README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Fractal Bitcoin Development Guide 2 | 3 | This guide serves as a comprehensive guide to the Fractal Bitcoin network. 4 | This includes the implementation of features such as the CAT20 token protocol, sCrypt smart contract development via OP_CAT, and exploration of the Ordinal, BRC-20, and Rune protocols. 5 | 6 | 7 | I am a blockchain developer with four years of experience, primarily working within the Bitcoin and Solana ecosystems. This guide is a work in progress and may encounter unexpected challenges. Therefore, users are advised to critically evaluate and reference this material. Updates will be provided as new announcements and technologies emerge within the Fractal Bitcoin ecosystem. 8 | 9 | ### 1. CAT20 Protocol Implementation 10 | 11 | - **[How to Mint CAT20 Token Based on CAT Protocol of Fractal Mainnet](./CAT20/CAT20_Token_Mint_Guide.md)** 12 | - **[Ultimate Guide on Using the CAT CLI Command](./CAT20/CAT_CLI_Guide.md)** 13 | - **[OP_CAT opcode guide for CAT20 token standard of CAT protocol](./CAT20/OP_CAT.md)** 14 | ### 2. Ordinal Protocol Implementation 15 | 16 | The Ordinal protocol is activated at block 21000. 17 | - **[BRC-20 Token Protocol Implementation](./Ordinal/BRC20-Token-Management.md)** 18 | - **[Ordinal NFT Protocol Implementation]()** 19 | 20 | ### 3. Rune Protocol Implementation 21 | 22 | The Rune protocol is set to be activated at block 84000. 23 | 24 | - **[Rune Token Protocol Implementation]()** 25 | 26 | ### 4. sCrypt Smart Contract Development Based on OP_CAT 27 | 28 | Coming Soon... 29 | 30 | Should you encounter any issues while utilizing this guide, feel free to reach out to me on Telegram. Additionally, if you have new ideas or wish to develop new products on the Fractal network, I am open to collaboration and brainstorming solutions to enhance our development processes. 31 | 32 | ### Contact Information: 33 | - **Telegram**: [inscNix](https://t.me/inscNix/) 34 | -------------------------------------------------------------------------------- /Rune/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leionion/Fractal-bitcoin-development-guide/8f082652837b92b5e699e93e320ee637ff82efeb/Rune/README.md -------------------------------------------------------------------------------- /sCrypt/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leionion/Fractal-bitcoin-development-guide/8f082652837b92b5e699e93e320ee637ff82efeb/sCrypt/README.md --------------------------------------------------------------------------------