Deploying a Token
To deploy a token, you can visit the link below to view an overview of what to do, or view the guide below the link.
Prerequisites
Have node.js installed (https://nodejs.org/en/download)
Have npm (Node package manager) installed (https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
Have OP_Wallet installed (https://chromewebstore.google.com/detail/opwallet/pmbjpcmaaladnfpacpmhmnfmpklgbdjb)
Have an IDE such as VS Code, (you can use textedit or notepad but an IDE is recommended)
Downloading the template to edit the contract
Head to the github link at the top of the page, and either clone the github repo in your selected directory:
git clone https://github.com/btc-vision/OP_20.git
or download directly by clicking the green "code" button and downloading as ZIP:

If you're using an IDE, open the OP20 folder and navigate to src/contracts/MyToken.ts. If you're going to use a text editor, find the MyToken.ts file and open it in a text editor.

Editing the parameters and building the contract
This step is crucial for customizing your OP_20 token. You will need to adjust several key properties such as maxSupply
, decimals
, name
, and symbol
.
Here’s what each property means and how you can customize it:
maxSupply
:
This defines the total supply of your token.
It’s a
u256
value representing the maximum number of tokens that will ever exist.The number should include the full number of decimals.
Example: If you want a total supply of 1,000,000 tokens with 18 decimals, the value should be
1000000000000000000000000
.
const maxSupply: u256 = u128.fromString('1000000000000000000000000').toU256(); // 1,000,000 tokens with 18 decimals
decimals
:
This property defines how divisible your token is.
A value of
18
means the token can be divided down to 18 decimal places, similar to how Ethereum handles its tokens.
const decimals: u8 = 18; // Your decimals
name
:
The
name
is a string representing the full name of your token.This will be displayed in wallets and exchanges.
const name: string = 'YourTokenName'; // e.g., 'My Custom Token'
symbol
:
The
symbol
is a short string representing the ticker symbol of your token.Similar to how "BTC" represents Bitcoin.
const symbol: string = 'SYM'; // e.g., 'MYT'
Modifying the Contract Code
Open the OP_20
template repository in your IDE or text editor and navigate to src/contracts/MyToken.ts
. Look for the following section in the onInstantiated
method:
const maxSupply: u256 = u128.fromString('1000000000000000000000000').toU256(); // Your max supply
const decimals: u8 = 18; // Your decimals
const name: string = 'YourTokenName'; // Your token name
const symbol: string = 'SYM'; // Your token symbol
Modify the values as needed for your token.
Install Dependencies and Build
After customizing your token's properties, build the contract:
Open your terminal and navigate to the location of the downloaded
OP_20
template folder.Run the following commands:
npm install npm run build
After building, a
build
folder will be created in the root of theOP_20
folder. Look for[nameoftoken].wasm
for the compiled contract.
Deploy the Token Contract
Open the OP_WALLET extension and select the "deploy" option.

Drag your
.wasm
file or click to choose and upload it.

Send your transaction to deploy the token contract.
Minting tokens
After the deployment is completed, it should be visitble in your imported tokens list.
To mint tokens, select the token, and click the Mint button.

Then select the amount of tokens you wish to mint.

Click Next, and then sign the transaction.
Last updated