July 1, 2023

WhiteBIT Network guides. Create your own token. Token's smartcontract verification

Introduction

The WB Network Testnet was launched in March 2023, and since then the WhiteBIT crypto exchange has been actively preparing for the mainnet release. It seems that this important event for Ukrainian cryptans is just around the corner: the company has announced the terms of the retrodrop!

WhiteBIT Network is a L1 blockchain developed by the WhiteBIT centralized exchange. This network runs on the Proof-of-Autority (PoA) consensus algorithm, is compatible with the Ethereum virtual machine (EVM). The exchange has its own WhiteBIT Token (WBT), which will be the gas token of the network.

More details can be found at White Paper

To participate you need:

Creating a token in WhiteBIT Network

  1. Go to site, press "Create new file" and create a file IWRC20.sol

2. In the IWRC20.sol file, insert the code:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IWRC20 {
 function name() external view returns(string memory);
 function symbol() external view returns(string memory);
 function decimals() external pure returns(uint);
 function totalSupply() external view returns(uint);
 function balanceOf(address account) external view returns(uint);
 function transfer(address to, uint amount) external;
 function allowance(address _owner, address spender) external view returns(uint);
 function approve(address spender, uint amount) external;
 function transferFrom(address sender, address recipient, uint amount) external;
 event Transfer(address indexed from, address indexed to, uint amount);
 event Approve(address indexed owner, address indexed to, uint amount);
}
This is how it should turn out

3. Create another new file and name it TestToken.sol (or "YournameToken".sol) and paste the code below into it

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IWRC20.sol";
contract WRC20 is IWRC20 {
uint totalTokens;
address owner;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowances;
string _name;
string _symbol;
function name() external view returns(string memory) {
return _name;
}
function symbol() external view returns(string memory) {
return _symbol;
}
function decimals() external pure returns(uint) {
return 18;
}
function totalSupply() external view returns(uint) {
return totalTokens;
}
modifier enoughTokens(address _from, uint _amount) {
require(balanceOf(_from) >= _amount, "not enough tokens!");
_;
}
modifier onlyOwner() {
require(msg.sender == owner, "not an owner!");
_;
}
constructor(string memory name_, string memory symbol_, uint initialSupply) {
_name = name_;
_symbol = symbol_;
owner = msg.sender;
mint(initialSupply, msg.sender);
}
function balanceOf(address account) public view returns(uint) {
return balances[account];
}
function transfer(address to, uint amount) external enoughTokens(msg.sender, amount) {
_beforeTokenTransfer(msg.sender, to, amount);
balances[msg.sender] -= amount;
balances[to] += amount;
emit Transfer(msg.sender, to, amount);
}
function mint(uint amount, address mint_to) public onlyOwner {
_beforeTokenTransfer(address(0), mint_to, amount);
balances[mint_to] += amount;
totalTokens += amount;
emit Transfer(address(0), mint_to, amount);
}
function burn(address _from, uint amount) public onlyOwner {
_beforeTokenTransfer(_from, address(0), amount);
balances[_from] -= amount;
totalTokens -= amount;
}
function allowance(address _owner, address spender) public view returns(uint) {
return allowances[_owner][spender];
}
function approve(address spender, uint amount) public {
_approve(msg.sender, spender, amount);
}
function _approve(address sender, address spender, uint amount) internal virtual {
allowances[sender][spender] = amount;
emit Approve(sender, spender, amount);
}
function transferFrom(address sender, address recipient, uint amount) public enoughTokens(sender, amount) {
_beforeTokenTransfer(sender, recipient, amount);
require(allowances[sender][msg.sender] >= amount, "check allowance!");
allowances[sender][msg.sender] -= amount;
balances[sender] -= amount;
balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint amount
) internal virtual {}
}
contract TestToken is WRC20 {
constructor(address owner) WRC20("YOUR NAME", "YOUR TICKER", YOUR-TOTAL-SUPPLY*10**18) {}
}
In the penultimate line of the code, enter the desired name of the token ("YOUR NAME"), its ticker ("YOUR TICKER") and the maximum number ("YOUR-TOTAL-SUPPLY")
This is how it should turn out

4. Next, select "Injected Provider Metamask" and connect to the site on the WB Network (it is important !)

This is how it should turn out
If everything is done correctly, your wallet address should appear in the "Account" field

5. Go here and compile the TestToken.sol file.

Importantly! To compile this file, it must be selected in the files tab
This is how it should turn out

If everything was successful, you will see it below:

Successful compilation

Now it's time to deploy the smartcontract

  1. Select our file;
  2. Insert the address of our Metamask wallet;
  3. Press "Deploy" and confirm the transaction in Metamask.

If our contract is successfully deployed, the following will be displayed:

Successful deployment of a smartcontract

Copy the contract address of our token (using the button indicated above in the screenshot) and add it to the Metamask:

Tab "Tokens" → Below we are looking for "Import tokens" → After entering the address of the contract, the "Token symbol" and "Token deciaml" fields will be filled in automatically → Press "Add custom token"

And now the token you created is displayed in your wallet

Token's contract verification

Now we need to verify the token's smartcontract in the WB Explorer, so that anyone who wants to can look at the program code of the contract and make sure that it does not implement anything fraudulent and works correctly.

  1. Go to the site in the "Verify contract" section;
  2. In the "Contract adress" field, insert the address of the smartcontract of the previously created token;
  3. Set the rest of the parameters as in the screenshot and press "Continue":

4. Now we need to upload the two files we created in the remix there. For this we need to download them. Right-click and select "Download". We do the same with the second file.

5. Downloaded files are uploaded to the site (you can simply drag and drop) and press "Verify and publish"

After passing the captcha, you will see the following:

Congratulations! You have successfully created your own token and verified its contract!