Disclaimer. All information on this page is provided for informational purposes only. Buying, selling and exchanging cryptocurrencies are subject to economic risks and are not recommended within the scope of this article. The code is not intended for use in projects and is provided only to understand how tokens work.
Binance Smart Chain (BSC) is one of many gas-efficient platforms that are gaining in popularity as the number of crypto and blockchain projects grows.
BSC is a blockchain similar to Etherium, but also supports the EVM and any smart contracts running on Etherium.

At the beginning of 2022, the average number of transactions is 6 million per day, with a maximum of 16 million.
BEP-20 is a token standard that extends the capabilities of the ERC-20 and BEP-2 standards, and is now used in almost all DeFi projects. And it is with him that we will work within the framework of this article, creating a simple token and deploying it on the BSC test network using the Remix IDE and MetaMask.
Token and code:
- Name: TestBEP20Token
- Symbol: STST
- Volume: 1.000.000 STST
<pre class="wp-block-syntaxhighlighter-code alignwide">// SPDX-License-Identifier: UNLISCENSED
pragma solidity 0.8.4;
/*
@title TestBEP20Token
@dev Пример простого BEP-20 токена, в котором
все токены изначально назначены создателю.
Обратите внимание, что позже создатель может
распределять токены по своему усмотрению,
используя “transfer” и другие функции BEP-20
НЕОБХОДИМО МОДИФИЦИРОВАТЬ ПЕРЕД ВЫПУСКОМ.
ИСПОЛЬЗОВАТЬ ИСКЛЮЧИТЕЛЬНО В ОЗНАКОМИТЕЛЬНЫХ ЦЕЛЯХ.
*/
contract TestBEP20Token {
string public name = "TestBEP20Token";
string public symbol = "STST";
uint256 public totalSupply = 1000000000000000000000000;
// 1 million
uint8 public decimals = 18;
/*
@dev Emitted when `value` of tokens
are transferred from one account (`from`) to another (`to`).
The value of `value` can be zero.
*/
event Transfer(address indexed _from, address indexed _to, uint256 _value);
/*
@dev Generated when `spender` for `owner`
set by calling {approve}. `value` is a new reserve.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*
@dev Constructor giving msg.sender all existing tokens.
*/
constructor() {
balanceOf[msg.sender] = totalSupply;
}
/*
@dev Passes `amount` tokens
from calling account to `recipient`.
Returns a boolean value indicating the success of the transaction.
Raises the {Transfer} event.
*/
function transfer(address _to, uint256 _value)
public
returns (bool success)
{
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
/*
@dev Sets `amount` to be `spender`'s tolerance for the caller's tokens.
Returns a boolean value indicating the success of the transaction.
IMPORTANT: Be aware that changing the resolution
using this method carries the risk of
someone can use both old and new
resolution due to bad order of transactions.
One possible solution to mitigate this
race conditions - first reduce the spender's tolerance to 0,
and then set the desired value.
Raises the {Approval} event.
*/
function approve(address _spender, uint256 _value)
public
returns (bool success)
{
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/*
@dev Passes `amount` of tokens from `sender` to `recipient`
using the reserve mechanism. `amount` is subtracted from the caller's reserve.
Returns a boolean value indicating the success of the transaction.
Raises the {Transfer} event.
*/
function transferFrom(
address _from,
address _to,
uint256 _value
) public returns (bool success) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
}</pre>
To proceed further, you need a browser with MetaMask already added to it, which is connected to the BSC testnet.
You can install an extension for a browser that is convenient for you from the official MetaMask website, registration and creating a wallet are intuitive and have all the necessary instructions.
But to connect to the BSC test network, you need to find the drop-down menu with a list of networks at the top of the MetaMask window and select “Add network” / “Custom RPC” in it. Then fill in the fields with the following values and save the changes.
- Network Name: BSC Testnet
- New RPC URL: https://data-seed-prebsc-1-s1.binance.org:8545
- ChainID: 97
- Symbol: BNB
- Block Explorer URL: https://explorer.binance.org/smart-testnet
Приступим к созданию.
1. Open https://remix.ethereum.org in your browser.

2. Create a new file called “TestBEP20Token.sol” and copy the above code into it.
3. Code must be compiled before deployment. Click the second button from the top in the left pane or press Ctrl+S.
4. In the source code, we indicated the version of Solidity 0.8.4, in the compiler you need to select the same one.

5. After compilation, if successful, go to the deploy menu by clicking the third button on the Remix panel.развертывания, щелкнув третью кнопку на панели Ремикса.
6. Select “Injected Web3” in the “ENVIRONMENT” menu and your contract in “CONTRACT”.

7. You will need BNB to pay for gas, you can get it from the testnet faucet at https://testnet.binance.org/faucet-smart
8. Click the “Deploy” button and confirm the deployments in the MetaMask window that appears.
9. After that, the log and details of the contract will appear in the “Deployed Contracts” section.

10. Click on “TestBEP20Token” under contracts. Now you see all public methods and variables, you can start testing.
11. Try to check the balance of the owner of the contract, you should see a value equal to the entire volume of the token.
12. Try to transfer tokens to another wallet using the “transfer” method. Enter the recipient’s address and the number of tokens with an accuracy of 18 and click the “transfer” button. The MetaMask window will reappear asking you to confirm the transaction and displaying the amount to be sent.

13. A few minutes after confirmation, the transaction status will appear in the Remix IDE logs and in the BSCScan testnet browser. Checking the balance again, you will see that it is already less than a million, and the amount that you sent has already been credited to the recipient’s wallet.
Deploying tokens on the BSC mainnet is similar, but don’t forget that you’ll need BNB to pay for gas in order to do so.
Let’s add tokens to the wallet.
Now let’s move on to the wallet to which the tokens were sent. In the MetaMask window, click “Import Tokens” and enter the address of the deployed contract. The fields with name and symbol should be filled in automatically.
In the next step, you can already see the balance of the created tokens. Click “Add Tokens” to add them to this account.
Now you know how to create your token!