Instant Mint

Lets mint!

Here is a straightforward example that illustrates how you can mint your very first token. To begin, you will need to add your private key to the testUtility.js file. To obtain a new random private key simply run this command in the terminal while in the /tests directory

node getPrivateKey.js

The corresponding address will appear in the terminal console.

Address to send funds to:  "some address "
Funding Private Key: "some private key"

In order to utilize this address for minting purposes, you will need to first send funds to it. Please note that a minimum of 5000 satoshis will be required in order to run the test, although only a fraction of this amount will actually be used in the mint example. Please be sure to keep a copy of this private key if you still have funds that you would like to recover in the future. At any time you would like to withdraw the funds from the test address please refer to the /tests/getFundsFromAddress.js file and follow the instructions.

To proceed, take the private key string and replace the two values in the testUtility.js file. In this example, you can use the same private key for both variables on lines 11 and 16

this.privateKey = bsv.PrivateKey.fromString('Enter Funding Private Key Here');
this.issuerPrivateKey = bsv.PrivateKey.fromString('Enter Funding Private Key Here');

Make sure to retain a copy of this private key if you have any remaining funds that you may wish to retrieve later. If you want to withdraw the funds from the test address at any point in time, consult the /tests/getFundsFromAddress.js file and adhere to the guidelines provided.

We're now set to conduct the test! Just go to the /test directory and execute this command in the terminal.

node instantMint.js

The process will start and the token will be minted onchain with all Txids provided.

Starting Instant Mint Example...
Fetching UTXO from the blockchain...
Building transactions...
Prepare Utxos Txid:  31fa389bec5677c048e6a5539467dda02da576427f8bbccb22fcb2250cd601ec
Contract Txid:  81bbdce661ea6b0133e8073a48b8334658bf6151d08cb8061d4a106175a095fb
Issue Txid:  7b678504f67fc87e93ddd6816800d73915cd43a09ad2a53d177cc539b3f8c233
Redeem Txid:  c7951ceb0bb8fd712e2e993a022d7d37c23a65a779477e5e80694640e6d9cb45
Instant Mint Example Completed

As this is for testing purposes, we will also redeem the token back to native satoshis as part of this test.

Last updated