Skip to content

Commit

Permalink
Added a local chain definition. Added an example how to deploy a crow…
Browse files Browse the repository at this point in the history
…dsale token on a local chain.
  • Loading branch information
miohtama committed Jan 2, 2018
1 parent f370512 commit 82b8c69
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 10 deletions.
74 changes: 74 additions & 0 deletions crowdsales/crowdsale-token-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This is an example for deploying a crowdsale compatible EIP-20 token on a private testnet.
#
# First start a transient local Ethereum chain using populus and geth:
#
# populus chain run local
#
# This will start a private chain running geth in port 8548. The
# first launch might be slow as it has to generate 1 GB DAG file.
# Leave populus + geth running on the background.
#
# Then in another terminal you can run a command to deploy this token script:
#
# deploy-contracts --address=coinbase --deployment-file=crowdsales/crowdsale-token-example.yml --deployment-name=local-token
#
# This will deploy a new token using the default coinbase account
# on the local chain. Running the command takes ~60 seconds.
#
# You can find it your coinbase account (account 0) by doing:
#
# geth attach http://localhost:8548
#
# > eth.accounts
# ["0xce90d9e5024e97f3123999aae6a1c395bb3c2013"]
#

# This is the deployment-name parameter.
# We can have multiple deployments in a single YAML file.
local-token:

# This is the chain name in populus.json
chain: local

# We cannot verify the contract on EtherScan, because EtherScan only supports public nets
verify_on_etherscan: no

contracts:

# This deploys CrowdsaleToken contract.
# This contract is a superset of EIP-20 token
# with added metadata, upgrade and release functionality.
token:
contract_name: CrowdsaleToken
contract_file: CrowdsaleToken.sol
arguments:
_name: "MooToken"
_symbol: "MOO"
_initialSupply: "{{ 100000000000*10**18 }}"
_decimals: 18 # Standardish decimals for EIP-20 tokens
_mintable: false

# No special post-deployment transactions needed
post_actions: |
# By default, our crowdsale token tranfers work only on whitelisted address.
# (To prevent shadow markets during the token sale).
# In post-actions we make token transferable.
# Make owner to be address / contract that controls the release
confirm_tx(token.transact({"from": deploy_address}).setReleaseAgent(deploy_address))
# Unlock token transfers
confirm_tx(token.transact({"from": deploy_address}).releaseTokenTransfer())
# Verify that we have correctly deployed the contract
verify_actions: |
# Token is now transferable
assert token.call().released()
# We deployed using coinbase account
assert deploy_address == web3.eth.accounts[0]
# Check that the owner got all initial balance
assert token.call().balanceOf(deploy_address) == 100000000000*10**18
2 changes: 2 additions & 0 deletions ico/cmd/deploytoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
def main(chain, address, contract_name, name, symbol, supply, decimals, minting_agent, release_agent, verify, verify_filename, master_address):
"""Deploy a single crowdsale token contract.
THIS COMMAND IS DEPRECATED. PLEASE USE deploy-contracts instead.
Examples:
deploy-token --chain=ropsten --address=0x3c2d4e5eae8c4a31ccc56075b5fd81307b1627c6 --name="MikkoToken 2.0" --symbol=MOO --release-agent=0x3c2d4e5eae8c4a31ccc56075b5fd81307b1627c6 --supply=100000
Expand Down
1 change: 1 addition & 0 deletions ico/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _confirm_multiple_txs(*txids, timeout=180):
context["confirm_tx"] = _confirm_tx
context["confirm_multiple_txs"] = _confirm_multiple_txs
context["load_investor_data"] = load_investor_data
context["web3"] = web3
return context


Expand Down
14 changes: 6 additions & 8 deletions ico/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def deploy_crowdsale(project: Project, chain, yaml_filename: str, source_definit
chain_name = runtime_data["chain"]
verify_on_etherscan = asbool(runtime_data["verify_on_etherscan"])
browser_driver = runtime_data.get("browser_driver", "chrome")
solc = runtime_data["solc"]
solc = runtime_data.get("solc")

need_unlock = runtime_data.get("unlock_deploy_address", True)

Expand Down Expand Up @@ -255,13 +255,11 @@ def perform_verify_actions(chain, runtime_data: dict, contracts: dict):


def _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address):
"""
:param project:
:param chain:
:param chain_data:
:param deploy_address:
:return:
"""
"""Kernel for deploing contracts."""

# Coinbase aliasing
if deploy_address == "coinbase":
deploy_address = web3.eth.accounts[0]

address = deploy_address
print("Web3 provider is", web3.currentProvider)
Expand Down
48 changes: 46 additions & 2 deletions populus.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,42 @@
}
},

"local": {
"chain": {
"class": "populus.chain.geth.LocalGethChain",
"settings": {
"rpc_port": "8548"
}
},
"contracts": {
"backends": {
"JSONFile": {
"$ref": "contracts.backends.JSONFile"
},
"Memory": {
"$ref": "contracts.backends.Memory"
},
"ProjectContracts": {
"$ref": "contracts.backends.ProjectContracts"
},
"TestContracts": {
"$ref": "contracts.backends.TestContracts"
}
}
},
"web3": {
"provider": {
"class": "web3.providers.rpc.HTTPProvider",
"settings": {
"endpoint_uri": "http://127.0.0.1:8548",
"request_kwargs": {
"timeout": 180
}
}
}
}
},

"ropsten": {
"chain": {
"class": "populus.chain.external.ExternalChain"
Expand Down Expand Up @@ -100,7 +136,10 @@
},
"temp": {
"chain": {
"class": "populus.chain.geth.TemporaryGethChain"
"class": "populus.chain.geth.TemporaryGethChain",
"settings": {
"rpc_port": "8548"
}
},
"contracts": {
"backends": {
Expand All @@ -116,7 +155,12 @@
}
},
"web3": {
"$ref": "web3.GethIPC"
"provider": {
"class": "web3.providers.rpc.HTTPProvider",
"settings": {
"endpoint_uri": "http://127.0.0.1:8547"
}
}
}
},
"tester": {
Expand Down

0 comments on commit 82b8c69

Please sign in to comment.