A Solidity BEP20 token contract for Binance Smart Chain with mintable, burnable, operable transfer, and token recovery extensions all compiled into a single deployable file.
| Feature | Description |
|---|---|
| BEP20 base | Standard transfer, approval, and allowance logic |
| Mintable | Owner-controlled token minting with a finish-minting lock |
| Burnable | Token holders can burn their own tokens or approved amounts |
| Operable | ERC-1363-style callbacks on transfer and approval to receiver/spender contracts |
| ERC165 | Interface detection to check compatibility at runtime |
| Token Recovery | Owner can recover any BEP20 tokens accidentally sent to the contract address |
contracts/
kshib.sol - fully flattened BEP20 token with all extensions
The flattened file contains these components in order:
| Component | Purpose |
|---|---|
Context |
Provides _msgSender() and _msgData() |
Ownable |
Single-owner access control |
IBEP20 |
Standard BEP20 interface |
BEP20 |
Core token implementation |
BEP20Mintable |
Adds mint and finishMinting with a canMint modifier |
BEP20Burnable |
Adds burn and burnFrom |
IERC165 |
Interface detection standard |
IBEP20Operable |
Interface for operatable transfer with callbacks |
IBEP20OperableReceiver |
Callback interface for transfer receivers |
IBEP20OperableSpender |
Callback interface for approval receivers |
Address |
Low-level call helpers |
ERC165Checker |
Utility to check interface support |
ERC165 |
Base ERC165 implementation |
BEP20Operable |
Adds transferAndCall and approveAndCall |
TokenRecover |
Allows owner to recover erroneously sent BEP20 tokens |
TheKing |
The main token contract combining all extensions |
- Solidity ^0.8.0
- A Solidity compiler (e.g., solc, Remix IDE, Brownie, or Hardhat)
For testnet or mainnet deployment you also need:
- A wallet private key for the deployer account
- A BSC RPC endpoint (public endpoints available for testnet and mainnet)
Clone the repository and open contracts/kshib.sol in your Solidity development environment.
git clone <repository-url>
cd bep20-token-kitNo package installation is required. The contract is fully self-contained.
Deploy TheKing with four constructor arguments:
| Parameter | Type | Description |
|---|---|---|
name_ |
string | Token full name |
symbol_ |
string | Token ticker symbol |
decimals_ |
uint8 | Decimal places (typically 18) |
initialBalance_ |
uint256 | Tokens minted to the deployer on construction |
Using Remix IDE:
- Open
contracts/kshib.solin Remix - Compile with Solidity 0.8.x
- Deploy
TheKingwith your chosen parameters
Using Brownie:
from brownie import TheKing, accounts
deployer = accounts.load('deployer')
token = TheKing.deploy(
"My Token",
"MTK",
18,
10_000_000_000 * 10**18,
{'from': deployer}
)To reuse this as a template:
- Change the token name, symbol, and initial supply in your deploy script (no source edits required)
- To rename the contract, replace
TheKingin thecontract TheKingdeclaration and the constructor - To add supply caps, add a
MAX_SUPPLYconstant and a require check in_mint
- Only the contract owner can mint new tokens
- Once
finishMinting()is called, minting is permanently disabled burnFromrequires the caller to have approval for the amount being burnedtransferAndCallandapproveAndCalltrigger callbacks on receiver/spender contracts if they implement the corresponding interfacesrecoverBEP20sends any accidentally deposited tokens back to the owner
MIT — see LICENSE.