Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 11879d3

Browse files
committed
added hardcode address to 3 contracts, added polytoken.sol, updated truffle.js and index.js for cli
1 parent 5c9dfdf commit 11879d3

File tree

7 files changed

+203
-4
lines changed

7 files changed

+203
-4
lines changed

contracts/PolyToken.sol

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
pragma solidity ^0.4.18;
2+
3+
import './interfaces/IERC20.sol';
4+
import './SafeMath.sol';
5+
6+
/*
7+
Copyright (c) 2016 Smart Contract Solutions, Inc.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining
10+
a copy of this software and associated documentation files (the
11+
"Software"), to deal in the Software without restriction, including
12+
without limitation the rights to use, copy, modify, merge, publish,
13+
distribute, sublicense, and/or sell copies of the Software, and to
14+
permit persons to whom the Software is furnished to do so, subject to
15+
the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
/**
30+
* @title Standard ERC20 token
31+
*
32+
* @dev Implementation of the basic standard token.
33+
* @dev https://github.com/ethereum/EIPs/issues/20
34+
*/
35+
contract PolyToken is IERC20 {
36+
using SafeMath for uint256;
37+
38+
// Poly Token parameters
39+
string public name = 'Polymath';
40+
string public symbol = 'POLY';
41+
uint8 public constant decimals = 18;
42+
uint256 public constant decimalFactor = 10 ** uint256(decimals);
43+
uint256 public constant totalSupply = 1000000000 * decimalFactor;
44+
mapping (address => uint256) balances;
45+
mapping (address => mapping (address => uint256)) internal allowed;
46+
47+
event Transfer(address indexed from, address indexed to, uint256 value);
48+
event Approval(address indexed owner, address indexed spender, uint256 value);
49+
50+
/**
51+
* @dev Constructor for Poly creation
52+
* @dev Assigns the totalSupply to the PolyDistribution contract
53+
*/
54+
function PolyToken(address _polyDistributionContractAddress) public {
55+
require(_polyDistributionContractAddress != address(0));
56+
balances[_polyDistributionContractAddress] = totalSupply;
57+
Transfer(address(0), _polyDistributionContractAddress, totalSupply);
58+
}
59+
60+
/**
61+
* @dev Gets the balance of the specified address.
62+
* @param _owner The address to query the the balance of.
63+
* @return An uint256 representing the amount owned by the passed address.
64+
*/
65+
function balanceOf(address _owner) public view returns (uint256 balance) {
66+
return balances[_owner];
67+
}
68+
69+
/**
70+
* @dev Function to check the amount of tokens that an owner allowed to a spender.
71+
* @param _owner address The address which owns the funds.
72+
* @param _spender address The address which will spend the funds.
73+
* @return A uint256 specifying the amount of tokens still available for the spender.
74+
*/
75+
function allowance(address _owner, address _spender) public view returns (uint256) {
76+
return allowed[_owner][_spender];
77+
}
78+
79+
/**
80+
* @dev transfer token for a specified address
81+
* @param _to The address to transfer to.
82+
* @param _value The amount to be transferred.
83+
*/
84+
function transfer(address _to, uint256 _value) public returns (bool) {
85+
require(_to != address(0));
86+
require(_value <= balances[msg.sender]);
87+
88+
// SafeMath.sub will throw if there is not enough balance.
89+
balances[msg.sender] = balances[msg.sender].sub(_value);
90+
balances[_to] = balances[_to].add(_value);
91+
Transfer(msg.sender, _to, _value);
92+
return true;
93+
}
94+
95+
/**
96+
* @dev Transfer tokens from one address to another
97+
* @param _from address The address which you want to send tokens from
98+
* @param _to address The address which you want to transfer to
99+
* @param _value uint256 the amount of tokens to be transferred
100+
*/
101+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
102+
require(_to != address(0));
103+
require(_value <= balances[_from]);
104+
require(_value <= allowed[_from][msg.sender]);
105+
106+
balances[_from] = balances[_from].sub(_value);
107+
balances[_to] = balances[_to].add(_value);
108+
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
109+
Transfer(_from, _to, _value);
110+
return true;
111+
}
112+
113+
/**
114+
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
115+
*
116+
* Beware that changing an allowance with this method brings the risk that someone may use both the old
117+
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
118+
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
119+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
120+
* @param _spender The address which will spend the funds.
121+
* @param _value The amount of tokens to be spent.
122+
*/
123+
function approve(address _spender, uint256 _value) public returns (bool) {
124+
allowed[msg.sender][_spender] = _value;
125+
Approval(msg.sender, _spender, _value);
126+
return true;
127+
}
128+
129+
/**
130+
* @dev Increase the amount of tokens that an owner allowed to a spender.
131+
*
132+
* approve should be called when allowed[_spender] == 0. To increment
133+
* allowed value is better to use this function to avoid 2 calls (and wait until
134+
* the first transaction is mined)
135+
* From MonolithDAO Token.sol
136+
* @param _spender The address which will spend the funds.
137+
* @param _addedValue The amount of tokens to increase the allowance by.
138+
*/
139+
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
140+
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
141+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
142+
return true;
143+
}
144+
145+
/**
146+
* @dev Decrease the amount of tokens that an owner allowed to a spender.
147+
*
148+
* approve should be called when allowed[_spender] == 0. To decrement
149+
* allowed value is better to use this function to avoid 2 calls (and wait until
150+
* the first transaction is mined)
151+
* From MonolithDAO Token.sol
152+
* @param _spender The address which will spend the funds.
153+
* @param _subtractedValue The amount of tokens to decrease the allowance by.
154+
*/
155+
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
156+
uint oldValue = allowed[msg.sender][_spender];
157+
if (_subtractedValue > oldValue) {
158+
allowed[msg.sender][_spender] = 0;
159+
} else {
160+
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
161+
}
162+
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
163+
return true;
164+
}
165+
166+
}

src/artifacts/Compliance.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,16 @@
601601
}
602602
],
603603
"networks": {
604+
"1": {
605+
"events": {},
606+
"links": {},
607+
"address": "0x076719c05961a0c3398e558e2199085d32717ca6"
608+
},
609+
"3": {
610+
"events": {},
611+
"links": {},
612+
"address": "0x238aa304fd1331a591c63e624453f4aeb08bc4b0"
613+
},
604614
"50": {
605615
"events": {},
606616
"links": {},

src/artifacts/Customers.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@
317317
}
318318
],
319319
"networks": {
320+
"1": {
321+
"events": {},
322+
"links": {},
323+
"address": "0xeb30a60c199664ab84dec3f8b72de3badf1837f5"
324+
},
325+
"3": {
326+
"events": {},
327+
"links": {},
328+
"address": "0x9d27f258663957f13fd2804b6c985797b8ca132e"
329+
},
320330
"50": {
321331
"events": {},
322332
"links": {},

src/artifacts/PolyTokenMock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,4 @@
249249
},
250250
"bytecode": "0x6060604052620f424060005560408051908101604052601081527f506f6c796d617468204e6574776f726b00000000000000000000000000000000602082015260019080516100529291602001906100b8565b506002805460ff1916601217905560408051908101604052600481527f504f4c5900000000000000000000000000000000000000000000000000000000602082015260039080516100a79291602001906100b8565b5034156100b357600080fd5b610153565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f957805160ff1916838001178555610126565b82800160010185558215610126579182015b8281111561012657825182559160200191906001019061010b565b50610132929150610136565b5090565b61015091905b80821115610132576000815560010161013c565b90565b610701806101626000396000f3006060604052600436106100a35763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100a8578063095ea7b31461013257806318160ddd1461016857806323b872dd1461018d5780632570e31e146101b5578063313ce567146101d757806370a082311461020057806395d89b411461021f578063a9059cbb14610232578063dd62ed3e14610254575b600080fd5b34156100b357600080fd5b6100bb610279565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100f75780820151838201526020016100df565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013d57600080fd5b610154600160a060020a0360043516602435610317565b604051901515815260200160405180910390f35b341561017357600080fd5b61017b610383565b60405190815260200160405180910390f35b341561019857600080fd5b610154600160a060020a0360043581169060243516604435610389565b34156101c057600080fd5b610154600435600160a060020a036024351661050b565b34156101e257600080fd5b6101ea610534565b60405160ff909116815260200160405180910390f35b341561020b57600080fd5b61017b600160a060020a036004351661053d565b341561022a57600080fd5b6100bb610558565b341561023d57600080fd5b610154600160a060020a03600435166024356105c3565b341561025f57600080fd5b61017b600160a060020a0360043581169060243516610682565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561030f5780601f106102e45761010080835404028352916020019161030f565b820191906000526020600020905b8154815290600101906020018083116102f257829003601f168201915b505050505081565b600160a060020a03338116600081815260056020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60005481565b6000600160a060020a03831615156103a057600080fd5b600160a060020a0384166000908152600460205260409020548211156103c557600080fd5b600160a060020a03808516600090815260056020908152604080832033909416835292905220548211156103f857600080fd5b600160a060020a038416600090815260046020526040902054610421908363ffffffff6106ad16565b600160a060020a038086166000908152600460205260408082209390935590851681522054610456908363ffffffff6106bf16565b600160a060020a0380851660009081526004602090815260408083209490945587831682526005815283822033909316825291909152205461049e908363ffffffff6106ad16565b600160a060020a03808616600081815260056020908152604080832033861684529091529081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b600160a060020a0316600090815260046020526040812080548301905580549091019055600190565b60025460ff1681565b600160a060020a031660009081526004602052604090205490565b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561030f5780601f106102e45761010080835404028352916020019161030f565b600160a060020a0333166000908152600460205260408120546105ec908363ffffffff6106ad16565b600160a060020a033381166000908152600460205260408082209390935590851681522054610621908363ffffffff6106bf16565b600160a060020a0380851660008181526004602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b6000828211156106b957fe5b50900390565b6000828201838110156106ce57fe5b93925050505600a165627a7a7230582012fb3bc46ef2acef2c2c76f2937cff2fa9948a8e916246c91c81e948d6996f6d0029",
251251
"sourceHash": "0x3885ea26b961c0fe1d3f805f07d80024bb638f51ba420f1a92e03a06c800d938"
252-
}
252+
}

src/artifacts/SecurityTokenRegistrar.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@
223223
}
224224
],
225225
"networks": {
226+
"1": {
227+
"events": {},
228+
"links": {},
229+
"address": "0x56e30b617c8b4798955b6be6fec706de91352ed0"
230+
},
231+
"3": {
232+
"events": {},
233+
"links": {},
234+
"address": "0x7eD744cdE284417740bCF758795d54dd14DD08dA"
235+
},
226236
"50": {
227237
"events": {},
228238
"links": {},

src/cli/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function copyArtifacts(/* argv */) {
6767
'SecurityTokenRegistrar',
6868
'STOContract',
6969
'Template',
70+
'PolyToken',
7071
];
7172

7273
for (let i = 0; i < toCopy.length; i++) {

truffle.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ module.exports = {
1111
host: 'localhost',
1212
port: 1337,
1313
network_id: '3',
14-
// At some point it would be nice not to hard-code this address.
15-
// In the meantime, get password file from Sukhveer.
16-
from: '0xb571be0e1876dc43345cfb08e1ad2792f678aefd',
1714
},
1815
testrpc: {
1916
host: 'localhost',
2017
port: 8545,
2118
network_id: '50',
2219
},
20+
mainnet: {
21+
host: 'localhost',
22+
port: 1337,
23+
network_id: '1',
24+
},
2325
},
2426
solc: {
2527
optimizer: {

0 commit comments

Comments
 (0)