tokenmarketnet / smart-contracts Goto Github PK
View Code? Open in Web Editor NEWEthereum smart contracts for security and utility tokens
Home Page: https://tokenmarket.net/
License: Other
Ethereum smart contracts for security and utility tokens
Home Page: https://tokenmarket.net/
License: Other
For some legal scenarios it might be important that we limit the amount people can invest to a Crowdsale.
Python 3.5.3
Parity 1.7
Kovan chain
All installation steps are passed from the docs
deploy-token
generates No module named 'splinter'
error after token contract deploying (but should note, that contract is created)
Full log:
(venv) viktors-MacBook-Pro:TokenMarketNet_ico viktor$ deploy-token --chain=kovan --contract-name="CentrallyIssuedToken" --address=0x005364854d51A0A12cb3cb9A402ef8b30702a565 --name="TestToken" --symbol=MOO --supply=916 --decimals=0 --verify --verify-filename=CentrallyIssuedToken.sol
Web3 provider is RPC connection http://localhost:8545
Deployer address is 0x005364854d51A0A12cb3cb9A402ef8b30702a565
Deployer balance is 0.985119332 ETH
Starting contract deployment
Contract address is 0xf4e3f2f959e1da62ef30ff0684ba88a7b0db4bad
CrowdsaleToken constructor arguments is 000000000000000000000000005364854d51a0a12cb3cb9a402ef8b30702a56500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000003940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000954657374546f6b656e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034d4f4f0000000000000000000000000000000000000000000000000000000000
Traceback (most recent call last):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/ico/etherscan.py", line 35, in verify_contract
from splinter import Browser
ImportError: No module named 'splinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/bin/deploy-token", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-token')()
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/ico/cmd/deploytoken.py", line 113, in main
browser_driver=browser_driver)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/ico/etherscan.py", line 37, in verify_contract
raise RuntimeError("Splinter package must be installed for verification automation")
RuntimeError: Splinter package must be installed for verification automation
https://github.com/TokenMarketNet/ico/blob/master/contracts/FlatPricing.sol#L23
I'd recommend adding:
require(_oneTokenInWei > 0)
to let calculatePrice
do the right thing.
In the token distribution script, when you check for duplicate addresses, make sure addresses are normalized using lower()
as input CSV may contain both checksummed and non-checksummed Ethereum addresses.
(venv) mymaps@mymaps-ThinkPad-E550:~/Desktop/taza/ico$ deploy-contracts --deployment-name testnet --deployment-file crowdsales/example.yml --address 0x00d2be7F3866160F900DF954E8f032d20fC11e85
Web3 provider is RPC connection http://127.0.0.1:8545
Owner address is 0x00d2be7F3866160F900DF954E8f032d20fC11e85
Owner balance is 6.69832 ETH
Starting Wallet deployment, with arguments {'_owners': ['0x00d2be7F3866160F900DF954E8f032d20fC11e85', '0x001684606978c3B5F50D8AEC9A98FC137209C196'], '_daylimit': 0, '_required': 1}
Traceback (most recent call last):
File "/home/mymaps/Desktop/taza/ico/ico/deploy.py", line 64, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 150, in deploy_contract
ContractFactory = self.get_contract_factory(contract_identifier)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 237, in get_contract_factory
BaseContractFactory = self.get_base_contract_factory(contract_identifier)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 189, in get_base_contract_factory
return get_base_contract_factory(contract_identifier, self.provider_backends)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 38, in get_base_contract_factory
"from any of the configured backends".format(contract_identifier)
populus.contracts.exceptions.UnknownContract: No contract data was available for the contract identifier 'Wallet' from any of the configured backends
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/deploy-contracts", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 87, in augment_usage_errors
yield
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/mymaps/Desktop/taza/ico/ico/cmd/deploycontracts.py", line 22, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/home/mymaps/Desktop/taza/ico/ico/deploy.py", line 263, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/home/mymaps/Desktop/taza/ico/ico/deploy.py", line 247, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
File "/home/mymaps/Desktop/taza/ico/ico/deploy.py", line 130, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/home/mymaps/Desktop/taza/ico/ico/deploy.py", line 66, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract Wallet, constructor arguments {'_owners': ['0x00d2be7F3866160F900DF954E8f032d20fC11e85', '0x001684606978c3B5F50D8AEC9A98FC137209C196'], '_daylimit': 0, '_required': 1}
Currently build/expanded
contract output is written by deploy-contracts
only if the contract is verified on EtherScan.
This should be written regardless.
Hi, often facing this error in various steps of my deployment script:
Starting CrowdsaleToken deployment, with arguments {'_decimals': 18, '_initialSupply': 300000000000000000000000000, '_symbol': '', '_name': ''}
Traceback (most recent call last):
File "/home/work/ico/deploy.py", line 66, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/home/work/venv/lib/python3.5/site-packages/populus/contracts/provider.py", line 123, in deploy_contract
contract_address = self.chain.wait.for_contract_address(deploy_transaction_hash)
File "/home/work/venv/lib/python3.5/site-packages/populus/wait.py", line 33, in for_contract_address
txn_receipt = self.for_receipt(txn_hash, **kwargs)
File "/home/work/venv/lib/python3.5/site-packages/populus/wait.py", line 47, in for_receipt
return wait_for_transaction_receipt(self.web3, txn_hash, **kwargs)
File "/home/work/venv/lib/python3.5/site-packages/populus/utils/wait.py", line 34, in wait_for_transaction_receipt
poll_interval_fn=lambda: poll_interval if poll_interval is not None else random.random(),
File "/home/work/venv/lib/python3.5/site-packages/populus/utils/wait.py", line 22, in poll_until
_timeout.sleep(poll_interval_fn())
File "/home/work/venv/lib/python3.5/site-packages/populus/utils/compat/compat_stdlib.py", line 74, in sleep
self.check()
File "/home/work/venv/lib/python3.5/site-packages/populus/utils/compat/compat_stdlib.py", line 67, in check
raise self
populus.utils.compat.compat_stdlib.Timeout: 120 seconds
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/work/venv/bin/deploy-contracts", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "/home/work/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/work/venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/work/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/work/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/work/ico/cmd/deploycontracts.py", line 31, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/home/work/ico/deploy.py", line 288, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/home/work/ico/deploy.py", line 272, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, yaml_filename, chain_data, deploy_address)
File "/home/work/ico/deploy.py", line 133, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/home/work/ico/deploy.py", line 68, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract CrowdsaleToken, constructor arguments {'_decimals': 18, '_initialSupply': 300000000000000000000000000, '_symbol': '', '_name': ''}
What is the reason for this error? I'm running my client in a VirtualBox so my options regarding hardware are slightly limited. Is there some way to perhaps increase the timeout duration?
For reference, I'm running parity using the command parity --unlock="0x0foo" --password="y" --mode active --tracing off --pruning fast --db-compaction ssd --cache-size 4096 --force-ui ui
and this is what htop
reads like during normal syncing of the mainnet chain.
https://github.com/TokenMarketNet/ico/blob/9f114b1cad7312f95e937cd1e855af35b9d97214/contracts/CrowdsaleBase.sol#L332
ethereum/solidity#610
since transfer
already does throw an error on failure, I think it could be cleaner approach instead.
Proposed change to
multisigWallet.transfer(weiAmount)
https://github.com/TokenMarketNet/ico/blob/master/crowdsales/example.yml
This file provides some good example on how to pass arguments and use your contract.
Would love to get some info on how do you use it
deploy-token --chain=ropsten --address=0x3c2d4e5eae8c4a31ccc56075b5fd81307b1627c6 --name="MikkoToken 2.0" --symbol=MOO --release-agent=0x3c2d4e5eae8c4a31ccc56075b5fd81307b1627c6 --supply=100000
Do we need to run geth before and sync all nodes? We always get exception connection refused ...
throw is deprecated; move to assert() and revert() in all contracts
When I try to run the release token example on my machine, it shows
ValueError: {'code': -32015, 'message': 'Transaction execution error.', 'data': 'Internal("Requires higher than upper limit of 1000000000000")'}
Then I review the issue #30 found that I need to set my address to releaseAgent, but when I call
contract.transact(transaction).setReleaseAgent(owner_address), it shows the same error
ValueError: {'code': -32015, 'message': 'Transaction execution error.', 'data': 'Internal("Requires higher than upper limit of 1000000000000")'}
So when I look back in smart contract code, seems there is no restrictions but onlyOwner
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
// We don't do interface check here as we might want to a normal wallet address to act as a release agent
releaseAgent = addr;
}
Since the address I own is the owner of the contract. So what should I do then?
https://github.com/rstormsf/ico/blob/b33ed2b4dc183023dec815f77bd4309a4dbd64d5/contracts/FlatPricing.sol#L31
calculatePrice
has unused params: uint weiRaised, uint tokensSold, address msgSender,
Here is where it's being used:
contracts/FlatPricing.sol
31: function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint) {
contracts/Crowdsale.sol
198: uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals());
contracts/EthTranchePricing.sol
151: function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint) {
contracts/MilestonePricing.sol
132: function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint) {
contracts/PricingStrategy.sol
47: function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
contracts/TokenTranchePricing.sol
139: function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint) {
ico/tests/contracts/test_deploy_acceptance.py
150: amount = pricing_strategy.call().calculatePrice(
180: amount = pricing_strategy.call().calculatePrice(
200: amount = pricing_strategy.call().calculatePrice(
ico/tests/contracts/test_eth_tranche_pricing.py
156: assert wei_tranche_pricing.call().calculatePrice(
164: assert wei_tranche_pricing.call().calculatePrice(
172: assert wei_tranche_pricing.call().calculatePrice(
180: assert wei_tranche_pricing.call().calculatePrice(
192: assert wei_tranche_pricing.call().calculatePrice(
200: assert wei_tranche_pricing.call().calculatePrice(
208: assert wei_tranche_pricing.call().calculatePrice(
216: assert wei_tranche_pricing.call().calculatePrice(
224: assert wei_tranche_pricing.call().calculatePrice(
237: assert wei_tranche_pricing.call().calculatePrice(
271: amount = wei_tranche_pricing.call().calculatePrice(
291: amount = wei_tranche_pricing.call().calculatePrice(
ico/tests/contracts/test_milestone_pricing.py
181: assert milestone_pricing.call().calculatePrice(
189: assert milestone_pricing.call().calculatePrice(
197: assert milestone_pricing.call().calculatePrice(
205: assert milestone_pricing.call().calculatePrice(
221: assert milestone_pricing.call().calculatePrice(
255: amount = milestone_pricing.call().calculatePrice(
277: amount = milestone_pricing.call().calculatePrice(
ico/tests/contracts/test_uncapped_flatprice.py
216: assert flat_pricing.call().calculatePrice(wei_value, 0, 0, customer, 0) > 0
ico/tests/contracts/test_token_tranche_pricing.py
154: assert tranche_pricing.call().calculatePrice(
162: assert tranche_pricing.call().calculatePrice(
170: assert tranche_pricing.call().calculatePrice(
178: assert tranche_pricing.call().calculatePrice(
190: assert tranche_pricing.call().calculatePrice(
198: assert tranche_pricing.call().calculatePrice(
206: assert tranche_pricing.call().calculatePrice(
214: assert tranche_pricing.call().calculatePrice(
222: assert tranche_pricing.call().calculatePrice(
235: assert tranche_pricing.call().calculatePrice(
269: amount = tranche_pricing.call().calculatePrice(
289: amount = tranche_pricing.call().calculatePrice(
just needs to be refactored.
Please give me 👍 so I can do a PR if you agree
I did pip3 install -r requirements.txt
but how do I get presale
CLI ?
Also ran python3 setup.py install
and checked venv/bin
folder it does have deploy-presale
binary, but the docs say to run presale
I assume it's the same
when I tried to use deploy-presale
, it gives me an error:
ModuleNotFoundError: No module named 'ico.cmd'
https://github.com/TokenMarketNet/ico/blob/master/contracts/CrowdsaleBase.sol#L250
I believe that the check that if the contract is finalizeAgent should be done first and only then to modify state variable
function setFinalizeAgent(FinalizeAgent addr) onlyOwner {
require(addr.isFinalizeAgent());
finalizeAgent = addr;
}
When i type
git clone # ...
it gives the following error
You must specify a repository to clone.
usage: git clone [] [--] [
]-v, --verbose be more verbose
-q, --quiet be more quiet
--progress force progress reporting
-n, --no-checkout don't create a checkout
--bare create a bare repository
--mirror create a mirror repository (implies bare)
-l, --local to clone from a local repository
--no-hardlinks don't use local hardlinks, always copy
-s, --shared setup as shared repository
--recursive initialize submodules in the clone
--recurse-submodules initialize submodules in the clone
--template <template-directory>
directory from which templates will be used
--reference <repo> reference repository
--dissociate use --reference only while cloning
-o, --origin <name> use <name> instead of 'origin' to track upstream
-b, --branch <branch>
checkout <branch> instead of the remote's HEAD
-u, --upload-pack <path>
path to git-upload-pack on the remote
--depth <depth> create a shallow clone of that depth
--single-branch clone only one branch, HEAD or --branch
--separate-git-dir <gitdir>
separate git dir from working tree
-c, --config <key=value>
set config inside the new repository
What am I missing???
For example, UncappedCrowdsale.sol flat file looks like:
// Temporarily have SafeMath here until all contracts have been migrated to SafeMathLib version from OpenZeppelin
pragma solidity ^0.4.11;
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) constant returns (uint256);
function transfer(address to, uint256 value) returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* Safe unsigned safe math.
*
* https://blog.aragon.one/library-driven-development-in-solidity-2bebcaf88736#.750gwtwli
*
* Originally from https://raw.githubusercontent.com/AragonOne/zeppelin-solidity/master/contracts/SafeMathLib.sol
*
* Maintained here until merged to mainline zeppelin-solidity.
*
*/
library SafeMathLib {
function times(uint a, uint b) returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function minus(uint a, uint b) returns (uint) {
assert(b <= a);
return a - b;
}
function plus(uint a, uint b) returns (uint) {
uint c = a + b;
assert(c>=a);
return c;
}
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/*
* Haltable
*
* Abstract contract that allows children to implement an
* emergency stop mechanism. Differs from Pausable by causing a throw when in halt mode.
*
*
* Originally envisioned in FirstBlood ICO contract.
*/
contract Haltable is Ownable {
bool public halted;
modifier stopInEmergency {
if (halted) throw;
_;
}
modifier onlyInEmergency {
if (!halted) throw;
_;
}
// called by the owner on emergency, triggers stopped state
function halt() external onlyOwner {
halted = true;
}
// called by the owner on end of emergency, returns to normal state
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* Interface for defining crowdsale pricing.
*/
contract PricingStrategy {
/** Interface declaration. */
function isPricingStrategy() public constant returns (bool) {
return true;
}
/** Self check if all references are correctly set.
*
* Checks that pricing strategy matches crowdsale parameters.
*/
function isSane(address crowdsale) public constant returns (bool) {
return true;
}
/**
* @dev Pricing tells if this is a presale purchase or not.
@param purchaser Address of the purchaser
@return False by default, true if a presale purchaser
*/
function isPresalePurchase(address purchaser) public constant returns (bool) {
return false;
}
/**
* When somebody tries to buy tokens for X eth, calculate how many tokens they get.
*
*
* @param value - What is the value of the transaction send in as wei
* @param tokensSold - how much tokens have been sold this far
* @param weiRaised - how much money has been raised this far in the main token sale - this number excludes presale
* @param msgSender - who is the investor of this transaction
* @param decimals - how many decimal units the token has
* @return Amount of tokens the investor receives
*/
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* Finalize agent defines what happens at the end of succeseful crowdsale.
*
* - Allocate tokens for founders, bounties and community
* - Make tokens transferable
* - etc.
*/
contract FinalizeAgent {
function isFinalizeAgent() public constant returns(bool) {
return true;
}
/** Return true if we can run finalizeCrowdsale() properly.
*
* This is a safety check function that doesn't allow crowdsale to begin
* unless the finalizer has been set up properly.
*/
function isSane() public constant returns (bool);
/** Called once by crowdsale finalize() if the sale was success. */
function finalizeCrowdsale();
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) constant returns (uint256);
function transferFrom(address from, address to, uint256 value) returns (bool);
function approve(address spender, uint256 value) returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* A token that defines fractional units as decimals.
*/
contract FractionalERC20 is ERC20 {
uint public decimals;
}
/**
* Abstract base contract for token sales.
*
* Handle
* - start and end dates
* - accepting investments
* - minimum funding goal and refund
* - various statistics during the crowdfund
* - different pricing strategies
* - different investment policies (require server side customer id, allow only whitelisted addresses)
*
*/
contract Crowdsale is Haltable {
/* Max investment count when we are still allowed to change the multisig address */
uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5;
using SafeMathLib for uint;
/* The token we are selling */
FractionalERC20 public token;
/* How we are going to price our offering */
PricingStrategy public pricingStrategy;
/* Post-success callback */
FinalizeAgent public finalizeAgent;
/* tokens will be transfered from this address */
address public multisigWallet;
/* if the funding goal is not reached, investors may withdraw their funds */
uint public minimumFundingGoal;
/* the UNIX timestamp start date of the crowdsale */
uint public startsAt;
/* the UNIX timestamp end date of the crowdsale */
uint public endsAt;
/* the number of tokens already sold through this contract*/
uint public tokensSold = 0;
/* How many wei of funding we have raised */
uint public weiRaised = 0;
/* Calculate incoming funds from presale contracts and addresses */
uint public presaleWeiRaised = 0;
/* How many distinct addresses have invested */
uint public investorCount = 0;
/* How much wei we have returned back to the contract after a failed crowdfund. */
uint public loadedRefund = 0;
/* How much wei we have given back to investors.*/
uint public weiRefunded = 0;
/* Has this crowdsale been finalized */
bool public finalized;
/* Do we need to have unique contributor id for each customer */
bool public requireCustomerId;
/**
* Do we verify that contributor has been cleared on the server side (accredited investors only).
* This method was first used in FirstBlood crowdsale to ensure all contributors have accepted terms on sale (on the web).
*/
bool public requiredSignedAddress;
/* Server side address that signed allowed contributors (Ethereum addresses) that can participate the crowdsale */
address public signerAddress;
/** How much ETH each address has invested to this crowdsale */
mapping (address => uint256) public investedAmountOf;
/** How much tokens this crowdsale has credited for each investor address */
mapping (address => uint256) public tokenAmountOf;
/** Addresses that are allowed to invest even before ICO offical opens. For testing, for ICO partners, etc. */
mapping (address => bool) public earlyParticipantWhitelist;
/** This is for manul testing for the interaction from owner wallet. You can set it to any value and inspect this in blockchain explorer to see that crowdsale interaction works. */
uint public ownerTestValue;
/** State machine
*
* - Preparing: All contract initialization calls and variables have not been set yet
* - Prefunding: We have not passed start time yet
* - Funding: Active crowdsale
* - Success: Minimum funding goal reached
* - Failure: Minimum funding goal not reached before ending time
* - Finalized: The finalized has been called and succesfully executed
* - Refunding: Refunds are loaded on the contract for reclaim.
*/
enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding}
// A new investment was made
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
// Refund was processed for a contributor
event Refund(address investor, uint weiAmount);
// The rules were changed what kind of investments we accept
event InvestmentPolicyChanged(bool newRequireCustomerId, bool newRequiredSignedAddress, address newSignerAddress);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
// Crowdsale end time has been changed
event EndsAtChanged(uint newEndsAt);
function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) {
owner = msg.sender;
token = FractionalERC20(_token);
setPricingStrategy(_pricingStrategy);
multisigWallet = _multisigWallet;
if(multisigWallet == 0) {
throw;
}
if(_start == 0) {
throw;
}
startsAt = _start;
if(_end == 0) {
throw;
}
endsAt = _end;
// Don't mess the dates
if(startsAt >= endsAt) {
throw;
}
// Minimum funding goal can be zero
minimumFundingGoal = _minimumFundingGoal;
}
/**
* Don't expect to just send in money and get tokens.
*/
function() payable {
throw;
}
/**
* Make an investment.
*
* Crowdsale must be running for one to invest.
* We must have not pressed the emergency brake.
*
* @param receiver The Ethereum address who receives the tokens
* @param customerId (optional) UUID v4 to track the successful payments on the server side
*
*/
function investInternal(address receiver, uint128 customerId) stopInEmergency private {
// Determine if it's a good time to accept investment from this participant
if(getState() == State.PreFunding) {
// Are we whitelisted for early deposit
if(!earlyParticipantWhitelist[receiver]) {
throw;
}
} else if(getState() == State.Funding) {
// Retail participants can only come in when the crowdsale is running
// pass
} else {
// Unwanted state
throw;
}
uint weiAmount = msg.value;
// Account presale sales separately, so that they do not count against pricing tranches
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals());
if(tokenAmount == 0) {
// Dust transaction
throw;
}
if(investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
// Update investor
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
// Update totals
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
if(pricingStrategy.isPresalePurchase(receiver)) {
presaleWeiRaised = presaleWeiRaised.plus(weiAmount);
}
// Check that we did not bust the cap
if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) {
throw;
}
assignTokens(receiver, tokenAmount);
// Pocket the money
if(!multisigWallet.send(weiAmount)) throw;
// Tell us invest was success
Invested(receiver, weiAmount, tokenAmount, customerId);
}
/**
* Preallocate tokens for the early investors.
*
* Preallocated tokens have been sold before the actual crowdsale opens.
* This function mints the tokens and moves the crowdsale needle.
*
* Investor count is not handled; it is assumed this goes for multiple investors
* and the token distribution happens outside the smart contract flow.
*
* No money is exchanged, as the crowdsale team already have received the payment.
*
* @param fullTokens tokens as full tokens - decimal places added internally
* @param weiPrice Price of a single full token in wei
*
*/
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = weiPrice * fullTokens; // This can be also 0, we give out tokens for free
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
assignTokens(receiver, tokenAmount);
// Tell us invest was success
Invested(receiver, weiAmount, tokenAmount, 0);
}
/**
* Allow anonymous contributions to this crowdsale.
*/
function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
bytes32 hash = sha256(addr);
if (ecrecover(hash, v, r, s) != signerAddress) throw;
if(customerId == 0) throw; // UUIDv4 sanity check
investInternal(addr, customerId);
}
/**
* Track who is the customer making the payment so we can send thank you email.
*/
function investWithCustomerId(address addr, uint128 customerId) public payable {
if(requiredSignedAddress) throw; // Crowdsale allows only server-side signed participants
if(customerId == 0) throw; // UUIDv4 sanity check
investInternal(addr, customerId);
}
/**
* Allow anonymous contributions to this crowdsale.
*/
function invest(address addr) public payable {
if(requireCustomerId) throw; // Crowdsale needs to track partipants for thank you email
if(requiredSignedAddress) throw; // Crowdsale allows only server-side signed participants
investInternal(addr, 0);
}
/**
* Invest to tokens, recognize the payer and clear his address.
*
*/
function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
investWithSignedAddress(msg.sender, customerId, v, r, s);
}
/**
* Invest to tokens, recognize the payer.
*
*/
function buyWithCustomerId(uint128 customerId) public payable {
investWithCustomerId(msg.sender, customerId);
}
/**
* The basic entry point to participate the crowdsale process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable {
invest(msg.sender);
}
/**
* Finalize a succcesful crowdsale.
*
* The owner can triggre a call the contract that provides post-crowdsale actions, like releasing the tokens.
*/
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
// Already finalized
if(finalized) {
throw;
}
// Finalizing is optional. We only call it if we are given a finalizing agent.
if(address(finalizeAgent) != 0) {
finalizeAgent.finalizeCrowdsale();
}
finalized = true;
}
/**
* Allow to (re)set finalize agent.
*
* Design choice: no state restrictions on setting this, so that we can fix fat finger mistakes.
*/
function setFinalizeAgent(FinalizeAgent addr) onlyOwner {
finalizeAgent = addr;
// Don't allow setting bad agent
if(!finalizeAgent.isFinalizeAgent()) {
throw;
}
}
/**
* Set policy do we need to have server-side customer ids for the investments.
*
*/
function setRequireCustomerId(bool value) onlyOwner {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
/**
* Set policy if all investors must be cleared on the server side first.
*
* This is e.g. for the accredited investor clearing.
*
*/
function setRequireSignedAddress(bool value, address _signerAddress) onlyOwner {
requiredSignedAddress = value;
signerAddress = _signerAddress;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
/**
* Allow addresses to do early participation.
*
* TODO: Fix spelling error in the name
*/
function setEarlyParicipantWhitelist(address addr, bool status) onlyOwner {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
/**
* Allow crowdsale owner to close early or extend the crowdsale.
*
* This is useful e.g. for a manual soft cap implementation:
* - after X amount is reached determine manual closing
*
* This may put the crowdsale to an invalid state,
* but we trust owners know what they are doing.
*
*/
function setEndsAt(uint time) onlyOwner {
if(now > time) {
throw; // Don't change past
}
endsAt = time;
EndsAtChanged(endsAt);
}
/**
* Allow to (re)set pricing strategy.
*
* Design choice: no state restrictions on the set, so that we can fix fat finger mistakes.
*/
function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner {
pricingStrategy = _pricingStrategy;
// Don't allow setting bad agent
if(!pricingStrategy.isPricingStrategy()) {
throw;
}
}
/**
* Allow to change the team multisig address in the case of emergency.
*
* This allows to save a deployed crowdsale wallet in the case the crowdsale has not yet begun
* (we have done only few test transactions). After the crowdsale is going
* then multisig address stays locked for the safety reasons.
*/
function setMultisig(address addr) public onlyOwner {
// Change
if(investorCount > MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE) {
throw;
}
multisigWallet = addr;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case the minimum goal was not reached..
*/
function loadRefund() public payable inState(State.Failure) {
if(msg.value == 0) throw;
loadedRefund = loadedRefund.plus(msg.value);
}
/**
* Investors can claim refund.
*
* Note that any refunds from proxy buyers should be handled separately,
* and not through this contract.
*/
function refund() public inState(State.Refunding) {
uint256 weiValue = investedAmountOf[msg.sender];
if (weiValue == 0) throw;
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.plus(weiValue);
Refund(msg.sender, weiValue);
if (!msg.sender.send(weiValue)) throw;
}
/**
* @return true if the crowdsale has raised enough money to be a successful.
*/
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
/**
* Check if the contract relationship looks good.
*/
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane();
}
/**
* Check if the contract relationship looks good.
*/
function isPricingSane() public constant returns (bool sane) {
return pricingStrategy.isSane(address(this));
}
/**
* Crowdfund state machine management.
*
* We make it a function and do not assign the result to a variable, so there is no chance of the variable being stale.
*/
function getState() public constant returns (State) {
if(finalized) return State.Finalized;
else if (address(finalizeAgent) == 0) return State.Preparing;
else if (!finalizeAgent.isSane()) return State.Preparing;
else if (!pricingStrategy.isSane(address(this))) return State.Preparing;
else if (block.timestamp < startsAt) return State.PreFunding;
else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
/** This is for manual testing of multisig wallet interaction */
function setOwnerTestValue(uint val) onlyOwner {
ownerTestValue = val;
}
/** Interface marker. */
function isCrowdsale() public constant returns (bool) {
return true;
}
//
// Modifiers
//
/** Modified allowing execution only if the crowdsale is currently running. */
modifier inState(State state) {
if(getState() != state) throw;
_;
}
//
// Abstract functions
//
/**
* Check if the current invested breaks our cap rules.
*
*
* The child contract must define their own cap setting rules.
* We allow a lot of flexibility through different capping strategies (ETH, token count)
* Called from invest().
*
* @param weiAmount The amount of wei the investor tries to invest in the current transaction
* @param tokenAmount The amount of tokens we try to give to the investor in the current transaction
* @param weiRaisedTotal What would be our total raised balance after this transaction
* @param tokensSoldTotal What would be our total sold tokens count after this transaction
*
* @return true if taking this investment would break our cap rules
*/
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken);
/**
* Check if the current crowdsale is full and we can no longer sell any tokens.
*/
function isCrowdsaleFull() public constant returns (bool);
/**
* Create new tokens or transfer issued tokens to the investor depending on the cap model.
*/
function assignTokens(address receiver, uint tokenAmount) private;
}
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/
/**
* Standard ERC20 token with Short Hand Attack and approve() race condition mitigation.
*
* Based on code by FirstBlood:
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, SafeMath {
/* Token supply got increased and a new owner received these tokens */
event Minted(address receiver, uint amount);
/* Actual balances of token holders */
mapping(address => uint) balances;
/* approve() allowances */
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
function transfer(address _to, uint _value) returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSub(balances[_from], _value);
allowed[_from][msg.sender] = safeSub(_allowance, _value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool success) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
/**
* A token that can increase its supply by another contract.
*
* This allows uncapped crowdsale by dynamically increasing the supply when money pours in.
* Only mint agents, contracts whitelisted by owner, can mint new tokens.
*
*/
contract MintableToken is StandardToken, Ownable {
using SafeMathLib for uint;
bool public mintingFinished = false;
/** List of agents that are allowed to create new tokens */
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state );
/**
* Create new tokens and allocate them to an address..
*
* Only callably by a crowdsale contract (mint agent).
*/
function mint(address receiver, uint amount) onlyMintAgent canMint public {
totalSupply = totalSupply.plus(amount);
balances[receiver] = balances[receiver].plus(amount);
// This will make the mint transaction apper in EtherScan.io
// We can remove this after there is a standardized minting event
Transfer(0, receiver, amount);
}
/**
* Owner can allow a crowdsale contract to mint new tokens.
*/
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
// Only crowdsale contracts are allowed to mint new tokens
if(!mintAgents[msg.sender]) {
throw;
}
_;
}
/** Make sure we are not done yet. */
modifier canMint() {
if(mintingFinished) throw;
_;
}
}
/**
* Uncapped ICO crowdsale contract.
*
*
* Intended usage
*
* - A short time window
* - Flat price
* - No cap
*
*/
contract UncappedCrowdsale is Crowdsale {
function UncappedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) {
}
/**
* Called from invest() to confirm if the curret investment does not break our cap rule.
*/
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) {
return false;
}
function isCrowdsaleFull() public constant returns (bool) {
// Uncle Scrooge
return false;
}
function assignTokens(address receiver, uint tokenAmount) private {
MintableToken mintableToken = MintableToken(token);
mintableToken.mint(receiver, tokenAmount);
}
}
If I copy this flat file Remix IDE or compile with solc of version >= 0.4.11, I get invalid bytecode:
60606040526004805460a060020a60ff02191690556006805460ff1916905534156200002757fe5b6040516200196f3803806200196f83398101604090815281516020830151918301516060840151608085015192850194939093019290915b335b5b60038054600160a060020a03191633600160a060020a03161790555b60088054600160a060020a031916600160a060020a0383161790555b5060038054600160a060020a03191633600160a060020a03161790558451620000cb90600b9060208801906200018c565b508351620000e190600c9060208701906200018c565b506000838155600d839055600354600160a060020a031681526001602052604081208490558311156200015a5760035460005460408051600160a060020a039093168352602083019190915280517f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe9281900390910190a15b8015156200017f576006805460ff1916600117905560005415156200017f5760006000fd5b5b5b505050505062000236565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001cf57805160ff1916838001178555620001ff565b82800160010185558215620001ff579182015b82811115620001ff578251825591602001919060010190620001e2565b5b506200020e92915062000212565b5090565b6200023391905b808211156200020e576000815560010162000219565b5090565b90565b61172980620002466000396000f300606060405236156101885763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302f652a3811461018a57806305d2035b146101ad57806306fdde03146101d1578063095ea7b31461026157806318160ddd1461029457806323b872dd146102b657806329ff4f53146102ef578063313ce5671461030d57806340c10f191461032f57806342c1867b14610350578063432146751461038057806345977d03146103a35780634eee966f146103b85780635de4ccb01461044d5780635f412d4f14610479578063600440cb1461048b57806370a08231146104b75780638444b391146104e5578063867c2857146105195780638da5cb5b1461054957806395d89b411461057557806396132521146106055780639738968c14610629578063a9059cbb1461064d578063c752ff6214610680578063d1f276d3146106a2578063d7e7088a146106ce578063dd62ed3e146106ec578063eefa597b14610720578063f2fde38b14610744578063ffeb7d7514610762575bfe5b341561019257fe5b6101ab600160a060020a03600435166024351515610780565b005b34156101b557fe5b6101bd6107e3565b604080519115158252519081900360200190f35b34156101d957fe5b6101e16107ec565b604080516020808252835181830152835191928392908301918501908083838215610227575b80518252602083111561022757601f199092019160209182019101610207565b505050905090810190601f1680156102535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026957fe5b6101bd600160a060020a036004351660243561087a565b604080519115158252519081900360200190f35b341561029c57fe5b6102a4610921565b60408051918252519081900360200190f35b34156102be57fe5b6101bd600160a060020a0360043581169060243516604435610927565b604080519115158252519081900360200190f35b34156102f757fe5b6101ab600160a060020a036004351661097f565b005b341561031557fe5b6102a46109e5565b60408051918252519081900360200190f35b341561033757fe5b6101ab600160a060020a03600435166024356109eb565b005b341561035857fe5b6101bd600160a060020a0360043516610bb1565b604080519115158252519081900360200190f35b341561038857fe5b6101ab600160a060020a03600435166024351515610bc6565b005b34156103ab57fe5b6101ab600435610c5a565b005b34156103c057fe5b6101ab600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375050604080516020601f89358b01803591820183900483028401830190945280835297999881019791965091820194509250829150840183828082843750949650610dca95505050505050565b005b341561045557fe5b61045d610f3e565b60408051600160a060020a039092168252519081900360200190f35b341561048157fe5b6101ab610f4d565b005b341561049357fe5b61045d610f82565b60408051600160a060020a039092168252519081900360200190f35b34156104bf57fe5b6102a4600160a060020a0360043516610f91565b60408051918252519081900360200190f35b34156104ed57fe5b6104f5610fb0565b6040518082600481111561050557fe5b60ff16815260200191505060405180910390f35b341561052157fe5b6101bd600160a060020a0360043516610ffd565b604080519115158252519081900360200190f35b341561055157fe5b61045d611012565b60408051600160a060020a039092168252519081900360200190f35b341561057d57fe5b6101e1611021565b604080516020808252835181830152835191928392908301918501908083838215610227575b80518252602083111561022757601f199092019160209182019101610207565b505050905090810190601f1680156102535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561060d57fe5b6101bd6110af565b604080519115158252519081900360200190f35b341561063157fe5b6101bd6110bf565b604080519115158252519081900360200190f35b341561065557fe5b6101bd600160a060020a03600435166024356110e5565b604080519115158252519081900360200190f35b341561068857fe5b6102a461113b565b60408051918252519081900360200190f35b34156106aa57fe5b61045d611141565b60408051600160a060020a039092168252519081900360200190f35b34156106d657fe5b6101ab600160a060020a0360043516611150565b005b34156106f457fe5b6102a4600160a060020a036004358116906024351661132d565b60408051918252519081900360200190f35b341561072857fe5b6101bd61135a565b604080519115158252519081900360200190f35b341561074c57fe5b6101ab600160a060020a0360043516611360565b005b341561076a57fe5b6101ab600160a060020a03600435166113bf565b005b60035433600160a060020a0390811691161461079c5760006000fd5b60045460009060a060020a900460ff16156107b75760006000fd5b600160a060020a0383166000908152600560205260409020805460ff19168315151790555b5b505b5050565b60065460ff1681565b600b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108725780601f1061084757610100808354040283529160200191610872565b820191906000526020600020905b81548152906001019060200180831161085557829003601f168201915b505050505081565b600081158015906108af5750600160a060020a0333811660009081526002602090815260408083209387168352929052205415155b156108ba5760006000fd5b600160a060020a03338116600081815260026020908152604080832094881680845294825291829020869055815186815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35060015b92915050565b60005481565b600454600090849060a060020a900460ff16151561096757600160a060020a03811660009081526005602052604090205460ff1615156109675760006000fd5b5b61097385858561141d565b91505b5b509392505050565b60035433600160a060020a0390811691161461099b5760006000fd5b60045460009060a060020a900460ff16156109b65760006000fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0384161790555b5b505b50565b600d5481565b600160a060020a03331660009081526007602052604090205460ff161515610a135760006000fd5b60065460ff1615610a245760006000fd5b60005473__:SafeMathLib__________________________6366098d4f9091836000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060206040518083038186803b1515610aa057fe5b6102c65a03f41515610aae57fe5b50506040805180516000908155600160a060020a038616815260016020908152838220549281019190915282517f66098d4f000000000000000000000000000000000000000000000000000000008152600481019290925260248201859052915173__:SafeMathLib__________________________93506366098d4f92604480840193919291829003018186803b1515610b4557fe5b6102c65a03f41515610b5357fe5b5050604080518051600160a060020a0386166000818152600160209081528582209390935586845293519094507fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35b5b5b5050565b60076020526000908152604090205460ff1681565b60035433600160a060020a03908116911614610be25760006000fd5b60065460ff1615610bf35760006000fd5b600160a060020a038216600081815260076020908152604091829020805460ff191685151590811790915582519384529083015280517f4b0adf6c802794c7dde28a08a4e07131abcff3bf9603cd71f14f90bec7865efa9281900390910190a15b5b5b5050565b6000610c64610fb0565b905060035b816004811115610c7557fe5b1480610c8d575060045b816004811115610c8b57fe5b145b1515610c995760006000fd5b811515610ca65760006000fd5b600160a060020a033316600090815260016020526040902054610cc99083611520565b600160a060020a03331660009081526001602052604081209190915554610cf09083611520565b600055600a54610d009083611537565b600a55600954604080517f753e88e5000000000000000000000000000000000000000000000000000000008152600160a060020a033381166004830152602482018690529151919092169163753e88e591604480830192600092919082900301818387803b1515610d6d57fe5b6102c65a03f11515610d7b57fe5b5050600954604080518581529051600160a060020a03928316935033909216917f7e5c344a8141a805725cb476f76c6953b842222b967edd1f78ddb6e8b3f397ac9181900360200190a35b5050565b60035433600160a060020a03908116911614610de65760006000fd5b8151610df990600b90602085019061165d565b508051610e0d90600c90602084019061165d565b5060408051818152600b8054600260001961010060018416150201909116049282018390527fd131ab1e6f279deea74e13a18477e13e2107deb6dc8ae955648948be5841fb46929091600c9181906020820190606083019086908015610eb45780601f10610e8957610100808354040283529160200191610eb4565b820191906000526020600020905b815481529060010190602001808311610e9757829003601f168201915b5050838103825284546002600019610100600184161502019091160480825260209091019085908015610f285780601f10610efd57610100808354040283529160200191610f28565b820191906000526020600020905b815481529060010190602001808311610f0b57829003601f168201915b505094505050505060405180910390a15b5b5050565b600954600160a060020a031681565b60045433600160a060020a03908116911614610f695760006000fd5b6006805460ff19166001179055610f7e61155f565b5b5b565b600854600160a060020a031681565b600160a060020a0381166000908152600160205260409020545b919050565b6000610fba6110bf565b1515610fc857506001610ff7565b600954600160a060020a03161515610fe257506002610ff7565b600a541515610ff357506003610ff7565b5060045b5b5b5b90565b60056020526000908152604090205460ff1681565b600354600160a060020a031681565b600c805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108725780601f1061084757610100808354040283529160200191610872565b820191906000526020600020905b81548152906001019060200180831161085557829003601f168201915b505050505081565b60045460a060020a900460ff1681565b60045460009060a060020a900460ff1680156110de57506110de61135a565b5b90505b90565b600454600090339060a060020a900460ff16151561112557600160a060020a03811660009081526005602052604090205460ff1615156111255760006000fd5b5b61113084846115a9565b91505b5b5092915050565b600a5481565b600454600160a060020a031681565b6111586110bf565b15156111645760006000fd5b600160a060020a038116151561117a5760006000fd5b60085433600160a060020a039081169116146111965760006000fd5b60045b6111a1610fb0565b60048111156111ac57fe5b14156111b85760006000fd5b6009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911791829055604080516000602091820181905282517f61d3d7a6000000000000000000000000000000000000000000000000000000008152925194909316936361d3d7a6936004808501948390030190829087803b151561123e57fe5b6102c65a03f1151561124c57fe5b505060405151151590506112605760006000fd5b6000805460095460408051602090810185905281517f4b2ba0dd00000000000000000000000000000000000000000000000000000000815291519394600160a060020a0390931693634b2ba0dd936004808501948390030190829087803b15156112c657fe5b6102c65a03f115156112d457fe5b5050604051519190911490506112ea5760006000fd5b60095460408051600160a060020a039092168252517f7845d5aa74cc410e35571258d954f23b82276e160fe8c188fa80566580f279cc9181900360200190a15b50565b600160a060020a038083166000908152600260209081526040808320938516835292905220545b92915050565b60015b90565b60035433600160a060020a0390811691161461137c5760006000fd5b600160a060020a03811615156113925760006000fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b50565b600160a060020a03811615156113d55760006000fd5b60085433600160a060020a039081169116146113f15760006000fd5b6008805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600160a060020a03808416600090815260026020908152604080832033851684528252808320549386168352600190915281205490919061145e9084611537565b600160a060020a03808616600090815260016020526040808220939093559087168152205461148d9084611520565b600160a060020a0386166000908152600160205260409020556114b08184611520565b600160a060020a038087166000818152600260209081526040808320338616845282529182902094909455805187815290519288169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3600191505b509392505050565b60008282111561152c57fe5b508082035b92915050565b600082820183811080159061154c5750828110155b151561155457fe5b8091505b5092915050565b60045433600160a060020a0390811691161461157b5760006000fd5b6004805474ff0000000000000000000000000000000000000000191660a060020a1790555b5b565b60015b90565b600160a060020a0333166000908152600160205260408120546115cc9083611520565b600160a060020a0333811660009081526001602052604080822093909355908516815220546115fb9083611537565b600160a060020a038085166000818152600160209081526040918290209490945580518681529051919333909316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060015b92915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061169e57805160ff19168380011785556116cb565b828001600101855582156116cb579182015b828111156116cb5782518255916020019190600101906116b0565b5b506116d89291506116dc565b5090565b610ff791905b808211156116d857600081556001016116e2565b5090565b905600a165627a7a72305820bf5dac13fc6231d9a4b040c61823eb5df3ad186ae25e108a4ea8918191de48610029
with __:SafeMathLib__________________________
insertions.
What is the reason? How to compile correctly?
New solidity compiler gives an error for
https://github.com/TokenMarketNet/ico/blob/master/contracts/FlatPricing.sol#L23
: Documented parameter "{uint"
It's just reference for tomorrow's PR that I'm going to provide.
Hi there!
This error raise when using deploy-contracts with example.yml. I already add missing arguments to token contract but I can't understand how to fix this error.
Full exception message below:
Starting MilestonePricing deployment, with arguments {'_preicoPrice': 8000000000000000, '_milestones': [1500739200, 10000000000000000, 1501171200, 11000000000000000, 1501603200, 12000000000000000, 1503676800, 13000000000000000], '_preicoContractAddress': '0x9756c1836c09a25efc639588cab032b452e8f5fb'}
Traceback (most recent call last):
File "/SafeRoot/ico/ico/deploy.py", line 64, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "~/virtualenv/lib/python3.5/site-packages/populus/contracts/provider.py", line 154, in deploy_contract
kwargs=deploy_kwargs,
File "~/virtualenv/lib/python3.5/site-packages/web3/contract.py", line 295, in deploy
deploy_transaction['data'] = cls._encode_constructor_data(args, kwargs)
File "~/virtualenv/lib/python3.5/site-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "~/virtualenv/lib/python3.5/site-packages/web3/contract.py", line 732, in _encode_constructor_data
arguments = merge_args_and_kwargs(constructor_abi, args, kwargs)
File "~/virtualenv/lib/python3.5/site-packages/eth_utils/string.py", line 71, in inner
return fn(*text_args, **text_kwargs)
File "~/virtualenv/lib/python3.5/site-packages/web3/utils/abi.py", line 152, in merge_args_and_kwargs
len(args) + len(kwargs),
TypeError: Incorrect argument count. Expected '1'. Got '3'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "~/virtualenv/bin/deploy-contracts", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "~/virtualenv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "~/virtualenv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "~/virtualenv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "~/virtualenv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/SafeRoot/ico/ico/cmd/deploycontracts.py", line 22, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/SafeRoot/ico/ico/deploy.py", line 263, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/SafeRoot/ico/ico/deploy.py", line 247, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
File "/SafeRoot/ico/ico/deploy.py", line 130, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/SafeRoot/ico/ico/deploy.py", line 66, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract MilestonePricing, constructor arguments {'_preicoPrice': 8000000000000000, '_milestones': [1500739200, 10000000000000000, 1501171200, 11000000000000000, 1501603200, 12000000000000000, 1503676800, 13000000000000000], '_preicoContractAddress': '0x9756c1836c09a25efc639588cab032b452e8f5fb'}```
https://github.com/TokenMarketNet/ico/blob/master/crowdsales/example.yml#L75
Seems like there are 2 more that have to be added:
_decimals,
_mintable
I hava a question about the CrowdsaleToken contract as folowing:
Assume I deploy the CrowdsaleToken(.sol) and lock the Token transfering that inherit the ReleasableToken(.sol).
Although the function::transfer()/transferFrom() in ReleasableToken is protected by modifier::canTransfer(), but the same ones from StandardToken that inherit from MintableToken is external and looks un-protected.
is possible called by any external approaches to StandardToken::transfer()/transferFrom() ?
- contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken {
...
function transfer() canTransfer ...
function transferFrom() canTransfer ...
}
- contract MintableToken is StandardToken, Ownable { ... }
- contract StandardToken is ERC20, SafeMath {
...
function transfer() ... //external without protection? or set to internal?
function transferFrom() ... //the same above
}
Is there a way to specify my geth ipc endpoint?
I get an ipc timeout (60 seconds) after running deploy-token --chain ropsten
My ropsten blockchain (consequently the geth.ipc file) is running in another directory
Thank you
Make it possible to withdraw presale money to a multisig wallet in the case of an emergency.
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/SafeMath.sol - already provides it. No need to have your own.
If you agree, I can open a PR.
hi, thanks for creating such good materials. I now can fully understand how ico actually works.
we run your deploy script successfully (with --address=$address1 [1]) but unable to run finalize stage (script[2]) because:
btw If I removed onlyOwner modifier[4], it works for me without any problem.
Would you kindly guide me how to solve it? thanks
[1] https://github.com/TokenMarketNet/ico/blob/master/ico/cmd/deploycontracts.py
[2] https://gist.github.com/hsinhoyeh/d2336d450f221ccf8e942540f8ccdc66
[3] https://github.com/TokenMarketNet/ico/blob/master/crowdsales/example.yml#L158
[4] https://github.com/TokenMarketNet/ico/blob/master/contracts/Crowdsale.sol#L326
Make a PaymentForwarder option to do a checksum check for customerIds.
A valid customerId can be generated on Python side
PaymentForwarder checks this and rejects the transaction in the case of an invalid payment
Line 23 points to an unexisting function parameter which cause some compilers to report an error. here it is
@param {uint amount} Buy-in value in wei.
Compiler reports an error 'Documented parameter “{uint” not found in the parameter list of the function'
Used standard example.yml with switched off verification of contract
mymaps@mymaps-ThinkPad-E550:~/Desktop/ico$ deploy-contracts --deployment-name testnet --deployment-file crowdsales/example.yml --address 0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9
Web3 provider is RPC connection http://127.0.0.1:8545
Owner address is 0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9
Owner balance is 0.752808516 ETH
Starting Wallet deployment, with arguments {'_daylimit': 0, '_required': 2, '_owners': ['0x0044Eb0651586dF0176B682c71C6B81Fa56Df54B', '0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9']}
Wallet address is 0xf679335b842330e5d1410c5201c2ed1b3284a1ca
Wallet constructor arguments payload is 0x00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000044eb0651586df0176b682c71c6b81fa56df54b0000000000000000000000000085f718c11e5fcaf7b25eadccbcd7144823a6a9
Wallet libraries are {}
Starting PresaleFundCollector deployment, with arguments {'_weiMinimumLimit': 750000000000000000000, '_owner': '0xf679335b842330e5d1410c5201c2ed1b3284a1ca', '_freezeEndsAt': 1503429100}
PresaleFundCollector address is 0x4cd0399f08e8b74112159822af0702a798c89bb2
PresaleFundCollector constructor arguments payload is 0x000000000000000000000000f679335b842330e5d1410c5201c2ed1b3284a1ca00000000000000000000000000000000000000000000000000000000599c81ec000000000000000000000000000000000000000000000028a857425466f80000
PresaleFundCollector libraries are {'SafeMathLib': '0x49e4b40c5e4ffba1f6ecffa23c3c4efa7f2ab25f'}
Starting CrowdsaleToken deployment, with arguments {'_initialSupply': 0, '_name': 'Example-testnet', '_symbol': 'EXA'}
Traceback (most recent call last):
File "/home/mymaps/Desktop/ico/ico/deploy.py", line 63, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 154, in deploy_contract
kwargs=deploy_kwargs,
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 295, in deploy
deploy_transaction['data'] = cls._encode_constructor_data(args, kwargs)
File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 732, in _encode_constructor_data
arguments = merge_args_and_kwargs(constructor_abi, args, kwargs)
File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 71, in inner
return fn(*text_args, **text_kwargs)
File "/usr/local/lib/python3.5/dist-packages/web3/utils/abi.py", line 152, in merge_args_and_kwargs
len(args) + len(kwargs),
TypeError: Incorrect argument count. Expected '5'. Got '3'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/deploy-contracts", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 87, in augment_usage_errors
yield
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/mymaps/Desktop/ico/ico/cmd/deploycontracts.py", line 22, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/home/mymaps/Desktop/ico/ico/deploy.py", line 258, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/home/mymaps/Desktop/ico/ico/deploy.py", line 242, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
File "/home/mymaps/Desktop/ico/ico/deploy.py", line 129, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/home/mymaps/Desktop/ico/ico/deploy.py", line 65, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract CrowdsaleToken, constructor arguments {'_initialSupply': 0, '_name': 'Example-testnet', '_symbol': 'EXA'}
As an investor, I'd like to buy tokens using contact address which is fallback function.
I see this pattern is used quite extensively in your contracts with 1 caution: all those contracts have to throw an exception in fallback.
function isCrowdsale() public constant returns (bool) {
return true;
}
If I unlock the fallback function and provide some default behaviour, then it would break those checks because of strange behaviour by design in solidity, if a method does not exist it will instead execute the fallback function, and if the fallback function does not raise an exception it will return 1 causing the check to pass.. I guess what could be done instead is using some kind of magic constant, e.g.
contract Crowdsale {
uint256 public constant CROWDSALE_MAGIC = 0x1234;
}
contract Token {
address crowdsale;
function doSomething(address _a) {
require(Crowdsale(_a).CROWDSALE_MAGIC() == 0x1234);
crowdsale = _a;
}
what do you think?
Hi, im trying to test launch a token to the testnet and Ive followed all the steps in the documentation and I get errors:
Im using Python 3.5.3 on Ubuntu 14.04
Command:
deploy-token --chain=ropsten --address=0x3e66d224fc63B57327Bb6aFE885c39EC85F86bd3 --name="testtoken" --symbol=t5000 --release-agent=0x3e66d224fc63B57327Bb6aFE885c39EC85F86bd3 --supply=100000
Error:
Traceback (most recent call last):
File "/usr/local/bin/deploy-token", line 9, in
load_entry_point('ico', 'console_scripts', 'deploy-token')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 2569, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 2229, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 2235, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
ImportError: No module named ico.cmd.deploytoken
Any help is appreciated. Thanks.
After successfully deploying a crowdsale on ropsten testnet using a modified allocated-token-sale-example.yml, when trying to interact with the contracts via the jupyter notebook afterwards, the getattr calls to chain all fail with AtrributeError: 'ExternalChain' object has no attribute '(calledattribute)'.
The geth RPC connection is online, account unlock call works, Python version is 3.5.4.
Any ideas?
Web3 provider is RPC connection http://127.0.0.1:8545
Deployer address is 0x9da61758eb87d3b71672bd95465c4ca67b806c1c
Deployer balance is 99.999999999996321721 ETH
Starting contract deployment
Contract address is 0x389cec0b5e2cb40eaaf24a8afe1cb667c05ad4e3
CrowdsaleToken constructor arguments is 0000000000000000000000009da61758eb87d3b71672bd95465c4ca67b806c1c00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4765766f726b20322e300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034745560000000000000000000000000000000000000000000000000000000000
Setting release agent to 0x94d8ccc0a2ab1b92925ac0ba8af46729e5a25105
Traceback (most recent call last):
File "/usr/local/bin/deploy-token", line 11, in
load_entry_point('ico', 'console_scripts', 'deploy-token')()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/mymaps/Desktop/ico/ico/cmd/deploytoken.py", line 84, in main
txid = contract.transact(transaction).setReleaseAgent(release_agent)
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 806, in transact_with_contract_function
transaction=transaction,
File "/usr/local/lib/python3.5/dist-packages/web3/utils/decorators.py", line 12, in _wrapper
return self.method(obj, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 678, in _prepare_transaction
fn_kwargs,
File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 717, in _encode_transaction_data
fn_name, args, kwargs,
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 646, in _get_function_info
fn_abi = cls._find_matching_fn_abi(fn_name, args, kwargs)
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 610, in _find_matching_fn_abi
raise ValueError("No matching functions found")
ValueError: No matching functions found
Where would one begin to start using these contracts. Is it just a read the code figure it out type of thing or do some tutorials or walkthroughs exist ?
https://github.com/TokenMarketNet/ico/blob/master/contracts/PricingStrategy.sol
the contract is being used as an interface.
In Solidity, there is keyword: interface
which must be used instead of contract
Also, it shouldn't have any state variables and any implementations of any methods.
Probably more accurate comment would be either:
using interface
or abstract contract
Abstract contract can't also have any implementations.
So in your case it's not either an interface nor contract.
So please choose how you want it to behave.
https://solidity.readthedocs.io/en/develop/contracts.html#abstract-contracts
Interfaces
Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions:
Cannot inherit other contracts or interfaces.
Cannot define constructor.
Cannot define variables.
Cannot define structs.
Cannot define enums.
Fix typing contracts, tests, documentation
Can we somehow set deadline and price, so how many new token you will get with 1 ETH?
fundingGoal = fundingGoalInEthers * 1 ether;
deadline = now + durationInMinutes * 1 minutes;
price = etherCostOfEachToken * 1 ether;
When I try to deploy particular contract I get
deploy-token --chain=mainnet --address=0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9 --contract-name=AllocatedCrowdsale --name=Xtoken --symbol=XXY --supply=1000000 --decimals=8 --verify --release-agent=0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9
Web3 provider is RPC connection http://127.0.0.1:8545
Deployer address is 0x0085f718c11E5fCaF7B25eAdCCBcD7144823a6A9
Deployer balance is 0.561346092 ETH
Starting contract deployment
Traceback (most recent call last):
File "/usr/local/bin/deploy-token", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-token')()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/mymaps/Desktop/ico/ico/cmd/deploytoken.py", line 73, in main
contract, txhash = c.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_args=args)
File "/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py", line 154, in deploy_contract
kwargs=deploy_kwargs,
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 295, in deploy
deploy_transaction['data'] = cls._encode_constructor_data(args, kwargs)
File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 732, in _encode_constructor_data
arguments = merge_args_and_kwargs(constructor_abi, args, kwargs)
File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 71, in inner
return fn(*text_args, **text_kwargs)
File "/usr/local/lib/python3.5/dist-packages/web3/utils/abi.py", line 152, in merge_args_and_kwargs
len(args) + len(kwargs),
TypeError: Incorrect argument count. Expected '7'. Got '4'
When doing bonus minting, make sure we never exceed the max cap due to rounding errors.
Otherwise supply of 100,000,000 might end up looking like 100,002,000
Also do not undercut the cap.
If you hit with 99,9% within the cap range then add the few remaining missing tokens, so that the total supply will look a nice round number.
Problem: According to the investInternal
method, we're calling PricingStrategy.calculatePrice
with first argument as amount sent by wallet in Wei and last argument as number of decimals for a token which is usually 18.
These two amounts are then multiplied again in the actual calculatePrice
methods.
Fix: It seems like calculatePrice
expects ether value that it can multiply by amount of decimals and divide by the price per token in Wei. Currently, it takes Wei value, multiplies it by decimals (i.e. 10^18), and divides it by price per token in Wei -- we're still left with 18 extra zeros.
If this is correct, then we need to fix the example YAML that lists price in Wei as well.
http://ico.readthedocs.io/en/latest/install.html#setting-up-ubuntu-linux-16-04
git clone # ...
cd Smart-Contracts
python3.5 -m venv venv
source venv/bin/activate
pip install wheel
pip install -r requirements.txt
pip install -e .
What do you mean with git cloine # ... which git repository?
https://github.com/TokenMarketNet/ico/blob/master/contracts/Crowdsale.sol#L179
Modern compilers now check if the function receives msg.value
it should be payable
Looks like this
pricing_strategy:
contract_name: MilestonePricing
contract_file: MilestonePricing.sol
arguments:
_preicoPrice: "{{ to_wei('0.008', 'ether') }}"
_preicoContractAddress: "{{contracts.preico.address}}"
_milestones:
- 1492272000
- "{{ to_wei('0.010', 'ether') }}"
- 1492876800
- "{{ to_wei('0.011', 'ether') }}"
- 1493481600
- "{{ to_wei('0.012', 'ether') }}"
- 1494691200
- "{{ to_wei('0.013', 'ether') }}"
causes this
tarting MilestonePricing deployment, with arguments {'_milestones': [1492272000, 10000000000000000, 1492876800, 11000000000000000, 1493481600, 12000000000000000, 1494691200, 13000000000000000], '_preicoContractAddress': '0xdbf49e6f5b5408356d03eac2c04dde3e69ee52c0', '_preicoPrice': 8000000000000000}
Traceback (most recent call last):
File "/home/sergey/PycharmProjects/ico/ico/deploy.py", line 66, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/populus/contracts/provider.py", line 121, in deploy_contract
kwargs=deploy_kwargs,
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/web3/contract.py", line 307, in deploy
deploy_transaction['data'] = cls._encode_constructor_data(args, kwargs)
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/web3/contract.py", line 745, in _encode_constructor_data
arguments = merge_args_and_kwargs(constructor_abi, args, kwargs)
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/eth_utils/string.py", line 71, in inner
return fn(*text_args, **text_kwargs)
File "/home/sergey/.virtualenvs/ico/lib/python3.5/site-packages/web3/utils/abi.py", line 166, in merge_args_and_kwargs
len(args) + len(kwargs),
TypeError: Incorrect argument count. Expected '1'. Got '3'
because MilestonePricing
contract's constructor has only one paremeter: _milestones
. Changed in 2745fa7
My question is then where can I configure _preicoContractAddress
and _preicoPrice
.
Hi,
My deploy-contracts command was failing with this below error:
(venv) ~/project/ico$ deploy-contracts --deployment-file=crowdsales/example.yml --deployment-name=testnet --address=0x5b2d743afb621e890b5fb4b21af70ea62da179d9
Web3 provider is RPC connection http://127.0.0.1:8545
Owner address is 0x5b2d743afb621e890b5fb4b21af70ea62da179d9
Owner balance is 99.941464624 ETH
Starting Wallet deployment, with arguments {'_owners': ['0x5b2d743afb621e890b5fb4b21af70ea62da179d9', '0x523e5f737c972872aa8ed0c9f1479f367cda10c3'], '_required': 2, '_daylimit': 0}
Traceback (most recent call last):
File "/Users/saung/project/eth/ico/ico/deploy.py", line 64, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/populus/contracts/provider.py", line 150, in deploy_contract
ContractFactory = self.get_contract_factory(contract_identifier)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/populus/contracts/provider.py", line 237, in get_contract_factory
BaseContractFactory = self.get_base_contract_factory(contract_identifier)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/populus/contracts/provider.py", line 189, in get_base_contract_factory
return get_base_contract_factory(contract_identifier, self.provider_backends)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/populus/contracts/provider.py", line 38, in get_base_contract_factory
"from any of the configured backends".format(contract_identifier)
populus.contracts.exceptions.UnknownContract: No contract data was available for the contract identifier 'Wallet' from any of the configured backends
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 247, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
File "/Users/saung/project/eth/ico/ico/deploy.py", line 130, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/Users/saung/project/eth/ico/ico/deploy.py", line 66, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract Wallet, constructor arguments {'_owners': ['0x5b2d743afb621e890b5fb4b21af70ea62da179d9', '0x523e5f737c972872aa8ed0c9f1479f367cda10c3'], '_required': 2, '_daylimit': 0}
(venv) ~/project/ico$
Is it true that deploy-contracts must run first before deploy-presale step?
Then, I tried to change the example.yml to:
team_multisig:
contract_name: Wallet
contract_file: Wallet.sol
team_multisig:
contract_name: MultiSigWallet
contract_file: GnosisWallet.sol
Now, it gave me different error:
(venv) ~/project/ico$ deploy-contracts --deployment-file=crowdsales/example.yml --deployment-name=testnet --address=0x5b2d743afb621e890b5fb4b21af70ea62da179d9
Web3 provider is RPC connection http://127.0.0.1:8545
Owner address is 0x5b2d743afb621e890b5fb4b21af70ea62da179d9
Owner balance is 99.941464624 ETH
Starting MultiSigWallet deployment, with arguments {'_owners': ['0x5b2d743afb621e890b5fb4b21af70ea62da179d9', '0x523e5f737c972872aa8ed0c9f1479f367cda10c3'], '_required': 2, '_daylimit': 0}
Traceback (most recent call last):
File "/Users/saung/project/eth/ico/ico/deploy.py", line 64, in deploy_contract
contract, txhash = chain.provider.deploy_contract(contract_name, deploy_transaction=transaction, deploy_kwargs=kwargs)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/populus/contracts/provider.py", line 154, in deploy_contract
kwargs=deploy_kwargs,
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/contract.py", line 295, in deploy
deploy_transaction['data'] = cls._encode_constructor_data(args, kwargs)
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/contract.py", line 732, in _encode_constructor_data
arguments = merge_args_and_kwargs(constructor_abi, args, kwargs)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/eth_utils/string.py", line 71, in inner
return fn(*text_args, **text_kwargs)
File "/Users/saung/project/eth/ico/venv/lib/python3.6/site-packages/web3/utils/abi.py", line 152, in merge_args_and_kwargs
len(args) + len(kwargs),
TypeError: Incorrect argument count. Expected '2'. Got '3'
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 247, in _deploy_contracts
runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
File "/Users/saung/project/eth/ico/ico/deploy.py", line 130, in deploy_crowdsale
contracts[name] = deploy_contract(project, chain, deploy_address, expanded_contract_def, chain_name, need_unlock=need_unlock)
File "/Users/saung/project/eth/ico/ico/deploy.py", line 66, in deploy_contract
raise RuntimeError("Could not deploy contract {}, constructor arguments {}".format(contract_name, kwargs)) from e
RuntimeError: Could not deploy contract MultiSigWallet, constructor arguments {'_owners': ['0x5b2d743afb621e890b5fb4b21af70ea62da179d9', '0x523e5f737c972872aa8ed0c9f1479f367cda10c3'], '_required': 2, '_daylimit': 0}
It looks like format in the example.yml doesn't match with the actual contract.
Thanking you in advance.
-Sithu
MacOS Sierra 10.12.6
Parity 1.7
Kovan chain
I try to test your examples from docs. Firstly, deploy-token script.
http://localhost:8545
kovan
chain with connection to this JSON RPC url to populus.json.deploy-token --chain=kovan --contract-name="CentrallyIssuedToken" --address=0x005364854d51A0A12cb3cb9A402ef8b30702a565 --name="TestToken" --symbol=MOO --supply=916 --decimals=0 --verify --verify-filename=CentrallyIssuedToken.sol
The output in console is:
Web3 provider is RPC connection http://localhost:8545
Deployer address is 0x005364854d51A0A12cb3cb9A402ef8b30702a565
Deployer balance is 0.996728632 ETH
Traceback (most recent call last):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1198, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py", line 576, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 389, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 309, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=8545): Read timed out. (read timeout=10)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/bin/deploy-token", line 11, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-token')()
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/ico/cmd/deploytoken.py", line 53, in main
if is_account_locked(web3, address):
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/populus/utils/accounts.py", line 15, in is_account_locked
web3.eth.sign(account, 'simple-test-data')
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/eth_utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/web3/eth.py", line 262, in sign
"eth_sign", [account, encode_hex(data)],
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/web3/providers/manager.py", line 27, in request_blocking
response_raw = self.provider.make_request(method, params)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/web3/providers/rpc.py", line 52, in make_request
**self.get_request_kwargs()
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/web3/utils/compat/compat_requests.py", line 21, in make_post_request
response = session.post(endpoint_uri, data=data, *args, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/Users/viktor/Documents/HintsProjects/Test/TokenMarketNet_ico/venv/lib/python3.5/site-packages/requests/adapters.py", line 521, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=8545): Read timed out. (read timeout=10)
Hello,
I am trying to connect to ropsten, any help in this direction appreciated.
I am using following command to connect
deploy-presale --chain ropsten --address=0x1b93a9de9B13D355D005167f89774DD98dbd7d3d --owner 0x1b93a9de9B13D355D005167f89774DD98dbd7d3d --days=-1 --minimum=0.001
I am timing out.
geth running with following arguments
geth --testnet --fast --nodiscover
and then I am attaching nodes as mentioned in
https://github.com/ethereum/ropsten
Is there anyway I can run tokenmarketico on privatenet?
Regards,
P
Hello all!
I tried to use this library but in Ropsten or Rinkeby test network I got exception due to gas limit for MintedTokenCappedCrowdsale
contract deploymeny like this
The GAS for this Txn exceeds the Avg GasLimit of 4,712,432 for the last 50 Blocks (this is real transaction from me)
I even tried local private net, but got 'None of the known addresses matched the expected bytecode`. Code didn't help me
Hi all,
I don't know if this is my fault or not, but I couldn't deploy the sample code. My first step was to setup everything according to this: https://ico.readthedocs.io/en/latest/install.html
Then, I started parity with this command: parity --chain=kovan
. I created an address, I also validated it on the main net, then I got some tokens on kovan.
After this, I tried to run the following command: deploy-contracts --deployment-file=crowdsales/allocated-token-sale-example.yml --deployment-name=kovan --address=0x00D75b582f6387dDb9fc0f7517350Ed7Ce6B50De
First I got the following error:
(venv) user-machine:ico user$ deploy-contracts --deployment-file=crowdsales/allocated-token-sale-example.yml --deployment-name=kovan --address=0x00D75b582f6387dDb9fc0f7517350Ed7Ce6B50De
Web3 provider is RPC connection http://127.0.0.1:8547
Owner address is 0x00D75b582f6387dDb9fc0f7517350Ed7Ce6B50De
Traceback (most recent call last):
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x1046c2780>: Failed to establish a new connection: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=8547): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1046c2780>: Failed to establish a new connection: [Errno 61] Connection refused',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/b/ico/venv/bin/deploy-contracts", line 9, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/user/b/ico/ico/cmd/deploycontracts.py", line 31, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/Users/user/b/ico/ico/deploy.py", line 288, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/Users/user/b/ico/ico/deploy.py", line 269, in _deploy_contracts
start_balance = from_wei(web3.eth.getBalance(address), "ether")
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/utils/functional.py", line 14, in inner
value = fn(*args, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/eth.py", line 123, in getBalance
formatters.input_block_identifier_formatter(block_identifier),
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/providers/manager.py", line 27, in request_blocking
response_raw = self.provider.make_request(method, params)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/providers/rpc.py", line 52, in make_request
**self.get_request_kwargs()
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/utils/compat/compat_requests.py", line 21, in make_post_request
response = session.post(endpoint_uri, data=data, *args, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8547): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1046c2780>: Failed to establish a new connection: [Errno 61] Connection refused',))
I figured out that this may be, because the port is wrong in populus, so I changed it in populus.json:60 from http://127.0.0.1:8547
to http://127.0.0.1:8546
.
It went through on that error, but I got a new one:
(venv) user-machine:ico user$ deploy-contracts --deployment-file=crowdsales/allocated-token-sale-example.yml --deployment-name=kovan --address=0x00D75b582f6387dDb9fc0f7517350Ed7Ce6B50De
Web3 provider is RPC connection http://127.0.0.1:8546
Owner address is 0x00D75b582f6387dDb9fc0f7517350Ed7Ce6B50De
Traceback (most recent call last):
File "/Users/user/b/ico/venv/bin/deploy-contracts", line 9, in <module>
load_entry_point('ico', 'console_scripts', 'deploy-contracts')()
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/user/b/ico/ico/cmd/deploycontracts.py", line 31, in main
deploy_crowdsale_from_file(project, deployment_file, deployment_name, address)
File "/Users/user/b/ico/ico/deploy.py", line 288, in deploy_crowdsale_from_file
return _deploy_contracts(project, chain, web3, yaml_filename, chain_data, deploy_address)
File "/Users/user/b/ico/ico/deploy.py", line 269, in _deploy_contracts
start_balance = from_wei(web3.eth.getBalance(address), "ether")
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/utils/functional.py", line 14, in inner
value = fn(*args, **kwargs)
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/eth.py", line 123, in getBalance
formatters.input_block_identifier_formatter(block_identifier),
File "/Users/user/b/ico/venv/lib/python3.5/site-packages/web3/providers/manager.py", line 30, in request_blocking
response = json.loads(force_text(response_raw))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Any ideas what did I miss or is this really a problem with the package?
FileNotFoundError Traceback (most recent call last)
in ()
29 with project.get_chain(chain_name) as chain:
30
---> 31 Contract = chain.get_contract_factory("CrowdsaleToken")
32 contract = Contract(address=contract_address)
33
/usr/local/lib/python3.5/dist-packages/populus/chain/base.py in get_contract_factory(self, contract_identifier, link_dependencies)
194 "Memory
contract backend prior to linking"
195 )
--> 196 return self.provider.get_contract_factory(contract_identifier)
197
198 def is_contract_available(self,
/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py in get_contract_factory(self, contract_identifier)
235 return self._factory_cache[contract_identifier]
236
--> 237 BaseContractFactory = self.get_base_contract_factory(contract_identifier)
238
239 bytecode = self._link_bytecode(BaseContractFactory.bytecode)
/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py in get_base_contract_factory(self, contract_identifier)
187 The bytecode
and bytecode_runtime
will be unlinked in this class.
188 """
--> 189 return get_base_contract_factory(contract_identifier, self.provider_backends)
190
191 def get_contract_data(self, contract_identifier):
/usr/local/lib/python3.5/dist-packages/populus/contracts/provider.py in get_base_contract_factory(contract_identifier, store_backends)
30 for _, backend in store_backends.items():
31 try:
---> 32 return backend.get_base_contract_factory(contract_identifier)
33 except UnknownContract:
34 pass
/usr/local/lib/python3.5/dist-packages/populus/contracts/backends/base.py in get_base_contract_factory(self, contract_name)
71 )
72
---> 73 contract_data = self.get_contract_data(contract_identifier)
74
75 base_contract_factory = construct_contract_factory(
/usr/local/lib/python3.5/dist-packages/populus/contracts/backends/base.py in get_contract_data(self, contract_name)
92 contract_identifier = self.get_contract_identifier(contract_name)
93 try:
---> 94 return self.get_all_contract_data()[contract_identifier]
95 except KeyError:
96 raise UnknownContract(
/usr/local/lib/python3.5/dist-packages/populus/contracts/backends/project.py in get_all_contract_data(self)
28 contract_name: contract_data
29 for contract_name, contract_data
---> 30 in self.chain.project.compiled_contract_data.items()
31 if is_project_contract(self.chain.project.contracts_source_dir, contract_data)
32 }
/usr/local/lib/python3.5/dist-packages/populus/project.py in compiled_contract_data(self)
243 _, self._cached_compiled_contracts = compile_project_contracts(
244 project=self,
--> 245 compiler_settings=self.config.get('compilation.settings'),
246 )
247 return self._cached_compiled_contracts
/usr/local/lib/python3.5/dist-packages/populus/compilation.py in compile_project_contracts(project, compiler_settings)
52
53 try:
---> 54 compiled_contracts = compile_files(all_source_paths, **compiler_settings)
55 except ContractsNotFound:
56 return all_source_paths, {}
/usr/local/lib/python3.5/dist-packages/solc/main.py in compile_files(source_files, allow_empty, output_values, **kwargs)
121 compiler_kwargs = dict(source_files=source_files, combined_json=combined_json, **kwargs)
122
--> 123 stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs)
124
125 contracts = _parse_compiler_output(stdoutdata)
/usr/local/lib/python3.5/dist-packages/solc/utils/string.py in inner(*args, **kwargs)
65 @functools.wraps(fn)
66 def inner(*args, **kwargs):
---> 67 return force_obj_to_text(fn(*args, **kwargs))
68 return inner
/usr/local/lib/python3.5/dist-packages/solc/wrapper.py in solc_wrapper(solc_binary, stdin_bytes, help, version, add_std, combined_json, optimize, optimize_runs, libraries, output_dir, gas, assemble, link, source_files, import_remappings, ast, ast_json, asm, asm_json, opcodes, bin, bin_runtime, clone_bin, abi, interface, hashes, userdoc, devdoc, formal, success_return_code)
140 stdin=stdin,
141 stdout=subprocess.PIPE,
--> 142 stderr=subprocess.PIPE)
143
144 stdoutdata, stderrdata = proc.communicate()
/usr/lib/python3.5/subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
945 c2pread, c2pwrite,
946 errread, errwrite,
--> 947 restore_signals, start_new_session)
948 except:
949 # Cleanup if the child failed starting.
/usr/lib/python3.5/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1549 else:
1550 err_msg += ': ' + repr(orig_executable)
-> 1551 raise child_exception_type(errno_num, err_msg)
1552 raise child_exception_type(err_msg)
1553
FileNotFoundError: [Errno 2] No such file or directory: 'solc'
In [ ]:
But Solc is installed as described in installation doc, manually, versio 0.4.8
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.