-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
I tested this code and ran into some issues. Seems like |
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. |
Ok, it looks like that worked. For some reason when I try to include a documentHash for the NFT I get |
try { | ||
await slpFaucet.evenlyDistributeTokens(process.env.TOKENID!); | ||
if (process.env.NFT === 'yes') { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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') { |
There was a problem hiding this comment.
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'}); |
There was a problem hiding this comment.
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' }); |
There was a problem hiding this comment.
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.
This code require too many changes to the original code. Closed in favours of PR#3 code. |
Allow the faucet to distribute NFT tokens too. See README file for more details about this kind of setup -
.env
settings etc.