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
350ab098
Commit
350ab098
authored
Mar 20, 2017
by
Jorge Izquierdo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments for TransferableToken
parent
72029b68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
TransferableToken.sol
contracts/token/TransferableToken.sol
+27
-0
No files found.
contracts/token/TransferableToken.sol
View file @
350ab098
...
...
@@ -2,20 +2,47 @@ pragma solidity ^0.4.8;
import "./ERC20.sol";
/*
TransferableToken defines the generic interface and the implementation
to limit token transferability for different events.
It is intended to be used as a base class for other token contracts.
Over-writting transferableTokens(address holder, uint64 time) is the way to provide
the specific logic for limitting token transferability for a holder over time.
TransferableToken has been designed to allow for different limitting factors,
this can be achieved by recursively calling super.transferableTokens() until the
base class is hit. For example:
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return min256(unlockedTokens, super.transferableTokens(holder, time));
}
A working example is VestedToken.sol:
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol
*/
contract TransferableToken is ERC20 {
// Checks whether it can transfer or otherwise throws.
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
// Checks modifier and allows transfer if tokens are not locked.
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) returns (bool success) {
return super.transfer(_to, _value);
}
// Checks modifier and allows transfer if tokens are not locked.
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
// Default transferable tokens function returns all tokens for a holder (no limit).
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
...
...
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