How To Mint A Token on the SafeCoin Network

 

These instructions will help you to set up a token on the SafeCoin Network. If you already have the SafeCoin Client running, you will need to create two new wallet.json files, “Token-Wallet” and “Mint-Authority”.

 

Part 1 – VPS Set Up & Log In

*For At-Home Set Up, skip to Part 2.

Ubuntu 20.04 is recommended.

 

 

Choose your VPS provider. Once you have your VPS installed, we will now SSH in and begin to build.

Download Putty (or any other SSH program) to log into your VPS.

 

 

 

CLICK HERE TO DOWNLOAD THE LATEST PUTTY VERSION.

 

 

 

Once we have Putty downloaded, open the program. You will see a screen like this:

 

 

 

 

 

Copy the IP Address of your VPS, and Paste into “Host Name (or IP address), then click Open. This will open a Terminal connected to your VPS. You may get a security alert due to this being the first time logging into your newly created VPS.

 

 

Once connected, use the log in credentials from your VPS provider.

 

Username – root

Password – xxxxxxxxxxxx

 

 

 

Part 2 – VPS Configuration

 

Next we will create a new user with the following command, replacing <username> with a username of your choice:

adduser <username>

You will be prompted for a password. Enter and confirm using a new password (different to your root password) and store it in a safe place. You will also see prompts for user information, but this can be left blank. Once the user has been created, we will add them to the sudo group so they can perform commands as root. Replace <username> with your chosen username.

usermod -aG sudo <username>

Now, while still as root, we will update the system from the Ubuntu package repository:

apt update

 

apt upgrade

 

 

Part 3 – Dependencies and SafeCoin Files

 

Open Putty again, and SSH into the VPS. This time log in with your username and password you created in Part 2.

 

Download all dependencies and programs we will need.

curl https://sh.rustup.rs -sSf | sh
*When prompted with “Proceed with Installation”, Type 1 then Enter.

 

source $HOME/.cargo/env
rustup component add rustfmt
rustup update
sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang make git
*If prompted with “Do you want to continue?”, type Y and hit Enter.

 

 

We are now ready to start building the SafeCoin Program.

 

First, lets download the necessary files from the SafeCoin GitHub.

git clone https://github.com/Fair-Exchange/Safecoin.git

 

Next, lets move into the SAFE directory.

cd Safecoin

 

Now in SAFE, lets compile the SafeCoin Program. This may take 5-45 mins, depending on your machine.

cargo build --release

 

Once finished, lets download a few more files.

./fetch-perf-libs.sh

 

Now let’s back out of the SAFE directory.

cd

 

 

Part 4 – Wallet Files and Seed Backup

 

Now we will build our ledger.

mkdir ledger

 

In the next few steps, we will be creating our wallet address. Open a text file (or somewhere to save seed words).

~/Safecoin/target/release/safecoin-keygen new --word-count 24 -o ledger/token-wallet.json
*Enter a BIP39 Passphrase if you want. If not, hit enter to bypass.

Save your PubKey and your 24 Seed Words for your token-wallet.

~/Safecoin/target/release/safecoin-keygen new --word-count 24 -o ledger/mint-authority.json
*Enter a BIP39 Passphrase if you want. If not, hit enter to bypass.

 

Save your PubKey and your 24 Seed Words for your mint-authority.

 

 

 

Next, we will set the configuration for the SafeCoin Program.

~/Safecoin/target/release/safecoin config set --keypair ~/ledger/token-wallet.json

 

You should see this confirmation returned after setting the configuration.

 

 

 

Now it is time to add SAFE to your Token Wallet with the funding to create a token. Let’s create a SafeCoin address from our already created wallets.

~/Safecoin/target/release/safecoin address

Copy the SafeCoin address, and send 1 SAFE to it. The transaction should confirm in a few seconds.

 

 

Use this command to check the SafeCoin balance on your Token Wallet.

~/Safecoin/target/release/safecoin balance

 

 

 

Part 5 – Building the SafeCoin Program Library

 

Make sure you are in your Home directory, and git clone the SafeCoin Program Library.

git clone https://github.com/Fair-Exchange/safecoin-program-library.git

  Next, lets move into the SafeCoin-Program-Library directory.

cd safecoin-program-library

  Now in Safecoin-Program-Library, lets compile the Token Program. This may take 5-10 mins, depending on your machine.

cargo build --release

Once built, you can see all available commands available.

 

Part 6 – Building a Token

 

~/safecoin-program-library/target/release/safe-token create-token --fee-payer ~/ledger/token-wallet.json --mint-authority ~/ledger/mint-authority.json
If successful, it will return your Token Address and a Signature.

 

 

 

Now lets create a Token Account where we will hold the minted tokens.

~/safecoin-program-library/target/release/safe-token create-account --fee-payer ~/ledger/token-wallet.json <TOKEN ADDRESS> --owner ~/ledger/token-wallet.json
If successful, it will return your created Token Account and a Signature.

 

 

Time to mint some Tokens!

~/safecoin-program-library/target/release/safe-token mint <TOKEN ADDRESS> <AMOUNT TO MINT> <ACCOUNT ADDRESS> --fee-payer ~/ledger/token-wallet.json --mint-authority ~/ledger/mint-authority.json

If successful, it will return Amount Minted, Token Address, Recipient Address, and a Signature.