Skip to content

Instantly share code, notes, and snippets.

@blueplanet
Last active December 19, 2017 20:27
Show Gist options
  • Save blueplanet/af10ed67c29728898b9e8177db6e6538 to your computer and use it in GitHub Desktop.
Save blueplanet/af10ed67c29728898b9e8177db6e6538 to your computer and use it in GitHub Desktop.
Truffle の Migration は何をやっている? ref: https://qiita.com/blueplanet/items/e3f5590c9711df4d4845
deployer.deploy(A);
deployer.deploy(B);
deployer.deploy(A).then(function() {
return deployer.deploy(B, A.address);
});
module.exports = function(deployer, network) {
// 正式ネットワーク以外の場合、デモデータ導入する
if (network != "live") {
deployer.exec("add_demo_data.js");
}
}
deployer.deploy(A, arg1, arg2, ...);
deployer.deploy([
[A, arg1, arg2, ...],
B,
[C, arg1]
]);
pragma solidity ^0.4.17;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
function Migrations() 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);
}
}
var old_contract = eth.contract(abi).at(address1)
old_contract.upgrade.sendTransaction(address2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment