Skip to content

Instantly share code, notes, and snippets.

@sithu
Created August 16, 2017 03:41
Show Gist options
  • Save sithu/a05bfc0af4ac73a6642c5cc7bbbb2683 to your computer and use it in GitHub Desktop.
Save sithu/a05bfc0af4ac73a6642c5cc7bbbb2683 to your computer and use it in GitHub Desktop.
chain: ropsten
# Use automated Chrome to verify all contracts on etherscan.io
# You need to install Splinter package:
# pip install splinter
verify_on_etherscan: no
browser_driver: chrome
contracts:
# This is the address of the multisig wallet where the paymnts eventually land
team_multisig:
contract_name: MultiSigWallet
contract_file: GnosisWallet.sol
address: '0x40f381b3bd8a4693a56f18984adfc4dd3322650e'
#
# Token contract
#
# This contract represents ERC-20 token.
# It has transfer lock up functionality to prevent the token to be transferable
# until the ICO is over.
#
# We create the whole token supply upfront and no more token minting
# happens ever.
#
# Token has 18 decimals.
#
# Token supply is one billion tokens.
#
# Name and symbol are not set yet. They are set later. In
# the case of the deployment fails and we need redeploy
# we do not create unnecessary entries in token explorers.
#
token: !!omap
- contract_name: BurnableCrowdsaleToken
- contract_file: BurnableCrowdsaleToken.sol
- arguments: !!omap
- _name: MooToken
- _symbol: MOO
- _initialSupply: 100000000000000000000000000000
- _decimals: 18
- _mintable: false
- address: '0x9ebc7a13f8909a3e778ffeaf478f29e3192f7694'
- constructor_args: '0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000001431e0fae6d7217caa00000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d6f6f546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034d4f4f0000000000000000000000000000000000000000000000000000000000'
- libraries:
SafeMathLib: '0x0f69edbab9f65197888f49eba552b8efbe6b18a2'
#
# Pricing strategy.
#
# We use ETH tranches. People who buy in in the first
# tranches get 20% and 10% bonus tokens.
#
pricing_strategy: !!omap
- contract_name: EthTranchePricing
- contract_file: EthTranchePricing.sol
- arguments: !!omap
- _tranches:
- 0
- 2272727272727
- 45000000000000000000000
- 2380952380952
- 90000000000000000000000
- 2500000000000
- 999999999999999000000000000000000
- 0
- address: '0x38732bf1fb0477ba4cbbb5bad56af18eb5905d1f'
- constructor_args: '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000211291a0d1700000000000000000000000000000000000000000000098774738bc8222000000000000000000000000000000000000000000000000000000000022a5bd2261800000000000000000000000000000000000000000000130ee8e717904440000000000000000000000000000000000000000000000000000000000246139ca800000000000000000000000000000000000000314dc6448d932ae0a456589c00000000000000000000000000000000000000000000000000000000000000000000'
- libraries:
SafeMathLib: '0x17cec37f169f8a34f28d4807602d7d1cfbaaa3a0'
crowdsale: !!omap
- contract_name: AllocatedCrowdsale
- contract_file: AllocatedCrowdsale.sol
- arguments: !!omap
- _token: '0x9ebc7a13f8909a3e778ffeaf478f29e3192f7694'
- _pricingStrategy: '0x38732bf1fb0477ba4cbbb5bad56af18eb5905d1f'
- _multisigWallet: '0x40f381b3bd8a4693a56f18984adfc4dd3322650e'
- _start: 1505221200
- _end: 1509022800
- _minimumFundingGoal: 15000000000000000000000
- _beneficiary: '0x40f381b3bd8a4693a56f18984adfc4dd3322650e'
- address: '0x44840f373e354badc39bd9baf1ed6594a3021be1'
- constructor_args: '0x0000000000000000000000006fda29059e37528f0b6975328c87eacb3c8bfe990000000000000000000000008ed546b4a61192286b8d9e967152911289b8445b00000000000000000000000082b7fdf7d900c1752c663432f4d252b6854b1a960000000000000000000000000000000000000000000000000000000059b7da500000000000000000000000000000000000000000000000000000000059f1dc5000000000000000000000000000000000000000000000032d26d12e980b60000000000000000000000000000082b7fdf7d900c1752c663432f4d252b6854b1a96'
- libraries:
SafeMathLib: '0x4b93484222b861d453bc818dfda2cb8d390815dd'
#
# Because deploy_address controls whole supply,
# we do not create any supply dynamically,
# we do not need a finalizer.
#
finalize_agent: !!omap
- contract_name: NullFinalizeAgent
- contract_file: NullFinalizeAgent.sol
- arguments: !!omap
- _crowdsale: '0x44840f373e354badc39bd9baf1ed6594a3021be1'
- address: '0x4607c8c17e8cbd2210be900746715a3cf7f617d1'
- constructor_args: '0x0000000000000000000000002eb2f363716f2617cd7924e748c8279be4a33f3b'
- libraries: {}
# Post-deployment actions connect contracts together.
post_actions: |2
# Allow crowdsale contract to sell its token
token.transact({"from": deploy_address}).approve(crowdsale.address, 70000000000*10**8)
# Make sure crowdsale contract and these accounts
# can transfer tokens despite transfer lock up
token.transact({"from": deploy_address}).setTransferAgent(team_multisig.address, True)
token.transact({"from": deploy_address}).setTransferAgent(crowdsale.address, True)
token.transact({"from": deploy_address}).setTransferAgent(finalize_agent.address, True)
token.transact({"from": deploy_address}).setTransferAgent(deploy_address, True)
# Do not do nothing at the end of the crowdsale
confirm_tx(crowdsale.transact({"from": deploy_address}).setFinalizeAgent(finalize_agent.address))
# Owner can release the token transfer when they fel its the time
confirm_tx(token.transact({"from": deploy_address}).setReleaseAgent(deploy_address))
# Set token upgrade master to team multisig to give the new token path
confirm_tx(token.transact({"from": deploy_address}).setUpgradeMaster(team_multisig.address))
# Allow test buys from these accounts before token sale begins.
# The latter one is a presale contract address.
# Presale contract (PreICOProxyBuyer) can move in funds
# and get tokens before the actual start time.
confirm_multiple_txs( \
crowdsale.transact({"from": deploy_address}).setEarlyParicipantWhitelist(deploy_address, True), \
crowdsale.transact({"from": deploy_address}).setEarlyParicipantWhitelist("0x6d997eDcA04282950416FA380d834f360fC36eBb", True) \
)
# We set a special price, outside ETH tranches, for a presale contract
confirm_tx(pricing_strategy.transact({"from": deploy_address}).setPreicoAddress("0x6d997eDcA04282950416FA380d834f360fC36eBb", 2083333333333))
# Sanity check
verify_actions: |
assert token.call().owner().lower() == deploy_address.lower()
assert token.call().released() == False
assert crowdsale.call().owner().lower() == deploy_address.lower()
assert crowdsale.call().multisigWallet().lower() == team_multisig.address.lower()
assert finalize_agent.call().isSane()
assert crowdsale.call().getState() == CrowdsaleState.PreFunding # PreFunding for the final, as it is deployed pre-opening
# Do a test buy using a test address.
# This ensures are variables are set and the
# funds flow in the multisig wallet.
#confirm_tx(crowdsale.transact({"from": deploy_address, "value": to_wei("0.02", "ether")}).buy())
# As the last action, after successful deployment, set the right token symbol and name so that it shows in a blockchain explorer
confirm_tx(token.transact({"from": deploy_address}).setTokenInformation("MooToken", "MOO"))
deploy_address: '0x7bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8'
@sithu
Copy link
Author

sithu commented Aug 16, 2017

$ testrpc
EthereumJS TestRPC v4.0.1 (ganache-core: 1.0.1)

Available Accounts

(0) 0x40f381b3bd8a4693a56f18984adfc4dd3322650e
(1) 0x9ebc7a13f8909a3e778ffeaf478f29e3192f7694
(2) 0x38732bf1fb0477ba4cbbb5bad56af18eb5905d1f
(3) 0x44840f373e354badc39bd9baf1ed6594a3021be1
(4) 0x4607c8c17e8cbd2210be900746715a3cf7f617d1
(5) 0x4b93484222b861d453bc818dfda2cb8d390815dd
(6) 0x1f30139318e02e47408ab035a327564de13cb0af
(7) 0x3cf3527585fa41738872ed184ab085b94327f5ed
(8) 0xb43f0acf72bb429db153b47ed1073adca94249c0
(9) 0x7bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8

Private Keys

(0) 6e11f9e7f8ca15d24a48494478cbddf01810b387e6c1cbb4c27ff996288d4376
(1) 00d61b68856231f595b5e336c325a2d1012eeabe2f0eb1e8520917c1c403c53e
(2) c83b99ef415f0cb056b62c3f72547daad59eeb7aaa633faf8f67cf53c74f6d84
(3) 487f4a984a7528b3f505aa254f727121032d4bf949fd1a84044e3570e633ccd9
(4) feeabd3bf1b47baa7caaeedd5c4d38fa2b60919d4ee22a82e6a28dd5199de725
(5) 8e8f183bfca8764f8cfdd0119b0a6a336c92ef46776081d7183326b6bba0ab72
(6) b6c927d67de4315acfea1e35a7585bdb61e43f7b687d59ab2f50f6e40111690f
(7) 6b992596a3553e1877a61657f2d4f41fdc8fd0888290cd7ef9a3490aa79086e1
(8) dca0b0f874559b824bad579891d64592de2be8888d97f7d44711227133d66630
(9) 7cd01df28e07411b1df2e24f42015f08052aa891683ff5e2a844e84ae03508a1

HD Wallet

Mnemonic: volcano buddy project desert garage seed sorry patient fatal divert hub either
Base HD Path: m/44'/60'/0'/0/{account_index}

Listening on localhost:8545

@sithu
Copy link
Author

sithu commented Aug 16, 2017

Error

$ deploy-contracts --address=0x7bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8  --deployment-file=crowdsales/allocated-token-sale-example.yml --deployment-name=mainnet
Web3 provider is RPC connection http://127.0.0.1:8545
Owner address is 0x7bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8
Owner balance is 100 ETH
Already deployed contract, team_multisig 0x82b7fdf7d900c1752c663432f4d252b6854b1a96
Starting BurnableCrowdsaleToken deployment, with arguments  {'_name': 'MooToken', '_symbol': 'MOO', '_initialSupply': 100000000000000000000000000000, '_decimals': 18, '_mintable': False}
BurnableCrowdsaleToken address is 0x2e068cf21cb0f9e1473870259c46bf86f98c9d89
BurnableCrowdsaleToken constructor arguments payload is 0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000001431e0fae6d7217caa00000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d6f6f546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034d4f4f0000000000000000000000000000000000000000000000000000000000
BurnableCrowdsaleToken libraries are {'SafeMathLib': '0x5e57016ec9161af13832dad6d27bf18b6ca3c195'}
Starting EthTranchePricing deployment, with arguments  {'_tranches': [0, 2272727272727, 45000000000000000000000, 2380952380952, 90000000000000000000000, 2500000000000, 999999999999999000000000000000000, 0]}
EthTranchePricing address is 0xf2d9d5c2774deb11cb9335b19aa391cd07f4dbed
EthTranchePricing constructor arguments payload is 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000211291a0d1700000000000000000000000000000000000000000000098774738bc8222000000000000000000000000000000000000000000000000000000000022a5bd2261800000000000000000000000000000000000000000000130ee8e717904440000000000000000000000000000000000000000000000000000000000246139ca800000000000000000000000000000000000000314dc6448d932ae0a456589c00000000000000000000000000000000000000000000000000000000000000000000
EthTranchePricing libraries are {'SafeMathLib': '0xf59014769b8dd60c70b1c7f3cf413ede80335891'}
Starting AllocatedCrowdsale deployment, with arguments  {'_token': '0x2e068cf21cb0f9e1473870259c46bf86f98c9d89', '_pricingStrategy': '0xf2d9d5c2774deb11cb9335b19aa391cd07f4dbed', '_multisigWallet': '0x82b7fdf7d900c1752c663432f4d252b6854b1a96', '_start': 1505134800, '_end': 1509022800, '_minimumFundingGoal': 15000000000000000000000, '_beneficiary': '0x7bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8'}
AllocatedCrowdsale address is 0x426b370d3b0682794a8f40410eb5a408ed1e18e3
AllocatedCrowdsale constructor arguments payload is 0x0000000000000000000000002e068cf21cb0f9e1473870259c46bf86f98c9d89000000000000000000000000f2d9d5c2774deb11cb9335b19aa391cd07f4dbed00000000000000000000000082b7fdf7d900c1752c663432f4d252b6854b1a960000000000000000000000000000000000000000000000000000000059b688d00000000000000000000000000000000000000000000000000000000059f1dc5000000000000000000000000000000000000000000000032d26d12e980b6000000000000000000000000000007bce9a8d57bd2a4e95accd5bd14676f4a8c08ae8
AllocatedCrowdsale libraries are {'SafeMathLib': '0x5b18de24379be6e372431ecbc2517ca14fdd70e7'}
Starting NullFinalizeAgent deployment, with arguments  {'_crowdsale': '0x426b370d3b0682794a8f40410eb5a408ed1e18e3'}
NullFinalizeAgent address is 0x69367214858ee5e8625afed90c291c385dc7afc9
NullFinalizeAgent constructor arguments payload is 0x000000000000000000000000426b370d3b0682794a8f40410eb5a408ed1e18e3
NullFinalizeAgent libraries are {}
Performing post-deployment contract actions
Action: # Allow crowdsale contract to sell its token
Action: token.transact({"from": deploy_address}).approve(crowdsale.address, 70000000000*10**8)
Action: # Make sure crowdsale contract and these accounts
Action: # can transfer tokens despite transfer lock up
Action: token.transact({"from": deploy_address}).setTransferAgent(team_multisig.address, True)
Action: token.transact({"from": deploy_address}).setTransferAgent(crowdsale.address, True)
Action: token.transact({"from": deploy_address}).setTransferAgent(finalize_agent.address, True)
Action: token.transact({"from": deploy_address}).setTransferAgent(deploy_address, True)
Action: # Do not do nothing at the end of the crowdsale
Action: confirm_tx(crowdsale.transact({"from": deploy_address}).setFinalizeAgent(finalize_agent.address))
Action: # Owner can release the token transfer when they fel its the time
Action: confirm_tx(token.transact({"from": deploy_address}).setReleaseAgent(deploy_address))
Action: # Set token upgrade master to team multisig to give the new token path
Action: confirm_tx(token.transact({"from": deploy_address}).setUpgradeMaster(team_multisig.address))
Action: # Allow test buys from these accounts before token sale begins.
Action: # The latter one is a presale contract address.
Action: # Presale contract (PreICOProxyBuyer) can move in funds
Action: # and get tokens before the actual start time.
Action: confirm_multiple_txs( crowdsale.transact({"from": deploy_address}).setEarlyParicipantWhitelist(deploy_address, True), crowdsale.transact({"from": deploy_address}).setEarlyParicipantWhitelist("0x82b7fdf7d900c1752c663432f4d252b6854b1a96", True) )
Action: # We set a special price, outside ETH tranches, for a presale contract
Action: confirm_tx(pricing_strategy.transact({"from": deploy_address}).setPreicoAddress("0x82b7fdf7d900c1752c663432f4d252b6854b1a96", 2083333333333))
Performing deployment verification
Verification: assert token.call().owner().lower() == deploy_address.lower()
Verification: assert token.call().released() == False
Verification: assert crowdsale.call().owner().lower() == deploy_address.lower()
Verification: assert crowdsale.call().multisigWallet().lower() == team_multisig.address.lower()
Verification: assert finalize_agent.call().isSane()
Verification: assert crowdsale.call().getState() == CrowdsaleState.PreFunding   # PreFunding for the final, as it is deployed pre-opening
Verification: # Do a test buy using a test address.
Verification: # This ensures are variables are set and the
Verification: # funds flow in the multisig wallet.
Verification: confirm_tx(crowdsale.transact({"from": deploy_address, "value": to_wei("0.02", "ether")}).buy())
Traceback (most recent call last):
  File "/Users/saung/project/eth/ico/ico/deploy.py", line 188, in exec_lines
    exec(buffer, context)
  File "<string>", line 1, in <module>
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/contract.py", line 809, in transact_with_contract_function
    txn_hash = contract.web3.eth.sendTransaction(transact_transaction)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/eth_utils/string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/eth.py", line 239, in sendTransaction
    transaction=formatted_transaction,
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/utils/transactions.py", line 47, in get_buffered_gas_estimate
    gas_estimate = web3.eth.estimateGas(gas_estimate_transaction)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/utils/functional.py", line 14, in inner
    value = fn(*args, **kwargs)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/eth.py", line 282, in estimateGas
    [formatted_transaction],
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/providers/manager.py", line 51, in request_blocking
    raise ValueError(response["error"])
ValueError: {'message': 'Error: VM Exception while executing eth_estimateGas: invalid JUMP at f5303ea21aae5b6fb07c130ced2835b765e5265e90de4195ee31fe7e3187768f/426b370d3b0682794a8f40410eb5a408ed1e18e3:6748\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59880:17\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88044:5\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11863:9\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8423:16\n    at replenish (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8943:25)\n    at iterateeCallback (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8933:17)\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8908:16\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11860:13\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88040:9\n    at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:73948:7', 'code': -32000}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/saung/project/eth/ico/venv/bin/deploy-contracts", line 11, in <module>
    load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/saung/project/eth/ico/ico/cmd/deploycontracts.py", line 22, in main
    deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
  File "/Users/saung/project/eth/ico/ico/deploy.py", line 263, in deploy_crowdsale_from_file
    return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
  File "/Users/saung/project/eth/ico/ico/deploy.py", line 249, in _deploy_contracts
    perform_verify_actions(chain, runtime_data, contracts)
  File "/Users/saung/project/eth/ico/ico/deploy.py", line 226, in perform_verify_actions
    exec_lines(verify_actions, context, print_prefix="Verification:")
  File "/Users/saung/project/eth/ico/ico/deploy.py", line 190, in exec_lines
    raise RuntimeError("Failed when running: {}".format(buffer)) from e
RuntimeError: Failed when running: confirm_tx(crowdsale.transact({"from": deploy_address, "value": to_wei("0.02", "ether")}).buy())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment