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

SLP templates using libauth #68

Closed
mainnet-pat opened this issue Dec 25, 2020 · 3 comments
Closed

SLP templates using libauth #68

mainnet-pat opened this issue Dec 25, 2020 · 3 comments

Comments

@mainnet-pat
Copy link
Contributor

Hi, @bitauth, thank you for your nice library.

I am trying to generate the SLP's OP_RETURN scripts using the libauth and would like to ask you for your feedback.
I've taken the USDT example from the SLP spec and was successful to reproduce the Genesis transaction.
The resulting script look's like this and its bytecode generation like this

Am i doing it the right way?
I am not really satisfied that I need to use the vm evaluations like $(<0x01 decimals>) and manually fiddle with endianness and the need to introduce the new bigIntToBinUint64BE method.

Thanks for your feedback in advance,
pat.

@mainnet-pat
Copy link
Contributor Author

An update to our release candidate libauth template

https://github.com/mainnet-cash/mainnet-js/blob/e1b7f355240d840a498f95dabcad1b4790576c67/src/slp/SlpLibAuth.ts#L433

Thanks in advance

@bitjson
Copy link
Member

bitjson commented Jan 17, 2021

Hey @mainnet-pat, thanks for opening an issue, and sorry to keep you waiting.

That usage looks great, and I'm impressed you made it so far with just the tsdocs! These are all very new ideas and APIs (feedback appreciated!) so there's not really a "right way" to do anything yet (I regularly discover new tricks myself). I'll try to offer some tips though:

  1. I think the effect of bigIntToBinUint64BE can be achieved with $(<your_number> <8> OP_NUM2BIN OP_REVERSEBYTES), though there's nothing wrong with your current solution (manipulating data before passing it to the compiler).
  2. For e.g. $(<0x01 g_decimals>), can you replace with just 0x01 g_decimals? Evaluations are useful for manipulating data using opcodes, but in this case, if I understand correctly(?), you just want to output 0x01 followed by the g_decimals value, no push-wrapping or modification. (I made a note here that this might be a good target for the IDE to auto-fix. Thanks!)

@mainnet-pat
Copy link
Contributor Author

Thanks a lot Jason.
Omitting $(<>) made the scripts look nice and sleek.
I stayed with data preparation outside of libauth template, since I am doing this anyway for other thins apart from big integers.

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

2 participants