Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
a605f669
Commit
a605f669
authored
Apr 06, 2017
by
David Knott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create and test MintableToken contract
parent
03282505
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
MintableToken.sol
contracts/token/MintableToken.sol
+42
-0
MintableToken.js
test/MintableToken.js
+35
-0
No files found.
contracts/token/MintableToken.sol
0 → 100644
View file @
a605f669
pragma solidity ^0.4.8;
import './StandardToken.sol';
import '../ownership/Ownable.sol';
/**
* Mintable token
*
* Simple ERC20 Token example, with mintable token creation
* Issue:
* https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet:
* https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint value);
bool public mintingFinished = false;
uint public totalSupply = 0;
modifier canMint() {
if(mintingFinished) throw;
_;
}
function mint(address _to, uint _amount) onlyOwner canMint returns (bool) {
totalSupply = safeAdd(totalSupply, _amount);
balances[_to] = safeAdd(balances[_to], _amount);
Mint(_to, _amount);
return true;
}
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
return true;
}
}
\ No newline at end of file
test/MintableToken.js
0 → 100644
View file @
a605f669
'use strict'
;
const
assertJump
=
require
(
'./helpers/assertJump'
);
var
MintableToken
=
artifacts
.
require
(
'../contracts/Tokens/MintableToken.sol'
);
contract
(
'Mintable'
,
function
(
accounts
)
{
let
token
;
beforeEach
(
async
function
()
{
token
=
await
MintableToken
.
new
();
});
it
(
'should start with a totalSupply of 0'
,
async
function
()
{
let
totalSupply
=
await
token
.
totalSupply
();
assert
.
equal
(
totalSupply
,
0
);
});
it
(
'should return mintingFinished false after construction'
,
async
function
()
{
let
mintingFinished
=
await
token
.
mintingFinished
();
assert
.
equal
(
mintingFinished
,
false
);
});
it
(
'should mint a given amount of tokens to a given address'
,
async
function
()
{
await
token
.
mint
(
accounts
[
0
],
100
);
let
balance0
=
await
token
.
balanceOf
(
accounts
[
0
]);
assert
(
balance0
,
100
);
let
totalSupply
=
await
token
.
totalSupply
();
assert
(
totalSupply
,
100
);
})
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment