Update docs/liquid/liquid-part2.md
This commit is contained in:
parent
ee472d0977
commit
dec7462a8a
@ -32,75 +32,9 @@ This shows us the total amount of L-BTC in circulation, additionally we can see
|
||||
|
||||
### Issuing our own Asset
|
||||
|
||||
Issuing assets is pretty straight forward, it can be roughly broken down into 3 main steps[^3]:
|
||||
|
||||
1. Generate a Legacy Address[^4] and PUBKEY for that address
|
||||
2. Generate a Contract Hash using that PUBKEY
|
||||
3. Issue the Asset
|
||||
|
||||
* STEP 1: Let's generate our legacy address and set the output to a variable and get its public key
|
||||
|
||||
Issuing assets is pretty straight forward
|
||||
```
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getnewaddress "" legacy)
|
||||
lq1qq03fq9jz20qnfqw4utjhdh3feasg3rtzf7l2qd9snrkctjm8g4ey4wvu225kq79wqclq9qg7ak8ycnhuekwuw9r38t94qr60a
|
||||
$ export NEWADD='lq1qq03fq9j....'
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getaddressinfo $NEWADD | jq '.pubkey'
|
||||
02fc3b404d9785d2dc26ea1867e25cf047702e45d29559a4657fafe8c0dd53877e
|
||||
```
|
||||
|
||||
* STEP 2: In order to generate the contract hash, it requires a few steps - so I've simplified it by making a bash script. Copy this into a file named `gen_asset_contract.sh` and mark as executable
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
shopt -s expand_aliases
|
||||
|
||||
### FILENAME: gen_asset_contract.sh
|
||||
### USAGE: ./gen_asset_contract.sh PUBKEY
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Missing PUBKEY: Usage ./gen_asset_contract.sh PUBKEY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###EDIT THESE VALUES###
|
||||
DOMAIN="coins.b0xxy.net"
|
||||
PUBKEY=$1
|
||||
NAME="StackerNewsDemo-1"
|
||||
PRECISION=8
|
||||
TICKER="SND-1"
|
||||
### END EDITING HERE ###
|
||||
|
||||
CONTRACT='{"entity":{"domain":"'$DOMAIN'"},"issuer_pubkey":"'$PUBKEY'","name":"'$NAME'","precision":'$PRECISION',"ticker":"'$TICKER'","version":'0'}'
|
||||
|
||||
CONTRACT_HASH=$(python3 -c 'import json,sys; sys.stdout.write(json.dumps(json.loads(sys.argv[1]), sort_keys=True, separators=(",",":")))' "$CONTRACT" | sha256sum | head -c64 | fold -w2 | tac | tr -d "\\n")
|
||||
|
||||
echo CONTRACT=$CONTRACT
|
||||
echo CONTRACT_HASH=$CONTRACT_HASH
|
||||
```
|
||||
|
||||
* Now we can use the script we saved before to generate the contract:
|
||||
|
||||
```
|
||||
$ ./gen_asset_contract.sh 02fc3b404d9785d2dc26ea1867e25cf047702e45d29559a4657fafe8c0dd53877e
|
||||
|
||||
CONTRACT={"entity":{"domain":"coins.b0xxy.net"},"issuer_pubkey":"02fc3b404d9785d2dc26ea1867e25cf047702e45d29559a4657fafe8c0dd53877e","name":"StackerNewsDemo-1","precision":8,"ticker":"SND-1","version":0}
|
||||
CONTRACT_HASH=a742ef224aedad0b26902822abd05f163ab965a1f5195d06ca8429b6d2a9ffdc
|
||||
```
|
||||
|
||||
* Finally export those variables via bash to use later:
|
||||
|
||||
```
|
||||
export CONTRACT='{"entity":{"domain":"coins.b0xxy.net"},"issuer_pubkey":"02fc3b404d9785d2dc26ea1867e25cf047702e45d29559a4657fafe8c0dd53877e","name":"StackerNewsDemo-1","precision":8,"ticker":"SND-1","version":0}'
|
||||
|
||||
export CONTRACT_HASH=a742ef224aedad0b26902822abd05f163ab965a1f5195d06ca8429b6d2a9ffdc
|
||||
```
|
||||
|
||||
* STEP 3: Now Issuing our own asset is straight-forward, as its a single line command in the client. Let's issue 10 new tokens and set the supply to be fixed (no re-issuance)
|
||||
|
||||
```
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS issueasset 10 0 true $CONTRACT_HASH
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS issueasset 10 0 true
|
||||
|
||||
{
|
||||
"txid": "8a12dd64c43de200cc7addb6c59f67bdbc6481ef1cc8b24253c7c1daba3c4e06",
|
||||
@ -126,7 +60,6 @@ $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER
|
||||

|
||||
|
||||
* So publicly we know the following about our new asset:
|
||||
- We can see our CONTRACT_HASH has been saved
|
||||
- It cannot be re-issued (fixed supply token)
|
||||
- It has only been issued once
|
||||
- However both the *issued amount and the circulating supply* has been hidden from us.
|
||||
@ -139,22 +72,7 @@ It is possible to 'unblind' this information to clients, but that would involve
|
||||
|
||||
* Let's create another address[^5] and another asset and this time choose a different option (specifically, lets create this asset unblinded):
|
||||
|
||||
```
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getnewaddress "" legacy
|
||||
lq1qqfgyq8zfyrsr296tqj7y23f9y4rz2q63hmhdf2mffwvg5yk9jxl8f0q4r7m0szy9m0wwe8224d856sas6enx6dp4w8ar7j06e
|
||||
|
||||
$ export NEWADD='lq1qqfgy...'
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getaddressinfo $NEWADD | jq '.pubkey'
|
||||
02ada219afbd424afca568e01370161d68ab3aa0697cd759a6105c23b81d20b397
|
||||
|
||||
$ ./gen_asset_contract.sh 02ada219afbd424afca568e01370161d68ab3aa0697cd759a6105c23b81d20b397
|
||||
CONTRACT={"entity":{"domain":"coins.b0xxy.net"},"issuer_pubkey":"02ada219afbd424afca568e01370161d68ab3aa0697cd759a6105c23b81d20b397","name":"StackerNewsDemo-1","precision":8,"ticker":"SND-1","version":0}
|
||||
CONTRACT_HASH=2b14c6c7ff4009ce6cf4dfa59099fdda4f27459d153b45fe91790e9d1bca42a0
|
||||
|
||||
$ export CONTRACT='{"entity":{"domain":"coins.b0xxy.net"},"issuer_pubkey":"02ada219afbd424afca568e01370161d68ab3aa0697cd759a6105c23b81d20b397","name":"StackerNewsDemo-1","precision":8,"ticker":"SND-1","version":0}'
|
||||
$ export CONTRACT_HASH=2b14c6c7ff4009ce6cf4dfa59099fdda4f27459d153b45fe91790e9d1bca42a0
|
||||
|
||||
$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS issueasset 10 0 false $CONTRACT_HASH
|
||||
`$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS issueasset 10 0 false`
|
||||
|
||||
{
|
||||
"txid": "225f3ed16457467673fd64f3577031b91be370615b3feba53e1cc0b256768944",
|
||||
@ -163,7 +81,6 @@ $ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER
|
||||
"asset": "41c19a473c71298a28342ccbf6fcbd3042cae8607b3b79d336b4c02e89ba2c66",
|
||||
"token": "10178003de4d2141fc318e3a61a7c8e1d43d3842a87fb8fb18fc1c1b09d081cb"
|
||||
}
|
||||
```
|
||||
|
||||
...and checking again what [the Liquid network knows about it](https://blockstream.info/liquid/asset/41c19a473c71298a28342ccbf6fcbd3042cae8607b3b79d336b4c02e89ba2c66)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user