> For the complete documentation index, see [llms.txt](https://docs.polysmartchain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.polysmartchain.com/zhong-wen-jian-ti/kai-fa-zhe/fa-bu-prc20-token.md).

# 发布 PRC-20 Token

在开始之前，您将需要准备以下内容：

1. Matemask钱包
2. 拥有至少1个PSC

### 开始使用Remix <a href="#getting-started-with-remix" id="getting-started-with-remix"></a>

现在，您可以启动[Remix](https://remix.ethereum.org/)进行操作。您需要创建一个新文件以保存Solidity智能合约。点击**File Explorers**下方&#x7684;**+**&#x6309;钮并在弹窗中输入文件名称“MyToken.sol”。

![](/files/yjLSopNJUiO5bOoqEBVi)

接着，将以下智能合约粘贴至弹窗的编辑框内：

```
pragma solidity ^0.7.0;

import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC20/ERC20.sol';

// This ERC-20 contract mints the specified amount of tokens to the contract creator.
contract MyToken is ERC20 {
  constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") {
    _mint(msg.sender, initialSupply);
  }
}
```

![](/files/4ToxGNl4Rz50IuzB097q)

这是一个基于最新OpenZeppelin ERC-20模板编写的简易版ERC-20合约。该合约使用`MYTOK`作为`MyToken`的符号，并为合约创建者铸造初始Token。

接着，导向至侧边选项的**Compile**并点击**Compile MyToken.sol**按钮。

![](/files/aKIBNUKsZp9VKjMQLrbr)

您将会看到Remix下载了所有OpenZeppelin的依赖项并完成合约编译。

当您选择**Injected Web3**选项时，您需授权Remix连接您的MetaMask账户。

![](/files/RrCjDuSn54yOWEtAJteJ)

接着返回Remix界面，您会看到您想要用来部署的账户已经通过MetaMask授权登入。在**Deploy**按键的旁边输入Token数额，假设我们现在要部署1000万的Token。但由于此合约默认位数为小数点后18位，因此您需要在输入框内输入`10000000000000000000000000`。

![](/files/4TQOu82kqAv1GnuyLzyp)

随后，MetaMask将跳出弹窗要求您确认此次部署合约的交易。

![](/files/RmgIcv5cdcmOtovuOeL9)

在您点击**Confirm**后部署也随之完成，您将会在MetaMask上看到您的交易记录。与此同时，合约也将会在Remix中的**Deployed Contracts**下出现。

成功部署合约之后，您便可通过Remix与智能合约进行交互。

![](/files/g4iddmhh5WCjC5aZxw1T)

将页面下滑，找到**Deployed Contracts**，点击**name**、**symbol**，以及**totalSupply**，将会分别出现`MyToke`、`MYTOK`以及`10000000000000000000000000`。如果您复制合约地址并将它粘贴在**balanceOf**字段中，您可以看到用户ERC-20地址上的账户全部余额。点击合约名称和地址旁边的按钮可复制合约地址。

![](/files/C2ZGIL2hf5mFcve6Droz)

现在，打开MetaMask添加刚部署的ERC-20 Token。在操作之前先确认您已在Remix上复制了合约地址。回到MetaMask，如下图所示，点击**Add Token**。请确保您现在所操作的账户为已部署合约的账户。

![](/files/bzHDdEz7WBIdlLC5EwJf)

将已复制的合约地址粘贴至**Custom Token**字段内，与此同时**Token Symbol**和**Decimals of Precision**字段会自动填充。

![](/files/DJxuVGNIGRmGgYSj9y9c)

点击**Add Token**后，您会看到800万的MyTok已成功加入您的账户：

![](/files/zXvqSYwLHqSvH47QfWed)


---

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

```
GET https://docs.polysmartchain.com/zhong-wen-jian-ti/kai-fa-zhe/fa-bu-prc20-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.
