Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute NFT tokens #2

Closed
wants to merge 3 commits into from
Closed

Distribute NFT tokens #2

wants to merge 3 commits into from

Conversation

zh
Copy link
Contributor

@zh zh commented Dec 20, 2020

Allow the faucet to distribute NFT tokens too. See README file for more details about this kind of setup - .env settings etc.

@jcramer
Copy link
Contributor

jcramer commented Dec 21, 2020

I tested this code and ran into some issues.

Seems like NFT=no functions fine, but NFT=yes keeps having problems with failing transactions due to an error BCH amount too low. I wasn't able to get past the distribution phase for the NFT Group.

@zh
Copy link
Contributor Author

zh commented Dec 22, 2020

Think I found the problem - simpleTokenSend(), when sending burning-ready utxos was returning the remaining BCH to the main address '/0, so all subaddresses was left without any BCH. Moved NFT distribution before BCH one to prevent this.

Also addressed 502 error message problem by reducing number of call to the BCHD node - finding UTXO for burning executed one call per address, resulting in 19 calls. Reduced to 1 call getting all UTXOs for all addresses.

@jcramer
Copy link
Contributor

jcramer commented Dec 22, 2020

Ok, it looks like that worked.

For some reason when I try to include a documentHash for the NFT I get Error: documentHash must be either 0 or 32 hex bytes

slpfaucet.ts Show resolved Hide resolved
@zh zh requested a review from jcramer December 22, 2020 13:57
try {
await slpFaucet.evenlyDistributeTokens(process.env.TOKENID!);
if (process.env.NFT === 'yes') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep this part of the server logic the same as master. Token type logic should be handled in slpfaucet.ts.

Copy link
Contributor

@jcramer jcramer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this new feature currently is setup to operate will require the admin to run the distribute function every 18 NFTs generated. The NFT faucet can be done in a way where this burden to a token operator can be eliminated.

IMO we should distribute the Group tokens in a way just like the Token Type 1 tokens are distributed. Then when user submits their address for an NFT you can do a Group NFT send to isolate qty 1 for burning, then send that qty 1 in a NFT GENESIS for burning. The GENESIS NFT should output to the user's address.

@@ -68,15 +78,28 @@ app.post("/", async (req, res) => {
let sendTxId: string;
try {
let inputs: slpjs.SlpAddressUtxoResult[] = [];
inputs = inputs.concat(changeAddr.balance.slpTokenUtxos[process.env.TOKENID!]).concat(changeAddr.balance.nonSlpUtxos);
if (process.env.NFT === 'yes') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, handle nft logic in slpfaucet. Create a new method in slpfaucet to pick which send method to call. This will keep the server.ts as clean as possible.

@@ -4,8 +4,8 @@ import { GrpcClient } from "grpc-bchrpc-node";
import * as slpjs from "slpjs";
import { BchdNetwork, BchdValidator, Utils } from "slpjs";

const bitbox = new BITBOX();
const client = new GrpcClient({url: "bchd.ny1.simpleledger.io" });
const bitbox = new BITBOX({restURL: 'https://bchd.fountainhead.cash'});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't using any of the network methods in BITBOX sdk, so we don't meed to use restURL parameter.

const bitbox = new BITBOX();
const client = new GrpcClient({url: "bchd.ny1.simpleledger.io" });
const bitbox = new BITBOX({restURL: 'https://bchd.fountainhead.cash'});
const client = new GrpcClient({url: 'bchd.fountainhead.cash' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specific to NFTs, but lets go ahead use a new environment variable BCHD_HOST here.

@zh
Copy link
Contributor Author

zh commented Dec 26, 2020

This code require too many changes to the original code. Closed in favours of PR#3 code.

@zh zh closed this Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants