![](/img/trans.png)
[英]Deploy 2 RaspberryPi's on test network and link them to a smart-contract
[英]Deploy smart contract on Ropsten network
我正在尝试在 Ropsten 网络上部署测试合同。 我正在使用 metamask、infura 和 truffle 来创建和测试合约。 我的文件夹结构是这样的
我的迁移文件有以下代码
const TestContract = artifacts.require("TestContract");
module.exports = function(deployer) {
deployer.deploy(TestContract);
};
当我运行 truffle migrate 时,我收到以下错误无法从任何来源找到迁移的工件
我的 truffle-config.js 看起来像这样
const HDWalletProvider = require('truffle-hdwallet-provider')
module.exports = {
networks: {
ropsten: {
provider: function() {
return new HDWalletProvider("Mnemonic key", "https://ropsten.infura.io/v3/API_KEY")
},
network_id: 3,
gas: 4000000
}
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
compilers: {
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
}
}
您需要在您的合同文件夹中有Migrations
合同:
pragma solidity >=0.4.25 <0.6.0;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
constructor() public {
owner = msg.sender;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
还有一个1_initial_migration.js
在您的迁移文件夹中:
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.