{"id":22021030,"url":"https://github.com/muffin819/cat20-mint-scrypt","last_synced_at":"2025-03-23T10:18:04.498Z","repository":{"id":264616388,"uuid":"893860554","full_name":"muffin819/cat20-mint-Scrypt","owner":"muffin819","description":"Fractal cat20 Mint smart contract using Scrypt","archived":false,"fork":false,"pushed_at":"2024-11-25T11:02:56.000Z","size":496,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T16:44:32.645Z","etag":null,"topics":["cat20","fractalbitcoin","scrypt","smartcontract"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muffin819.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T10:39:34.000Z","updated_at":"2025-01-14T18:03:24.000Z","dependencies_parsed_at":"2024-11-25T11:34:29.147Z","dependency_job_id":"f17bf491-a8fd-4cc4-bbfc-ad068ab98eb9","html_url":"https://github.com/muffin819/cat20-mint-Scrypt","commit_stats":null,"previous_names":["muffin819/cat20-mint-scrypt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffin819%2Fcat20-mint-Scrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffin819%2Fcat20-mint-Scrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffin819%2Fcat20-mint-Scrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffin819%2Fcat20-mint-Scrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muffin819","download_url":"https://codeload.github.com/muffin819/cat20-mint-Scrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084608,"owners_count":20558251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cat20","fractalbitcoin","scrypt","smartcontract"],"created_at":"2024-11-30T06:09:09.897Z","updated_at":"2025-03-23T10:18:04.470Z","avatar_url":"https://github.com/muffin819.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Fractal-Cat20-sCrypt-smart-contract\nThe smart contract for the Cat Protocol utilizes sCrypt to implement cat20 minting service on the Fractal Bitcoin network. It is basic of a launchpad for the Fractal CAT20 token, allowing users to mint CAT20 tokens.\n \n## Overview\nThe Fractal-Cat20-sCrypt-smart-contract project leverages the Fractal Bitcoin network's capabilities to implement a smart contract for the Cat Protocol using sCrypt. This project enables users to mint CAT20 tokens. The implementation takes advantage of the OP_CAT opcode to enhance Bitcoin's functionality, providing features akin to those seen in smart contracts on other blockchain platforms.\n\n## Features\nMinting of CAT20 Tokens: Utilize the sCrypt-based smart contract to mint new CAT20 tokens on the Fractal Bitcoin network.\nIntegration of OP_CAT: The smart contract makes use of the OP_CAT opcode to improve contract programmability and execution.\n\n## Contract Structure\n### Mint Function: Implements the logic to mint new CAT20 tokens by verifying appropriate proofs and executing the creation script.\n### Transfer Function: Handles the transfer of existing tokens between users, ensuring compliance with the protocol's specified rules.\nBelow is a simplified version of the sCrypt contract code structure:\n\npublic mint(\n        //\n        curTxoStateHashes: TxoStateHashes,\n        // contract logic args\n        tokenMint: CAT20State,\n        nextMinterAmounts: FixedArray\u003cint32, typeof MAX_NEXT_MINTERS\u003e,\n\n        // premine related args\n        preminerPubKeyPrefix: ByteString,\n        preminerPubKey: PubKey,\n        preminerSig: Sig,\n\n        // satoshis locked in minter utxo\n        minterSatoshis: ByteString,\n        // satoshis locked in token utxo\n        tokenSatoshis: ByteString,\n        // unlock utxo state info\n        preState: OpenMinterState,\n        preTxStatesInfo: PreTxStatesInfo,\n        // backtrace info, use b2g\n        backtraceInfo: BacktraceInfo,\n        // common args\n        // current tx info\n        shPreimage: SHPreimage,\n        prevoutsCtx: PrevoutsCtx,\n        spentScriptsCtx: SpentScriptsCtx,\n        // change output info\n        changeInfo: ChangeInfo\n    ) {\n        // check preimage\n        assert(\n            this.checkSig(\n                SigHashUtils.checkSHPreimage(shPreimage),\n                SigHashUtils.Gx\n            ),\n            'preimage check error'\n        )\n        // check ctx\n        SigHashUtils.checkPrevoutsCtx(\n            prevoutsCtx,\n            shPreimage.hashPrevouts,\n            shPreimage.inputIndex\n        )\n        SigHashUtils.checkSpentScriptsCtx(\n            spentScriptsCtx,\n            shPreimage.hashSpentScripts\n        )\n        // verify state\n        StateUtils.verifyPreStateHash(\n            preTxStatesInfo,\n            OpenMinterProto.stateHash(preState),\n            backtraceInfo.preTx.outputScriptList[STATE_OUTPUT_INDEX],\n            prevoutsCtx.outputIndexVal\n        )\n        // check preTx script eq this locking script\n        const preScript = spentScriptsCtx[Number(prevoutsCtx.inputIndexVal)]\n        // back to genesis\n        Backtrace.verifyUnique(\n            prevoutsCtx.spentTxhash,\n            backtraceInfo,\n            this.genesisOutpoint,\n            preScript\n        )\n\n        // split to multiple minters\n        let openMinterOutputs = toByteString('')\n        let curStateHashes = toByteString('')\n        let curStateCnt = 0n\n        let totalAmount = 0n\n        for (let i = 0; i \u003c MAX_NEXT_MINTERS; i++) {\n            const amount = nextMinterAmounts[i]\n            if (amount \u003e 0n) {\n                totalAmount += amount\n                curStateCnt += 1n\n                openMinterOutputs += TxUtil.buildOutput(\n                    preScript,\n                    minterSatoshis\n                )\n                curStateHashes += hash160(\n                    OpenMinterProto.stateHash({\n                        tokenScript: preState.tokenScript,\n                        isPremined: true,\n                        remainingSupply: amount,\n                    })\n                )\n            }\n        }\n        // mint token\n        let tokenOutput = toByteString('')\n        if (tokenMint.amount \u003e 0n) {\n            totalAmount += tokenMint.amount\n            curStateCnt += 1n\n            curStateHashes += hash160(\n                CAT20Proto.stateHash({\n                    amount: tokenMint.amount,\n                    ownerAddr: tokenMint.ownerAddr,\n                })\n            )\n            tokenOutput = TxUtil.buildOutput(\n                preState.tokenScript,\n                tokenSatoshis\n            )\n        }\n        if (!preState.isPremined \u0026\u0026 this.premine \u003e 0n) {\n            // premine need checksig\n            assert(\n                hash160(preminerPubKeyPrefix + preminerPubKey) ==\n                    this.premineAddr\n            )\n            assert(this.checkSig(preminerSig, preminerPubKey))\n            // first unlock mint\n            assert(totalAmount == preState.remainingSupply + this.premine)\n            assert(this.max == preState.remainingSupply + this.premine)\n            assert(tokenMint.amount == this.premine)\n        } else {\n            // not first unlock mint\n            assert(totalAmount == preState.remainingSupply)\n            assert(tokenMint.amount \u003c= this.limit)\n        }\n        const stateOutput = StateUtils.getCurrentStateOutput(\n            curStateHashes,\n            curStateCnt,\n            curTxoStateHashes\n        )\n        const changeOutput = TxUtil.getChangeOutput(changeInfo)\n        const hashOutputs = sha256(\n            stateOutput + openMinterOutputs + tokenOutput + changeOutput\n        )\n        assert(hashOutputs == shPreimage.hashOutputs, 'hashOutputs mismatch')\n    }\n\n## Developer Notes\nEnsure that you have the appropriate configuration for connecting to the Fractal Bitcoin network.\nReview the sCrypt smart contract thoroughly to understand its security assumptions and execution model.\n\n## Contact Info\n### Twitter: https://x.com/ProDogeLover/\n### Telegram: https://t.me/dogewhiz/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuffin819%2Fcat20-mint-scrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuffin819%2Fcat20-mint-scrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuffin819%2Fcat20-mint-scrypt/lists"}