Solidity smart contracts for the Decentraland Crowdsale and MANA Token
decentraland / mana Goto Github PK
View Code? Open in Web Editor NEW⏣ Solidity Contracts for the Decentraland MANA Token
License: Other
⏣ Solidity Contracts for the Decentraland MANA Token
License: Other
This causes Travis to report that tests pass when they fail. There's an updated script in OpenZeppelin which fixes this.
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/scripts/test.sh
DO you want to allow the token holders to burn/destroy their tokens? Maybe you dont, I mean you want the tokens in circulation right? Would a user would want to destroy it?. In the case a account is hacked, and instead of draining the account the attacker decide to burn the tokens instead.
I dont understand 100% how you crowdsale will work, but if you need to destroy unsold tokens, you can allow only the crowdsale owner to do that.
If you want I can create the PR to let only the owner of the crowdsale burn tokens, let me know what you think :)
Also, identify code stealed copied from OpenZeppelin.
Line 44:
require(_rate > _rateStepDecrease * (_endBlock - _startBlock));
and line 78 of MANACrowdsale.sol:
return rate.sub(rateStepDecrease.mul(block.number - startBlock));
should use SafeMath functions to be consistent with the rest of the codebase.
Specifically, line 44 should be changed to:
require(_rate > _rateStepDecrease.mul(_endBlock.sub(_startBlock)));
and line 78 should be changed to:
return rate.sub(rateStepDecrease.mul(block.number.sub(startBlock)));
why https://etherscan.io/address/0xa66d83716c7cfe425b44d0f7ef92de263468fb3d is no longer used?
We should transfer the ownership of the token once the main Crowdsale ends to a simpler contract that only handles the continuous issuance. This significantly reduces the attack surface of both contracts.
Helps prevent what happened to Parity multisig.
When a whitelisted investor is making a purchase the cap invariant check is skipped. This will allow a big whale investor to buy much more tokens than intended to be offered and put the whole crowd sale in jeopardy.
Test to demonstrate this bug:
it('whitelisted big whale investor should not exceed the cap', async function () {
const cap = (await crowdsale.cap());
const overCap = cap.mul(2);
await crowdsale.addToWhitelist(investor);
await crowdsale.buyTokens(investor, {value: overCap, from: investor}).should.be.rejectedWith(EVMThrow);
const balance = await token.balanceOf(investor);
const raised = await crowdsale.weiRaised();
balance.should.be.bignumber.equal(0);
raised.should.be.bignumber.most(cap);
})
In MANACrowdsale.sol three contracts are imported from zeppelin-solidity
, but there's no indication as to which versions they are.
This potentially complicates review.
mana/contracts/BurnableToken.sol
Line 18 in e39547e
Line 127 of MANACrowdsale.sol:
// TODO: possibility of overflow in these operations should be analized
should be removed as there is no possibility of overflow. uint256 can store numbers larger than 10^77.
The line also contains a typo: analized should be analyzed.
It's also worth noting that the interest in the next two lines is calculated linearly instead of exponentially.
Since endBlock
is inclusive, MANACrowdsale.sol:44 should read:
require(_rate > _rateStepDecrease * (1 + _endBlock - _startBlock));
processPurchase() in MANACrowdsale overrides the function in ContiniousCrowdsale, Instead of overriding that method you can add the function getRate() on the ConiousCrowdsale and only override that function, I understand that is the only thing that you want to do, provide different rates for special addresses, its not a bug, just a change on the code that you can do, and I think It will look better.
Also, why is getRate() internal? I think it can be public, so the investors can verify the rate they are going to have before sending eth.
If you want I can create the PR, let me know what you think :)
Hi,
I am a newbie in Ethereum contract programming. I am testing the code in an ubuntu machine with node, testrpc and truffle. Here is what I got after running "npm test"
reggie@UBC809:~/mana$ npm test
> [email protected] test /home/reggie/mana
> ./scripts/test.sh
Using existing testrpc instance
Compiling ./contracts/BurnableToken.sol...
Compiling ./contracts/ContinuousSale.sol...
Compiling ./contracts/MANAContinuousSale.sol...
Compiling ./contracts/MANACrowdsale.sol...
Compiling ./contracts/MANAToken.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/WhitelistedCrowdsale.sol...
Compiling ./test/helpers/BurnableTokenMock.sol...
Compiling ./test/helpers/WhitelistedCrowdsaleImpl.sol...
Compiling zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol...
Compiling zeppelin-solidity/contracts/crowdsale/Crowdsale.sol...
Compiling zeppelin-solidity/contracts/crowdsale/FinalizableCrowdsale.sol...
Compiling zeppelin-solidity/contracts/lifecycle/Pausable.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/ownership/Ownable.sol...
Compiling zeppelin-solidity/contracts/token/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/MintableToken.sol...
Compiling zeppelin-solidity/contracts/token/PausableToken.sol...
Compiling zeppelin-solidity/contracts/token/StandardToken.sol...
Error: Error: Exceeds block gas limit
at StateManager.queueTransaction (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:90571:21)
at GethApiDouble.eth_sendTransaction (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:90071:14)
at GethApiDouble.handleRequest (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:89870:10)
at next (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59378:18)
at GethDefaults.handleRequest (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:89767:12)
at next (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59378:18)
at FilterSubprovider.handleRequest (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:65832:7)
at next (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59378:18)
at DelayedBlockFilter.handleRequest (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:89595:3)
at next (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59378:18)
at Object.InvalidResponse (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:37047:16)
at /home/reggie/mana/node_modules/truffle/build/cli.bundled.js:224634:36
at XMLHttpRequest.request.onreadystatechange (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:223413:13)
at XMLHttpRequestEventTarget.dispatchEvent (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:225286:18)
at XMLHttpRequest._setReadyState (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:225576:12)
at XMLHttpRequest._onHttpResponseEnd (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:225731:12)
at IncomingMessage.<anonymous> (/home/reggie/mana/node_modules/truffle/build/cli.bundled.js:225691:24)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
npm ERR! Test failed. See above for more details.
reggie@UBC809:~/mana$ node -v
v7.9.0
reggie@UBC809:~/mana$ npm -v
5.6.0
I don't have enough gas on testrpc?
The MANA token should be pausable
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/PausableToken.sol
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.