4. Pay transaction fees in the newly issued asset

We will now spend the new asset whilst paying transaction fees directly in this new asset.

Let’s send the asset we created to a new address (GENERATED_ADDRESS_3)

.\elements-cli getnewaddress

In the following commands, replace GENERATED_ADDRESS_3 and ASSET, submit the transactions and create a new block as shown below:

.\elements-cli -named sendtoaddress address=<GENERATED_ADDRESS_3> amount=100.0 assetlabel=<ASSET> subtractfeefromamount=true

Take note of the transaction ID (txid), which is the string that the interface will show you when you run the sendtoaddress command (if it’s executed correctly). This txid will also be used later for another test in the next section (Replace By Fee).

You can also transfer signetcoin while paying fees in the newly issued asset. To do so, use signetcoin as the assetlabel, set subtractfeefromamount=false and then add fee_asset_label=<ASSET> with the label or asset id of the newly issued asset. For example:

.\elements-cli -named sendtoaddress address=<ANY ADDRESS> amount=1 assetlabel=signetcoin subtractfeefromamount=false fee_asset_label=<ANY ASSET IN YOUR WALLET>

Then, create a block:

.\elements-cli generatetoaddress 1 <GENERATED_ADDRESS>

Since we set “subtractfeefromamount=true” the payment used the new asset that is transferred with the payment to also pay for transaction fees

.\elements-cli getreceivedbyaddress <GENERATED_ADDRESS_3>

If you sent 100 tokens in the Asset you issued to GENERATED_ADDRESS_3, given the fee paid subtracted from the amount, you will see an amount transferred of about 99.99999864.

We have now demonstrated how the node handles payments using two different assets, signetcoin and a new asset you issued, as transaction fees.

Let’s move forward with something even more interesting!

Last updated