LogoLogo
Go to Website
  • Getting Started
  • OP_WALLET
  • tBTC and OP_20 Faucet
  • $MOTO Token
  • Deploying a Token
  • OP_SCAN
  • Motoswap
    • OP_20 Swap
    • Creating, Adding, and Removing LP
    • NativeSwap
  • Creating a Native LP
  • Motoswap Staking
  • Motochef
    • MOTO Staking
    • BTC Staking
  • Official Links
    • OP_NET Website
  • OP_NET X
  • OP_NET Discord
  • OP_NET Developer Documentation
  • Motoswap
  • MotoChef
  • Motoswap X
  • OP_SCAN Explorer
Powered by GitBook
On this page
  • Prerequisites
  • Downloading the template to edit the contract
  • Editing the parameters and building the contract
  • Install Dependencies and Build
  • Minting tokens

Deploying a Token

Previous$MOTO TokenNextOP_SCAN

Last updated 1 month ago

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 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:

  1. 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
  1. 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
  1. 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'
  1. 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 the OP_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.

Have node.js installed ()

Have npm (Node package manager) installed ()

Have OP_Wallet installed ()

https://nodejs.org/en/download
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
https://chromewebstore.google.com/detail/opwallet/pmbjpcmaaladnfpacpmhmnfmpklgbdjb
GitHub - btc-vision/OP_20: OP_20 example tokenGitHub
Logo