Update docs/liquid/liquid-part2.md
This commit is contained in:
parent
60f2fb0bbf
commit
7c4f567a5c
@ -27,8 +27,92 @@ Looking up this value on [https://blockstream.info/liquid/assets](https://blocks
|
|||||||
|
|
||||||
### Issuing our own Asset
|
### Issuing our own Asset
|
||||||
|
|
||||||
* 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)
|
Issuing assets is pretty straight forward, it can be roughly broken down into 3 main steps[^3]:
|
||||||
- `$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS issueasset 10 0 true`
|
|
||||||
|
1. Generate a Legacy Address[^4] and PUBKEY for that address
|
||||||
|
2. Generate a Contract Hash
|
||||||
|
3. Issue the Asset
|
||||||
|
|
||||||
|
* STEP 1a: Let's generate our legacy address and set the output to a variable
|
||||||
|
`$ LEG_ADDRESS=$(sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getnewaddress "" legacy`)
|
||||||
|
|
||||||
|
lq1qq2s92z0uq78kd4gfepua6qvfwx40g4lqqer9e3tzrr0j04ugyzsed39mnh9wvuhw0hmaqy5mxs9egqrr7j3rx8j2sdyun9m90
|
||||||
|
|
||||||
|
* STEP 1b: Set this address to a variable for use later and generate the public key.
|
||||||
|
- `$ export LEG_ADDRESS="lq1qq2s92....."`
|
||||||
|
- `$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getaddressinfo $LEG_ADDRESS | jq '.pubkey'`
|
||||||
|
|
||||||
|
025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780
|
||||||
|
|
||||||
|
- `$ export PUBKEY="025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780"`
|
||||||
|
|
||||||
|
* 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 "Please supply PUBKEY before running"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PUBKEY=$1
|
||||||
|
|
||||||
|
###EDIT THESE VALUES###
|
||||||
|
|
||||||
|
DOMAIN="nulldata.org"
|
||||||
|
NAME="StackerNews-Demo1"
|
||||||
|
PRECISION=8
|
||||||
|
TICKER="SND-1"
|
||||||
|
CONTRACT='{"entity":{"domain":"'$DOMAIN'"},"issuer_pubkey":"'$PUBKEY'","name":"'$NAME'","precision":'$PRECISION',"ticker":"'$TICKER'","version":'0'}'
|
||||||
|
CONTRACT_HASH=$(echo -n "${CONTRACT}" | sha256sum | sha256sum | sed 's/ .*//g')
|
||||||
|
|
||||||
|
#Generate a byte-aligned reveresed CONTRACT_HASH for use in asset Creation
|
||||||
|
TEMP=$CONTRACT_HASH
|
||||||
|
LEN=${#TEMP}
|
||||||
|
until [ $LEN -eq "0" ]; do
|
||||||
|
END=${TEMP:(-2)}
|
||||||
|
CONTRACT_HASH_REV="$CONTRACT_HASH_REV$END"
|
||||||
|
TEMP=${TEMP::$((${#TEMP} - 2))}
|
||||||
|
LEN=$((LEN-2))
|
||||||
|
done
|
||||||
|
|
||||||
|
### END EDITING HERE ###
|
||||||
|
echo CONTRACT=$CONTRACT
|
||||||
|
echo CONTRACT_HASH=$CONTRACT_HASH
|
||||||
|
echo CONTRACT_HASH_REV=$CONTRACT_HASH_REVT_HASH_REV=$CONTRACT_HASH_REV
|
||||||
|
```
|
||||||
|
|
||||||
|
* STEP 2: Now we can use the script we saved before to generate the contract:
|
||||||
|
|
||||||
|
- `$ ./gen_asset_contract.sh $PUBKEY`
|
||||||
|
|
||||||
|
CONTRACT={"entity":{"domain":"nulldata.org"},"issuer_pubkey":"025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780","name":"StackerNews-Demo1","precision":8,"ticker":"SND-1","version":0}
|
||||||
|
|
||||||
|
CONTRACT_HASH=df4bd5aec71f808f78b752cbaac783019fa20268265f66baa406e4202b77e4a1
|
||||||
|
|
||||||
|
CONTRACT_HASH_REV=a1e4772b20e406a4ba665f266802a29f0183c7aacb52b7788f801fc7aed54bdf
|
||||||
|
|
||||||
|
|
||||||
|
* STEP 2: Finally export those variables via bash to use later:
|
||||||
|
|
||||||
|
```
|
||||||
|
export CONTRACT={"entity":{"domain":"nulldata.org"},"issuer_pubkey":"025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780","name":"StackerNews-Demo1","precision":8,"ticker":"SND-1","version":1}
|
||||||
|
|
||||||
|
export CONTRACT_HASH=7d6bf3e3228fd00e9591c4c6bd1163d088a387e95d29fdfcf2e4e5035a137a94
|
||||||
|
|
||||||
|
export CONTRACT_HASH_REV=947a135a03e5e4f2fcfd295de987a388d06311bdc6c491950ed08f22e3f36b7d
|
||||||
|
```
|
||||||
|
|
||||||
|
* 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_REV`
|
||||||
|
|
||||||
{
|
{
|
||||||
"txid": dd3983619f67e7a743ccfd32e48bbdb591c1d44b86a71d442be95a2453c0479a,
|
"txid": dd3983619f67e7a743ccfd32e48bbdb591c1d44b86a71d442be95a2453c0479a,
|
||||||
@ -97,12 +181,28 @@ We can see that we've received 100,000,000 'sats' of our custom asset. However,
|
|||||||
The publication of asset metadata info on Liquid works on a `.well-known` system where specific files are published on a webserver that you control. There are a few different steps to accomplish this, so lets begin
|
The publication of asset metadata info on Liquid works on a `.well-known` system where specific files are published on a webserver that you control. There are a few different steps to accomplish this, so lets begin
|
||||||
|
|
||||||
* The first step is we need to generate a `legacy` address in case we ever want to delete the asset from the registry later[^3]
|
* The first step is we need to generate a `legacy` address in case we ever want to delete the asset from the registry later[^3]
|
||||||
- `sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getnewaddress "" legacy`
|
- `$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getnewaddress "" legacy`
|
||||||
|
|
||||||
lq1qq2s92z0uq78kd4gfepua6qvfwx40g4lqqer9e3tzrr0j04ugyzsed39mnh9wvuhw0hmaqy5mxs9egqrr7j3rx8j2sdyun9m90
|
lq1qq2s92.....
|
||||||
|
|
||||||
|
* Set this address to a variable for use later and generate the public key.
|
||||||
|
- `$ export DELETE_ADDRESS="lq1qq2s92....."`
|
||||||
|
- `$ sudo ./scripts/app compose elements exec node elements-cli -rpcuser=$E_RPCUSER -rpcpassword=$E_RPCPASS getaddressinfo $DELETE_ADDRESS | jq '.pubkey'`
|
||||||
|
|
||||||
|
025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780
|
||||||
|
|
||||||
|
- `$ export PUBKEY="025aa49d444a150c99c904c8e779e5317aff4aee15ee9171f450e14af9dd8b8780"`
|
||||||
|
|
||||||
|
* We need to set some variable and then generate a json 'contract' file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[^1]: The values E_RPCUSER and E_RPCPASS, where environmental variables we set in Part I
|
[^1]: The values E_RPCUSER and E_RPCPASS, where environmental variables we set in Part I
|
||||||
[^2]: Like in bitcoin, 1 integer unit is 100,000,000 base units (not sats, but equivalent concept)
|
[^2]: Like in bitcoin, 1 integer unit is 100,000,000 base units (not sats, but equivalent concept)
|
||||||
[^3]: Using a legacy address for this task imposes no real implications to your security since its only used to remove assets from the registry. Its possible to do this with a non-legacy address, but more steps are involved and we will need to use other tools rather than what's already built-in to Elements node, so we will just use a legacy address for this.
|
[^3]: Technically just running `elements-cli issueasset 10 0` is enough to issue an asset, however there will be limitations later on when trying to register the asset, burn, remove, etc.
|
||||||
|
[^4]: Using a legacy address for this task imposes no real implications to your security since its only used to remove assets from the registry. Its possible to do this with a non-legacy address, but more steps are involved and we will need to use other tools rather than what's already built-in to Elements node, so we will just use a legacy address for this.
|
||||||
Loading…
x
Reference in New Issue
Block a user