> For the complete documentation index, see [llms.txt](https://docs.planq.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.planq.network/for-dapp-developers/planq-smart-contract/contract-deployment.md).

# Contract Deployment

## Truffle: Deploy ERC20 Contract

### Step 1. Enter `smart-contract-example/truffle` folder

```bash
$ cd planq-smart-contract-example/truffle
```

### Step 2. Run `npm install` inside the folder

```bash
$ npm install
```

### Step 3. Make a copy of `.env.example` to `.env`

```bash
$ cp .env.example .env
```

### Step 4. Modify `.env` and fill *ONE* of the field

```bash
MNEMONIC=goose easy ivory ...
PRIVATE_KEY=XXXXXXX
```

### Step 5. Review Migration Script at `migrations/2_deploy_planq_token.js`

```javascript
  const PlanqToken = artifacts.require("PlanqToken");
  
  module.exports = function (deployer) {
      deployer.deploy(PlanqToken, "Planq Token", "PLQ", "1000000000000000000000000");
  };
```

### Step 6. Endpoints setting

By default, the script will be using your local host `"127.0.0.1"` - If you are not running a localhost, you may leverage the public endpoint `https://evm-rpc.planq.network/` by making changes to `networks` in `truffle-config.js`, for example:

```json
  networks: {
    development: {
      provider: new HDWalletProvider(getHDWallet(), "http://127.0.0.1:8545"), // TODO
      network_id: "*",       // Any network (default: none)
    },
    testnet: {
      provider: new HDWalletProvider(getHDWallet(), "https://evm-rpc.planq.network/"), // TODO
      network_id: "*",
      skipDryRun: true
    },
  },
```

### Step 7. Deploy Contract

```bash
npm run deploy-contract-planq
```

### Step 8. Obtain Contract address from console and input to Metamask

Correct balance will be shown on Metamask page

![](/files/6JZgrEv9Q7MfKgK9reOI)

![](/files/f9RkOJph7HchRwTpWAab) ![](/files/nswaNTGBYKh4ovcb29bZ)

## Hardhat: Deploy ERC20 Contract

### Step 1. Enter `smart-contract-example/hardhat` folder

```bash
$ cd smart-contract-example/hardhat
```

### Step 2. Run `npm install` inside the folder

```bash
$ npm install
```

### Step 3. Make a copy of `.env.example` to `.env`

```bash
$ cp .env.example .env
```

### Step 4. Modify `.env` and fill *ONE* of the field

```bash
MNEMONIC=goose easy ivory ...
PRIVATE_KEY=XXXXXXX
```

### Step 5. Review Migration Script at `scripts/deploy-planq-token.js`

```javascript
  async function main() {
      const PlanqToken = await hre.ethers.getContractFactory("PlanqToken");
      const planqToken = await PlanqToken.deploy("Planq Token", "PLQ", "1000000000000000000000000");
  
      await planqToken.deployed();
  
      console.log("PlanqToken deployed to:", planqToken.address);
  }
```

### Step 6. Endpoints setting

By default, the script will be using your local host `"127.0.0.1"` - If you are not running a localhost, you may leverage the public endpoint `https://evm-rpc.planq.network/` by making changes to `networks` in `hardhat.config.js`, for example:

```json
  networks: {
    development: {
      url: "http://localhost:8545",
      accounts: getHDWallet(),
     },
    testnet: {
      url: "https://evm-rpc.planq.network/",
      accounts: getHDWallet(),
    },
  },
```

### Step 7. Deploy Contract

```bash
npm run deploy-contract-planq
```

### Step 8. Obtain Contract address from the console and input to Metamask

the Correct balance will be shown on Metamask page

```bash
PlanqToken deployed to: 0x5F803c894a0A16B46fe5982fB5D89eb334eAF68
```

![](/files/f9RkOJph7HchRwTpWAab) ![](/files/nswaNTGBYKh4ovcb29bZ)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.planq.network/for-dapp-developers/planq-smart-contract/contract-deployment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
