Deploy a Token

A BHRC20 token contract keeps track of fungible tokens: any token is exactly equal to any other token; no tokens have special rights or behavior associated with them. This makes BHRC20 tokens useful for things like a medium of exchange currency, voting rights, staking, and more. As we know, both OpenZeppelin and ConsenSys maintain the standard library of BHRC contract classes. Simply put, BHRC20 is nothing more than a class with methods and members that run the logic of what we usually call cryptocurrency. However, it has a broader meaning because it also has applications in other use cases. Let's move on to learning how to create and deploy an BHRC20 token with the OpenZepplin library. Pre-requisites

  • Install Metamask

  • Configure Bahamut Mainnet on Metamask

  • Get mainnet token

Compile and Deploy BHRC20 Token. Open Remix IDE then create a new Token.sol contract and copy the below contract code to Token.sol.

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/BHRC20/BHRC20.sol";

contract BHRC20Token is ERC20 {

constructor(uint256 totalSupply) ERC20("DemoToken", "DET") {

// create totalSupply of tokens for the deployer

_mint(msg.sender, totalSupply);

}

}

Compile the contract

  • Switch to the compile page

  • Select proper compiler

  • Select BHRC20Token(Token.sol) contract

  • And then click Compile Token.sol

Deploy the contract

  • Click the button to switch to deploy button

  • Select Injected Provider-MetaMask

  • Select BHRC20Token-Token.sol

  • Fill in many tokens you want to mint and click Deploy button

Click Confirm button to sign and broadcast the transaction to chain.

Add custom token to MetaMask

  1. Copy the deployed contract address

  2. Click Import Tokens

  3. Paste the contract address to the Token contract address

  4. And the Token symbol and Token decimal will auto tilled by MetaMask

  5. Finally, Click the Add custom token

  6. Click the Import tokens button

When you reopen the MetaMask next time, you will see the token and amount.

Last updated