Code Monkey home page Code Monkey logo

cashninjas-api-server's Introduction

CashNinjas API Server

Commands

Installation

npm install

Configure

Update config.js with your collection specific information.

Run Server

npm start

Setup Data Directory (Optional)

# Make git/docker ignored data directory.
mkdir data

# Copy BCMR file
cp <path-to-BCMR-file> data/bitcoin-cash-metadata-registry.json

# Copy collection images
cp <path-to-collection-images> data/images

# Copy collection icons
cp <path-to-collection-icons> data/icons

Endpoints

/ - Mint summary.

/mint - Minting UTXO data.

/icons/:id - Show icon for NFT.

/images/:id - Show image for NFT.

/nfts/:id - Show metadata for NFT.

/.well-known/bitcoin-cash-metadata-registry.json - BCMR registry.

Build Docker Image

docker build -t cashninja-server .

Run Docker Image

docker run -p 8777:3000 cashninja-server

Then visit http://127.0.0.1:8777.

Profit.

cashninjas-api-server's People

Contributors

mr-zwets avatar zquestz avatar

Stargazers

 avatar  avatar  avatar

cashninjas-api-server's Issues

Use Chaingraph for Subscriptions

Currently the server uses subscriptions to an electrum server, ideally this would use subscriptions to the chaingraph server so only one indexer is used to get the state of the blockchain.

// Listen for notifications and set up a subscription with callback function.
electrum.on('notification', () => updateMintingUtxos());
await electrum.subscribe('blockchain.address.subscribe', contractAddressMint);

Streaming subscriptions are only available using chaingraph with an updated Hasura dependency >v2.7.
This way updateMintingUtxos could be removed as we can only change the minting utxo which changed.

more info: https://hasura.io/docs/latest/subscriptions/postgres/index/

possible graphql subscription library to use: https://github.com/nearform/graphql-hooks

Invoking Payout triggers endless loops

The addition of a txidChanged check has not prevented infinite looping of updateMintingUtxos in practice.

 const noStateUpdate = nftsMinted == oldAmountMinted && !txidChanged;
    // If the Chaingraph instance has not seen the new tx, wait and re-fetch.
    if (noStateUpdate && nftsMinted != 0) {
      setTimeout(updateMintingUtxos, 500);
    }

The underlying issue is probably related to using two different indexers to get blockchain state (#1) as checking whether the txidChanged should be enough to prevent infinite looping of updateMintingUtxos , need to investigate the issue further.

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.