Coder Social home page Coder Social logo

cashninjas / ninjas.cash Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 5.0 36.53 MB

Cash-Ninjas web3 frontend and minting website.

Home Page: https://ninjas.cash

HTML 32.44% CSS 47.68% JavaScript 19.88%
bitcoin-cash bitcoincash cashtokens smart-contracts

ninjas.cash's Introduction

Cash-Ninjas Minting Frontend

Repo for the Cash-Ninjas website - including wallet connect and minting logic.

Overview

The logic for the minting page can be found in js/mint.js with configuration in js/mintingParams.js.

The CashScript artifact of the minting smart contract is provided in js/mint.json.

The minting app relies on walletconnect/sign-client, walletconnect/modal, libauth, cashscript and electrum-cash libraries.

Vite is used as bundler for the code, the public folder that goes with it is used to avoid jQuery bundling issues and have a consistent image path on production deploys. Vite is configured to allow top-level-await for libauth-v2, specific Vite configuration can be found in vite.config.js. Top-level-await support of by the user's browser is necessary to use the minting page.

To implement the wallet connect functionality the following guide was used: 'Docs: Dapp Usage'.

The Wallet Connect V2 standard for BCH is supported by Cashonize, the Zapit wallet and the Paytaca wallet is at the time of writing.

Installation

git clone https://github.com/cashninjas/ninjas.cash

npm install

Usage

You need to make an account at cloud.walletconnect.com to get a WalletConnect projectId. To simplify implementation you can turn off the Verify API in the project's settings.

Update js/mintingParams.js with your specific configuration.

Then startup the web server!

npm run dev

Profit!

ninjas.cash's People

Contributors

mr-zwets avatar zquestz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ninjas.cash's Issues

Allow multiple user-inputs in minting transaction

The cashscript code for the minting smart contract allows for the user to add multiple inputs.

  // Get userInput for mint
  const userAddress = await getUserAddress();
  const userUtxos = await electrumServer.getUtxos(userAddress);
  const networkFeeMint = 520;
  const filteredUserUtxos = userUtxos.filter(
    val => !val.token && val.satoshis >= mintPriceSats + networkFeeMint,
  );
  const bchBalanceUser = userUtxos.reduce((total, utxo) => utxo.token ? total : total + utxo.satoshis, 0n);
  const userInput = filteredUserUtxos[0];

this code could just as well select an array of userInputs to get to the required minting amount.

Next the fromP2PKH(userInput, userSig) in the transaction construction should be using this array of userInputs and then set the all signatures to be empty before adding each input to the listSourceOutputs .

Cannot visit mint website

After clicking to go to the mint from the main ninjas.cash website, I end up with a blank page and the following in my console output:

assets/mint-2346be2c.js:20 Uncaught SyntaxError: Unexpected reserved word

I am using the Falkon browser, which is based on QtWebEngine.

The page opens fine in Firefox.

Insufficient funds, take 2

After previous failure to mint due to unsuccessful funds, I sent another โ‚ฌ0.02 and tried again.

The result remained the same, so I assume the coin selection wants to take all the coins from a single address, but the wallet receive screen has no way to send to that specific address.

I am using the Zapit! wallet for this attempt in minting.

No error on insufficient funds

I tried to mint a ninja and it just said building transaction 1/1.

When I looked into the console it says:

Error: Insufficient funds: available (110002000) < needed (110002511).

Given that the cost to mint is supposed to be 0.05 BCH, I don't intuitively understand what these numbers correspond to, but there should be a user-interface error shown that helps the user resolve the situation.

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.