> For the complete documentation index, see [llms.txt](https://happyboy.gitbook.io/happynotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://happyboy.gitbook.io/happynotes/ji-suan-ji/yu-yan/solidity/kuang-jia/openzeppelin/chang-yong-cao-zuo.md).

# 常用操作

## ERC20使用

```solidity
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 1000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

```

## 使用内置ERC20合约对象

```solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Test_2 is ERC20{
     constructor() ERC20("ld ssa", "LDN") {
        _mint(msg.sender, 1 * 10**8 * 10**18);
    }
}
```
