Deploying a Token
Last updated
Last updated
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.
Have an IDE such as VS Code, (you can use textedit or notepad but an IDE is recommended)
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.
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
.
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.
name
:
The name
is a string representing the full name of your token.
This will be displayed in wallets and exchanges.
symbol
:
The symbol
is a short string representing the ticker symbol of your token.
Similar to how "BTC" represents Bitcoin.
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:
Modify the values as needed for your token.
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:
After building, a build
folder will be created in the root of the OP_20
folder. Look for [nameoftoken].wasm
for the compiled 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.
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.
Have node.js installed ()
Have npm (Node package manager) installed ()
Have OP_Wallet installed ()