Last active
December 19, 2017 20:27
-
-
Save blueplanet/af10ed67c29728898b9e8177db6e6538 to your computer and use it in GitHub Desktop.
Truffle の Migration は何をやっている? ref: https://qiita.com/blueplanet/items/e3f5590c9711df4d4845
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployer.deploy(A); | |
deployer.deploy(B); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployer.deploy(A).then(function() { | |
return deployer.deploy(B, A.address); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(deployer, network) { | |
// 正式ネットワーク以外の場合、デモデータ導入する | |
if (network != "live") { | |
deployer.exec("add_demo_data.js"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployer.deploy(A, arg1, arg2, ...); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployer.deploy([ | |
[A, arg1, arg2, ...], | |
B, | |
[C, arg1] | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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