# 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.

{% embed url="<https://github.com/btc-vision/OP_20>" %}

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

<figure><img src="/files/Tx710JqxJq9SvttNiIxA" alt="" width="563"><figcaption></figcaption></figure>

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.

<figure><img src="/files/T5ggd8R6M5f7XkkM6wRx" alt=""><figcaption></figcaption></figure>

### **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
```

2. **`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
```

3. **`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'
```

4. **`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.

<figure><img src="/files/aMZ2X7xpdqEps0nnkXz3" alt="" width="267"><figcaption></figcaption></figure>

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

<figure><img src="/files/lkR3kaQlnQZSocnHz5ET" alt="" width="563"><figcaption></figcaption></figure>

* Send your transaction to deploy the token contract.

### Minting tokens

After the deployment is completed, it should be visitble in your imported tokens list.&#x20;

To mint tokens, select the token, and click the Mint button.

<figure><img src="/files/Cqf5L2YyQ45UQYp9Ups5" alt="" width="260"><figcaption></figcaption></figure>

Then select the amount of tokens you wish to mint.

<figure><img src="/files/EpKTGYIOIxo9w2MCZezG" alt="" width="264"><figcaption></figcaption></figure>

Click Next, and then sign the transaction.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://opnet-testnet.gitbook.io/start/deploying-a-token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
