-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConvergent_Billboard.sol
73 lines (61 loc) · 2.14 KB
/
Convergent_Billboard.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pragma solidity ^0.4.24;
import "@convergent/arc/contracts/EthPolynomialCurvedToken.sol";
contract Convergent_Billboard is EthPolynomialCurvedToken {
using SafeMath for uint256;
uint256 public cashed; // Amount of tokens that have been "cashed out."
uint256 public maxTokens; // Total amount of Billboard tokens to be sold.
uint256 public requiredAmt; // Required amount of token per banner change.
address public safe; // Target to send the funds.
event Advertisement(bytes32 what, uint256 indexed when);
constructor(uint256 _maxTokens, uint256 _requiredAmt, address _safe)
EthPolynomialCurvedToken(
"Convergent Billboard Token",
"CBT",
18,
1,
1000
)
public
{
maxTokens = _maxTokens * 10**18;
requiredAmt = _requiredAmt * 10**18;
safe = _safe;
}
/// Overwrite
function mint(uint256 numTokens) public payable {
uint256 newTotal = totalSupply().add(numTokens);
if (newTotal > maxTokens) {
super.mint(maxTokens.sub(totalSupply()));
// The super.mint() function will not allow 0
// as an argument rendering this as sufficient
// to enforce a cap of maxTokens.
} else {
super.mint(numTokens);
}
}
function purchaseAdvertisement(bytes32 _what)
public
payable
{
mint(requiredAmt);
submit(_what);
}
function submit(bytes32 _what)
public
{
require(balanceOf(msg.sender) >= requiredAmt);
cashed++; // increment cashed counter
_transfer(msg.sender, address(0x1337), requiredAmt);
uint256 dec = 10**uint256(decimals());
uint256 newCliff = curveIntegral(
(cashed).mul(dec)
);
uint256 oldCliff = curveIntegral(
(cashed - 1).mul(dec)
);
uint256 cliffDiff = newCliff.sub(oldCliff);
safe.transfer(cliffDiff);
emit Advertisement(_what, block.timestamp);
}
function () public { revert(); }
}