Skip to content

Commit 916ab14

Browse files
committed
hello world
0 parents  commit 916ab14

File tree

3 files changed

+432
-0
lines changed

3 files changed

+432
-0
lines changed

AirDrop.sol

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
pragma solidity ^0.4.19;
2+
3+
/**
4+
* @title Token
5+
* @dev Simpler version of ERC20 interface
6+
*/
7+
contract Token {
8+
function transfer(address to, uint256 value) public returns (bool);
9+
event Transfer(address indexed from, address indexed to, uint256 value);
10+
}
11+
12+
contract Ownable {
13+
address public owner;
14+
15+
16+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
17+
18+
19+
/**
20+
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
21+
* account.
22+
*/
23+
function Ownable() {
24+
owner = msg.sender;
25+
}
26+
27+
28+
/**
29+
* @dev Throws if called by any account other than the owner.
30+
*/
31+
modifier onlyOwner() {
32+
require(msg.sender == owner);
33+
_;
34+
}
35+
36+
37+
/**
38+
* @dev Allows the current owner to transfer control of the contract to a newOwner.
39+
* @param newOwner The address to transfer ownership to.
40+
*/
41+
function transferOwnership(address newOwner) onlyOwner public {
42+
require(newOwner != address(0));
43+
OwnershipTransferred(owner, newOwner);
44+
owner = newOwner;
45+
}
46+
47+
}
48+
49+
contract AirDrop is Ownable {
50+
51+
// This declares a state variable that would store the contract address
52+
Token public tokenInstance;
53+
54+
/*
55+
constructor function to set token address
56+
*/
57+
function AirDrop(address _tokenAddress){
58+
tokenInstance = Token(_tokenAddress);
59+
}
60+
event AddressLog(address _from, uint256 _amount);
61+
62+
/*
63+
Airdrop function which take up a array of address and amount and call the
64+
transfer function to send the token
65+
*/
66+
function doAirDrop(address[] addrs, uint256 _amount) onlyOwner public returns (bool success) {
67+
uint256 count = addrs.length;
68+
for (uint256 i = 0; i < count; i++)
69+
{
70+
/* calling transfer function from contract */
71+
tokenInstance.transfer(addrs [i],_amount);
72+
/* logging event */
73+
AddressLog(addrs [i],_amount);
74+
}
75+
}
76+
}

PreMint.sol

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
pragma solidity ^0.4.19;
2+
3+
/**
4+
* @title ERC20Basic
5+
* @dev Simpler version of ERC20 interface
6+
* @dev see https://github.com/ethereum/EIPs/issues/179
7+
*/
8+
contract ERC20Basic {
9+
uint256 public totalSupply;
10+
function balanceOf(address who) public view returns (uint256);
11+
function transfer(address to, uint256 value) public returns (bool);
12+
event Transfer(address indexed from, address indexed to, uint256 value);
13+
}
14+
15+
contract ERC20 is ERC20Basic {
16+
function allowance(address owner, address spender) public view returns (uint256);
17+
function transferFrom(address from, address to, uint256 value) public returns (bool);
18+
function approve(address spender, uint256 value) public returns (bool);
19+
event Approval(address indexed owner, address indexed spender, uint256 value);
20+
}
21+
22+
23+
contract StandardToken is ERC20 {
24+
using SafeMath for uint256;
25+
26+
mapping (address => uint256) public balances;
27+
mapping (address => mapping (address => uint256)) public allowed;
28+
29+
function transfer(address _to, uint256 _value) returns (bool success) {
30+
require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
31+
balances[msg.sender] = balances[msg.sender].sub(_value);
32+
balances[_to] = balances[_to].add(_value);
33+
Transfer(msg.sender, _to, _value);
34+
return true;
35+
}
36+
37+
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
38+
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]);
39+
balances[_to] = balances[_to].add(_value);
40+
balances[_from] = balances[_from].sub(_value);
41+
allowed[_from][msg.sender] -= allowed[_from][msg.sender].sub(_value);
42+
Transfer(_from, _to, _value);
43+
return true;
44+
}
45+
46+
function balanceOf(address _owner) constant returns (uint256 balance) {
47+
return balances[_owner];
48+
}
49+
50+
function approve(address _spender, uint256 _value) returns (bool success) {
51+
allowed[msg.sender][_spender] = _value;
52+
Approval(msg.sender, _spender, _value);
53+
return true;
54+
}
55+
56+
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
57+
return allowed[_owner][_spender];
58+
}
59+
}
60+
61+
contract Ownable {
62+
address public owner;
63+
64+
65+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
66+
67+
68+
/**
69+
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
70+
* account.
71+
*/
72+
function Ownable() {
73+
owner = msg.sender;
74+
}
75+
76+
77+
/**
78+
* @dev Throws if called by any account other than the owner.
79+
*/
80+
modifier onlyOwner() {
81+
require(msg.sender == owner);
82+
_;
83+
}
84+
85+
86+
/**
87+
* @dev Allows the current owner to transfer control of the contract to a newOwner.
88+
* @param newOwner The address to transfer ownership to.
89+
*/
90+
function transferOwnership(address newOwner) onlyOwner public {
91+
require(newOwner != address(0));
92+
OwnershipTransferred(owner, newOwner);
93+
owner = newOwner;
94+
}
95+
96+
}
97+
98+
library SafeMath {
99+
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
100+
uint256 c = a * b;
101+
assert(a == 0 || c / a == b);
102+
return c;
103+
}
104+
105+
function div(uint256 a, uint256 b) internal constant returns (uint256) {
106+
assert(b > 0); // Solidity automatically throws when dividing by 0
107+
uint256 c = a / b;
108+
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
109+
return c;
110+
}
111+
112+
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
113+
assert(b <= a);
114+
return a - b;
115+
}
116+
117+
function add(uint256 a, uint256 b) internal constant returns (uint256) {
118+
uint256 c = a + b;
119+
assert(c >= a);
120+
return c;
121+
}
122+
}
123+
124+
/* Contract class for adding removing whitelisted contracts */
125+
contract WhiteListedContracts is Ownable {
126+
mapping (address => uint ) white_listed_contracts;
127+
128+
//modifer to check if the contract given is white listed or not
129+
modifier whitelistedContractsOnly() {
130+
require(white_listed_contracts[msg.sender] == 1);
131+
_;
132+
}
133+
134+
//add a contract to whitelist
135+
function addWhiteListedContracts (address _address) onlyOwner public {
136+
white_listed_contracts[_address] = 1;
137+
}
138+
139+
//remove contract from whitelist
140+
function removeWhiteListedContracts (address _address) onlyOwner public {
141+
white_listed_contracts[_address] = 0;
142+
}
143+
}
144+
145+
/* Contract class to mint tokens and transfer */
146+
contract SRTToken is Ownable,StandardToken,WhiteListedContracts {
147+
using SafeMath for uint256;
148+
149+
string constant public name = 'SpringRole Pre Mint Token';
150+
string constant public symbol = 'SRT';
151+
uint constant public decimals = 18;
152+
uint256 public totalSupply;
153+
154+
/* Contructor function to set initial balance and assign to owner*/
155+
function SRTToken(uint256 _totalSupply){
156+
totalSupply = _totalSupply * 10**decimals;
157+
balances[msg.sender] = balances[msg.sender].add(totalSupply);
158+
}
159+
160+
/*
161+
transfer eth recived to owner account if any
162+
*/
163+
function() payable {
164+
owner.transfer(msg.value);
165+
}
166+
167+
/*
168+
do transfer function will allow transfer from a _to to _from provided if the call
169+
comes from whitelisted contracts only
170+
*/
171+
function doTransfer(address _from, address _to, uint256 _value) whitelistedContractsOnly public returns (bool){
172+
require(balances[_from] >= _value && balances[_to] + _value > balances[_to]);
173+
balances[_from] = balances[_from].sub(_value);
174+
balances[_to] = balances[_to].add(_value);
175+
Transfer(_from, _to, _value);
176+
return true;
177+
}
178+
179+
}

0 commit comments

Comments
 (0)