truffle技巧:更新Solidity版本 / 学习智能合约#14

truffle技巧:更新Solidity版本 / 学习智能合约#14

智能合约

Remix上Solidity版本已经更新到了0.6.10(更新发展得挺快的),而在truffle上一直是0.5.16版的,重新安装了几遍也没有更新到最新版!

查了下资料,这个需要额外的设置。需要手动修改 ‘truffle-config.js’ 文件中的’compilers’ -> ‘solc’ -> ‘version’至最新版(”0.6.10”)即可。

truffle会自动从官方拉取相应版本的编译器,不再需要你手动下载配置了。

1
2
3
4
5
6
7
8
9
10
11
12
13
compilers: {
solc: {
version: "0.6.10", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: "byzantium"
// }
}
}

试着编译下”truffle migrate”,可以看到在下载最新版的Solidity! turffle version看看:

1
2
3
4
Truffle v5.1.27 (core: 5.1.27)
Solidity - 0.6.10 (solc-js)
Node v12.13.0
Web3.js v1.2.1

Solidity已经更新到了最新版,可以愉快地玩耍啰!


This page is synchronized from the post: ‘truffle技巧:更新Solidity版本 / 学习智能合约#14’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×