Skip to content

Instantly share code, notes, and snippets.

@sproxet
Created July 5, 2021 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sproxet/a39e152fdbc4e7d552d09bdbba881ad5 to your computer and use it in GitHub Desktop.
Save sproxet/a39e152fdbc4e7d552d09bdbba881ad5 to your computer and use it in GitHub Desktop.
Managed Token Elysium Lelantus Example
#!/bin/bash
set -o xtrace
set -e
shopt -s expand_aliases
network="$(ps auxw | grep firod | grep -o -e -testnet -e -regtest | cat)"
alias firo-cli="$HOME/Code/firo/src/firo-cli $network"
if [[ "$passphrase" != "" ]]; then
firo-cli walletpassphrase $passphrase 99999
fi
# There must be confirmed PUBLIC Firo in an address before we can mint funds from it.
ownerAddress=$(firo-cli getnewaddress)
firo-cli sendtoaddress $ownerAddress 5
# Now we must create the issuance transaction.
ecosystem=1 # 1 = regular, 2 = test (this is independent of being on reg/testnet)
divisible=2 # 1 = indivisible token, 2 = divisible token
predecessorTokenId=0 # this is the predecessor token id; you usually want to specify 0 for none.
category="Test Tokens"
subcategory="Lelantus Test Tokens"
name="Our Lelantus Test Token"
url="http://ourlelantustesttoken.example/"
description="This is a cool Lelantus test token."
supply=99999 # this is the amount of token to mint; with elysium_sendissuancefixed,
# it constitutes the whole supply
useLelantus=3 # 0 = disabled (mutable), 1 = enabled (mutable),
# 2 = disabled (immutable), 3 = enabled (immutable)
issuanceTxId=$(firo-cli elysium_sendissuancemanaged $ownerAddress $ecosystem $divisible $predecessorTokenId \
"$category" "$subcategory" "$name" "$url" "$description" \
$useLelantus)
# Before taking the propertyid, you must wait for the issuance transaction to be mined.
firo-cli generate 1
# Now you may take the propertyid of the token; it will be what you must use for all subsequent interactions.
propertyId=$(firo-cli elysium_gettransaction $issuanceTxId | sed -Ene 's/^ "propertyid": ([0-9]+),$/\1/p')
if [[ "x$propertyId" == "x" ]]; then
echo "test failed" >&2
exit 1;
fi
firo-cli elysium_sendgrant $ownerAddress $ownerAddress $propertyId $supply
firo-cli generate 1
# Now we have to mint our tokens.
amountToMint=1000
# The "elysium_send" here just signifies that an Elysium transaction is being sent on the network;
# the coins are just being minted, not actually sent anywhere.
firo-cli elysium_sendlelantusmint $ownerAddress $propertyId $(( $amountToMint / 2 ))
# In order to spend tokens, there must be at least two mints existing in the pool for that property.
firo-cli elysium_sendlelantusmint $ownerAddress $propertyId $(( $amountToMint / 2 ))
firo-cli elysium_listpendinglelantusmints
firo-cli elysium_listpendingtransactions
# We must have confirmed PRIVATE Firo available (anywhere in our wallet) for the transaction fee before
# we can send.
firo-cli mintlelantus 10
firo-cli generate 2
receiveAddress=$(firo-cli getnewaddress)
amountToSend=10
firo-cli elysium_sendlelantusspend $receiveAddress $propertyId $amountToSend
firo-cli generate 1
firo-cli elysium_getbalance $receiveAddress $propertyId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment