![](/img/trans.png)
[英]I try to deploy my smart contract in truffle but is says "unsupported compiler" when I "truffle migrate" how can I fix this?
[英]truffle migrate only migrating first contract, not the second
命令“truffle migrate”工作正常(没有错误)但只迁移“Migrations.sol”。 它甚至不尝试使用 2_deploy_contracts.js 进行迁移
1_initial_migration.js:
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
迁移.sol:
enter code herepragma solidity ^0.4.25;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
function Migration() public {
owner = msg.sender;
}
function setCompleted(uint completed) restricted public{
last_completed_migration = completed;
}
function upgrade(address new_address) restricted public{
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
2_deploy_contracts.js:
var Election = artifacts.require("./Election.sol");
module.exports = function(deployer) {
deployer.deploy(Election);
};
选举.sol:
pragma solidity ^0.4.25;
contract Election {
// Store candidate
// Read candidate
string public candidate;
// Constructor
// Our constructor will be run when the contract gets deployed, so must be public
constructor() public{
candidate = "Candidate 1";
}
}
解决方案:我删除了我的项目文件夹并重建了它。 这修复了它。 不确定到底是什么问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.