Launch your own token

Learn how to launch your own token in 20 minutes!
This tutorial is based on the description provided by QuickNode. You can find the original tutorial here.

Set up MetaMask and get BTC on Botanix testnet

To get started, you will need the Metamask browser extension to create a BTC wallet and some test Bitcoin, which you can get by going to the Botanix faucet. You'll need to connect your Metamask wallet to the faucet and request some test BTC. More information can be found in the Botanix docs.

Implement contract

Head over to the Ethereum Remix IDE and make a new Solidity file, for example Botanix-token.sol . Paste the following code into your new Solidity script:
1
pragma solidity ^0.4.24;
2
3
//Safe Math Interface
4
5
contract SafeMath {
6
7
function safeAdd(uint a, uint b) public pure returns (uint c) {
8
c = a + b;
9
require(c >= a);
10
}
11
12
function safeSub(uint a, uint b) public pure returns (uint c) {
13
require(b <= a);
14
c = a - b;
15
}
16
17
function safeMul(uint a, uint b) public pure returns (uint c) {
18
c = a * b;
19
require(a == 0 || c / a == b);
20
}
21
22
function safeDiv(uint a, uint b) public pure returns (uint c) {
23
require(b > 0);
24
c = a / b;
25
}
26
}
27
28
29
//ERC Token Standard #20 Interface
30
31
contract ERC20Interface {
32
function totalSupply() public constant returns (uint);
33
function balanceOf(address tokenOwner) public constant returns (uint balance);
34
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
35
function transfer(address to, uint tokens) public returns (bool success);
36
function approve(address spender, uint tokens) public returns (bool success);
37
function transferFrom(address from, address to, uint tokens) public returns (bool success);
38
39
event Transfer(address indexed from, address indexed to, uint tokens);
40
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
41
}
42
43
44
//Contract function to receive approval and execute function in one call
45
46
contract ApproveAndCallFallBack {
47
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
48
}
49
50
//Actual token contract
51
52
contract QKCToken is ERC20Interface, SafeMath {
53
string public symbol;
54
string public name;
55
uint8 public decimals;
56
uint public _totalSupply;
57
58
mapping(address => uint) balances;
59
mapping(address => mapping(address => uint)) allowed;
60
61
constructor() public {
62
symbol = "QKC";
63
name = "QuikNode Coin";
64
decimals = 2;
65
_totalSupply = 100000;
66
balances[YOUR_METAMASK_WALLET_ADDRESS] = _totalSupply;
67
emit Transfer(address(0), YOUR_METAMASK_WALLET_ADDRESS, _totalSupply);
68
}
69
70
function totalSupply() public constant returns (uint) {
71
return _totalSupply - balances[address(0)];
72
}
73
74
function balanceOf(address tokenOwner) public constant returns (uint balance) {
75
return balances[tokenOwner];
76
}
77
78
function transfer(address to, uint tokens) public returns (bool success) {
79
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
80
balances[to] = safeAdd(balances[to], tokens);
81
emit Transfer(msg.sender, to, tokens);
82
return true;
83
}
84
85
function approve(address spender, uint tokens) public returns (bool success) {
86
allowed[msg.sender][spender] = tokens;
87
emit Approval(msg.sender, spender, tokens);
88
return true;
89
}
90
91
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
92
balances[from] = safeSub(balances[from], tokens);
93
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
94
balances[to] = safeAdd(balances[to], tokens);
95
emit Transfer(from, to, tokens);
96
return true;
97
}
98
99
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
100
return allowed[tokenOwner][spender];
101
}
102
103
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
104
allowed[msg.sender][spender] = tokens;
105
emit Approval(msg.sender, spender, tokens);
106
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
107
return true;
108
}
109
110
function () public payable {
111
revert();
112
}
113
}
Replace the following values:
  • Line 62: symbol = "QKC"; Choose your own symbol
  • Line 63: name = "QuikNode Coin"; Choose your own name
  • Line 64: decimals = 2; set the decimal (value in which tokens can be divided, 0 to 8 decimal units can be used) and establish a total supply value as you wish
  • Line 65 _totalSupply = 100000; Choose a total supply
  • Line 66: balances[YOUR_METAMASK_WALLET_ADDRESS] = _totalSupply; Please change YOUR_METAMASK_WALLET_ADDRESS to your own wallet address (This one can be found in your MetaMask interface)
  • Line 67: emit Transfer(address(0), YOUR_METAMASK_WALLET_ADDRESS, _totalSupply);
Note: The total supply value must have additional trailing zeros as specified by the decimals field. For example, the decimals value in this contract is 2 and we need a total supply of 1000 tokens, so we’ll have to set the total supply variable to 100000 (simply because it won’t allow a decimal point).
Compile the smart contract. Make sure you select the right compiler based on the chosen Solidity version.
Deploy it using injected Web3 (make sure to select Botanix testnet on MetaMask before compiling the contract) and select the right contract to be deployed. Approve the transaction from MetaMask.
Note: We need to deploy the main token contract, select the name of the contract appropriately under the contracts section before deploying the contract (BotanixTestToken here).
If you receive an error message before deployment “This contract may be abstract”, make sure to select the appropriate contract under the Contract tab. Confirm the transaction in Metamask.
That’s it! your token contract is now deployed on Bitcoin’s Botanix testnet!

Get token in MetaMask

To get the token in Metamask, go to the “Deployed Contracts” section in Remix and copy the deployed contract’s address using the copy button near the contract’s name.
Open Metamask, go to the Token tab and click on the Import Tokens button. Paste the contract’s address in the first field. Metamask will fetch the Token Symbol and decimals automatically.

Add your token to AvocadoSwap

Go back to https://avocadoswap.io/ and navigate to Liquidity. Click on Add Liquidity. Next, click on Select Currency and paste the copied contract’s address in the search bar. AvocadoSwap will find your token that you just deployed. Simply click on "Add".
Now, go back to the Liquidity page and click again on Select Currency. This time, you will find your token in the list. You can now choose how much BTC you want to provide for an amount of your chosen token. Here you can see an example.
First, approve the token and follow the instructions on MetaMask. Next, click Supply and Confirm the creation of the pool.
In case the gas fee is too high, you can try to change it in MetaMask, your transaction should still go through.
Congratulations, you have now provided liquidity for your own created token! Other people can now start to trade your personalized token!
You can find the confirmation of the transaction in your MetaMask
Last modified 1mo ago