Giter Site home page Giter Site logo

frensnft's Introduction

BTC-FRENS-NFT

By sending BTC to the authority address, frens NFT would be minted to the account on the Stacks Blockchain. Powered by chainhooks.

How to use

Start a local Devnet with the command:

$ clarinet integrate

In another console, change the directory to ./serverless/. After running

$ yarn global add serverless    # Install serverless globally
$ yarn                          # Install dependencies

and making sure that the command serverless is available in your $PATH, the lambda functions can be started locally with the following command:

$ serverless offline --verbose --printOutput
  • deployments/btc-sendNFT.devnet-plan.yaml: a BTC transaction is being performed, using the following parameters:
        - btc-transfer:
            expected-sender: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d
            recipient: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC
            sats-amount: 100000000
            sats-per-byte: 10

A chainhook, present in chainhooks/wrap-btc.chainhook.yaml is observing BTC transfers being performed to the address mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC thanks to the following configuration:

networks:
  regtest:
    predicate:
      scope: outputs
      p2pkh:
        equals: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC

and then, a frens mint NFT transaction would be sent:

  const txOptions = {
    contractAddress: frensToken.contractAddress,
    contractName: frensToken.contractName,
    functionName: "mint",
    functionArgs: [standardPrincipalCVFromAddress(recipientAddress)],
    fee: 1000,
    nonce,
    network,
    anchorMode: AnchorMode.OnChainOnly,
    postConditionMode: PostConditionMode.Allow,
    senderKey: process.env.AUTHORITY_SECRET_KEY!,
  };
  const tx = await makeContractCall(txOptions);

In this protocol, this transaction assumes usage of p2pkh addresses, and sends the change back to the sender, using the same address.

$ clarinet deployment apply -p deployments/btc-sendNFT.devnet-plan.yaml

frensnft's People

Contributors

jnrlouis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.