in 2022.6, truffle 5.x + version, you can speicify the compiler version. e.g.
Bby default , solc version is 0.4.x , you can make it 0.8.x
$ cat truffle-config.js
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
},
},
// here you can speicify the compiler version
// by default , solc version is 0.4.x
compilers: {
solc: {
version: "^0.8.0",
}
}
};
and at the first time you run truffle migrate, you may see truffle downloaded the 0.8.x compiler, e.g.
$ truffle migrate --network development --verbose-rpc --interactive
Compiling your contracts...
✓ Fetching solc version list from solc-bin. Attempt #1
✓ Downloading compiler. Attempt #1.
✓ Fetching solc version list from solc-bin. Attempt #1
> Compiling ./contracts/MyTestNft.sol
> Artifacts written to /mnt/d/workspace/test_erc_721/build/contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
refer to: https://trufflesuite.com/docs/truffle/reference/configuration/
a compile example from official doc:
module.exports = {
compilers: {
solc: {
version: <string>, // A version or constraint - Ex. "^0.5.0"
// Can be set to "native" to use a native solc or
// "pragma" which attempts to autodetect compiler versions
docker: <boolean>, // Use a version obtained through docker
parser: "solcjs", // Leverages solc-js purely for speedy parsing
settings: {
optimizer: {
enabled: <boolean>,
runs: <number> // Optimize for how many times you intend to run the code
},
evmVersion: <string> // Default: "istanbul"
},
modelCheckerSettings: {
// contains options for SMTChecker
}
}
}
}