pragma solidity ^0.4.15;
contract ERC20 {
event Transfer(address indexed from, address indexed to, uint value);
function balanceOf( address who ) public constant returns (uint value);
function transfer( address to, uint value) public returns (bool ok);
function approve( address to, uint value) public returns (bool ok);
function transferFrom(address from, address to, uint value) public returns (bool ok);
}
contract Owned {
address public owner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
contract TerraformReserve is Owned {
/* Storing a balance for each user */
mapping (address => uint256) public lockedBalance;
/* Store the total sum locked */
uint public totalLocked;
/* Reference to the token */
ERC20 public manaToken;
/* Contract that will assign the LAND and burn/return tokens */
address public landClaim;
/* Prevent the token from accepting deposits */
bool public acceptingDeposits;
event LockedBalance(address user, uint mana);
event LandClaimContractSet(address target);
event LandClaimExecuted(address user, uint value, bytes data);
event AcceptingDepositsChanged(bool _acceptingDeposits);
function TerraformReserve(address _token) {
require(_token != 0);
manaToken = ERC20(_token);
acceptingDeposits = true;
}
/**
* Lock MANA into the contract.
* This contract does not have another way to take the tokens out other than
* through the target contract.
*/
function lockMana(address _from, uint256 mana) public {
require(acceptingDeposits);
require(mana >= 1000 * 1e18);
require(manaToken.transferFrom(_from, this, mana));
lockedBalance[_from] += mana;
totalLocked += mana;
LockedBalance(_from, mana);
}
/**
* Allows the owner of the contract to pause acceptingDeposits
*/
function changeContractState(bool _acceptingDeposits) public onlyOwner {
acceptingDeposits = _acceptingDeposits;
AcceptingDepositsChanged(acceptingDeposits);
}
/**
* Set the contract that can move the staked MANA.
* Calls the `approve` function of the ERC20 token with the total amount.
*/
function setTargetContract(address target) public onlyOwner {
landClaim = target;
manaToken.approve(landClaim, totalLocked);
LandClaimContractSet(target);
}
/**
* Prevent payments to the contract
*/
function () public payable {
revert();
}
}
{
"compilationTarget": {
"TerraformReserve.sol": "TerraformReserve"
},
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":false,"inputs":[{"name":"target","type":"address"}],"name":"setTargetContract","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalLocked","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_acceptingDeposits","type":"bool"}],"name":"changeContractState","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"mana","type":"uint256"}],"name":"lockMana","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"manaToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"landClaim","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"lockedBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"acceptingDeposits","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_token","type":"address"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"mana","type":"uint256"}],"name":"LockedBalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"target","type":"address"}],"name":"LandClaimContractSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"LandClaimExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_acceptingDeposits","type":"bool"}],"name":"AcceptingDepositsChanged","type":"event"}]