我正在使用松露5.0.30,我想创建一个开发区块链,我可以运行和测试我的合同。这是我正在使用的truffle-config.js:
module.exports = {
networks: {
mynet: {
host: "127.0.0.1", // Localhost (default: none)
port: 8547, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
gas: 8700000,
gasLimit: 8900000
}
},
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
//version: "0.6.4", // 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: true,
runs: 100
},
//evmVersion: "byzantium"
}
}
}
}当我使用命令truffle develop --network mynet启动网络时,会得到以下输出:
Warning: possible unsupported (undocumented in help) command line option: --network
Connected to existing Truffle Develop session at http://127.0.0.1:9545/
truffle(mynet)>它指示它创建了一个具有默认值的块链,而不是使用mynet配置中指定的值。如何强制松露使用mynet中的设置?
发布于 2020-03-31 08:22:44
如果您想创建自己的网络,应该使用ganache、ganache或test-rpc。这些是可以配置的本地块链测试网络。
在设置和运行网络之后,应该将网络配置添加到truffle-config.js中:
module.exports = {
networks: {
development: {
host: "localhost", // your if
port: 8545, // Your port
network_id: "5777" //
// ...other config
}
}
}然后,您可以通过truffle console --network development与您的网络交互,也可以通过truffle migrate --network development迁移合同。
发布于 2020-03-31 07:57:12
您可以通过在单独的进程中运行Ganache来创建您自己的模拟块链。在truf-config.js中,您可以更改开发网络的规范,然后只运行truffle test,默认情况下它将使用开发。在你的例子中,它可能是这样的
development: {
host: '127.0.0.1', // This might be different for you
port: 8545, // This might be different for you
network_id: YOUR_GANACHE_NETWORK_ID,
gas: 8700000,
gasLimit: 8900000
}或者您可以在旋转ganache时设置gasLimit,如:ganache-cli --gasLimit: 8900000
https://ethereum.stackexchange.com/questions/82011
复制相似问题