Created
March 24, 2019 02:29
-
-
Save miguelmota/cf07dd0f6e7456bf55d364ded6882f49 to your computer and use it in GitHub Desktop.
ZeppelinOS notes
This file contains 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.5.0; | |
import "zos-lib/contracts/Initializable.sol"; | |
contract MyContract is Initializable { | |
uint256 public x; | |
string public s; | |
// the 'initializer' modifier prevents the function from being called more than once. | |
function initialize(uint256 _x, string memory _s) initializer public { | |
x = _x; | |
s = _s; | |
} | |
} | |
npx zos init my-project | |
npm install truffle@5.0.4 | |
npm install zos-lib | |
# add contract to project | |
npx zos add MyContract | |
# push is intended for logic contracts only | |
npx zos push | |
# create contract to interact with (proxy) | |
npx zos create MyContract --init initialize --args 42,hitchhiker | |
npx truffle console --network local | |
truffle(local)> myContract = await MyContract.at('0xBe0B0f08A599F07699E98A9D001084e97b9a900A') | |
undefined | |
truffle(local)> (await myContract.x()).toString() | |
'42' | |
truffle(local)> myContract.s() | |
'hitchhiker' | |
# upgrade contract | |
npx zos push | |
npx zos update MyContract | |
# install openzeppelin-eth contracts locally | |
npx zos link openzeppelin-eth | |
npx zos add MyLinkedContract | |
npx zos link npm-module> | |
npx zos push --deploy-dependencies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment