1
- /* pragma solidity ^0.4.18;
1
+ pragma solidity ^ 0.4.18 ;
2
2
3
+ import "zeppelin-solidity/contracts/math/SafeMath.sol " ;
4
+ import "../tokens/SingularityNetToken.sol " ;
3
5
4
- contract Market {
5
-
6
- address public owner;
7
- mapping (address => uint256) public jobs;
8
-
9
- function Market() public {
10
- owner = msg.sender;
11
- }
12
-
13
- function ask() public {
14
-
15
- }
16
6
17
- function sell() public {
18
-
19
- }
20
-
21
- function stake() pure {
22
-
23
- }
24
-
25
- } */
7
+ contract Market {
8
+ using SafeMath
9
+ for uint256 ;
10
+
11
+ SingularityNetToken public token;
12
+ address public owner;
13
+ // amount of AGI at stake
14
+ uint256 public pool = 0 ;
15
+ // supply of MintedToken
16
+ uint256 public totalSupply = 0 ;
17
+ // next price multiplier in AGI for minting next token
18
+ uint256 public nextPrice = 1 * (10 ** 8 );
19
+
20
+ //Balances of MintedToken
21
+ mapping (address => uint256 ) public balances;
22
+
23
+ function Market (address _token ) public {
24
+ owner = msg .sender ;
25
+ token = SingularityNetToken (_token);
26
+ }
27
+
28
+ function ask () public {
29
+ // We want to add 1 AGI. Use cogs instead?
30
+ require (token.transferFrom (msg .sender , address (this ), nextPrice));
31
+ pool = pool.add (nextPrice);
32
+ //Minting
33
+ uint256 mintedToken = 1 ;
34
+ balances[msg .sender ] = mintedToken;
35
+ totalSupply = totalSupply.add (mintedToken);
36
+ //Update the rate
37
+ nextPrice = nextPrice.add (1 * (10 ** 8 ));
38
+ }
39
+
40
+ function claimFunds () {
41
+ require (owner == msg .sender );
42
+ token.transfer (owner, token.balanceOf (address (this )));
43
+ }
44
+
45
+ }
0 commit comments