Admin 发布的文章

# 首先安装mvn
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

# 安装后可能会提示你设置环境变量,按照提示运行去设置即可
# 如果网络无法连接,可能需要export一下proxy

# 然后用nvm安装node
nvm install 14.18.2

# 然后启用刚安装的版本
nvm use node

# 查看版本
node -v

  1. 进入文件夹~/Library/Preferences/
  2. 用XCode打开com.apple.HIToolbox.plist,删除AppleEnabledInputSources里的KeyboardLayout Name U.S.并保存,先不要关闭XCode
  3. 在文件夹~/Library/Preferences/里右击com.apple.HIToolbox.plist查看Info,勾选Lock
  4. 关闭XCode,再次打开com.apple.HIToolbox.plist查看是否删除成功,重启电脑即可生效

注意:名字不一定是KeyboardLayout Name U.S.,可以根据自己情况删除

npm install -g truffle-flattener

because some new features in solidity 0.8.x might go wrong by [email protected], so after installed, run code below again:

inpm nstall -g https://github.com/jplew/truffle-flattener

usage:

truffle-flattener ./contracts/MyContract.sol > ./flatten/MyContractFlatten.sol

and then put faltten code as single solidity file to bscscan

  • open your truffle project folder, and then run:
npm init -y

it will generate a file package.json in the root folder

  • install openzeppelin contracts:
npm install @openzeppelin/contracts
  • add a test solidity file called MyToken.sol to folder contracts/, and then put these test code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") {}
    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

more usage, see node_modules/@openzeppelin/contracts/README.md

note: pragma solidity in the MyToken.sol above is ^0.8.4, and it is 0.8.0 in "@openzeppelin/contracts/token/ERC20/ERC20.sol", but it also compile successful

  • compile this project:
truffle compile

more details, watch this: /playlist?list=PLbbtODcOYIoFdQ37ydykQNO-MNGER6mtd