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

Ability to create SLP create token transactions w/ mint baton per SLP spec #228

Open
nickfujita opened this issue Jan 28, 2020 · 0 comments

Comments

@nickfujita
Copy link

What problem are you trying to solve?
The current implementation of sendTransaction on web4bch currently allows for the creation of new SLP tokens according to the SLP specifications, as long as there is no mint baton specified. If a mint baton is requested to be issued, it can only appear to be set on the change vout for the remaining BCH from the vin utxos. Since the OP_RETURN is being created before calling sendTransaction, the user can set the mint baton index to any number, but the transaction generated does not allow for multiple outputs, so the only option at the moment appears to be vout2 (the change address).

Describe the solution you'd like
In order to add flexibility beyond just creating SLP tokens, it may be an opportunity to enhance the sendTransaction method to allow the user to specify multiple outputs. As a general use case, it would allow users to send BCH to multiple addresses for varying amounts in the same transaction. But more specifically, it will enable the user to specify the appropriate number of utxo outputs to facilitate the creating of SLP tokens with a mint baton to a specific address, and also allow users to back any SLP tokens with any desired amount of BCH.

Here are a couple of examples of what the updated parameters object for sendTransaction could look like:

Send w/ multiple outpus

The following would result in a transaction with 3 utxo outputs.

  • vout0 = 12345
  • vout1 = 6789
  • vout2 = <remaining_bch_from_vin_utxos>
const txParams = {
  from: web4bch.bch.defaultAccount,
  outputs: [
    {
      address: <bch_address>,
      amount: '12345',
    },
    {
      address: <bch_address>,
      amount: '6789',
    }
  ]
};

SLP create token

The following would result in a transaction with 4 utxo outputs.

  • vout0 = 0 BCH, OP_RETURN
  • vout1 = 0.00000546 BCH, 10000000000 initial SLP tokens
  • vout2 = 0.00000546 BCH, mint baton
  • vout3 = <remaining_bch_from_vin_utxos>
const encodedData = slpjs.Slp.buildGenesisOpReturn({
  ticker: <ticker>,
  name: <name>,
  documentUri: <documentUri>,
  hash: <documentHash>,
  decimals: <decimals>,
  batonVout: 2,
  initialQuantity: 10000000000,
});

const txParams = {
  from: web4bch.bch.defaultAccount,
  outputs: [
    {
      address: <bch_address>,
      amount: '546',
    },
    {
      address: <bch_address>,
      amount: '546',
    }
  ],
  opReturn: {
    data: encodedData,
    isEncoded: true,
    position: '0',
  },
};

Additional context
SLP token genesis transaction spec

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

No branches or pull requests

1 participant