Skip to content

XAUR ‐ Xaurum

BokkyPooBah edited this page Mar 24, 2017 · 4 revisions

Table of contents



Token Information



Token Contract Information



Market Making Information

Creating Your Trade Contract

If you want to list a XAUR TokenTrader contract on https://cryptoderivatives.market, use the TokenTraderFactory contract.

Execute createTradeContract(address asset, uint256 buyPrice, uint256 sellPrice, uint256 units, bool buysTokens, bool sellsTokens) to create your XAUR TokenTrader contract.

The formula for working out the buyPrice or sellPrice follows:

rate = price / units * 10^(tokenDecimals - etherDecimals)

which is:

rate = price / units * 10^(tokenDecimals - 18)

and tokenDecimals = 8, so:

rate = price / units * 10^-10

Watching Your Trade Contract

Find your newly created Trade contract on https://cryptoderivatives.market/tokenTraderContracts. Watch this contract address using the ABI at How To Watch A TokenTrader Contract In Ethereum Wallet / Mist.

Depositing Tokens

Use the XAUR token contract to transfer your tokens to your newly created TokenTrader address.

Depositing Ethers

Execute your TokenTrader.makerDepositEther() function, sending the amount of ethers.



How To Watch The Token Contract In Ethereum Wallet / Mist

In Ethereum Wallet / Mist, select the CONTRACTS tab and click WATCH CONTRACT to open the Watch contract window. Then:

  • Under CONTRACT NAME, enter XAUR

  • Under CONTRACT ADDRESS, enter 0x4df812f6064def1e5e029f1ca858777cc98d2d81

  • Copy the Application Binary Interface below and paste it into the JSON INTERFACE text box

    [{"constant":false,"inputs":[{"name":"_dataContractAddress","type":"address"}],"name":"setDataContract","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_alliesContractAddress","type":"address"}],"name":"setAlliesContract","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"dataContract","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_curratorAddress","type":"address"}],"name":"setXauForGasCurrator","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_newOwnerAdress","type":"address"}],"name":"setOwner","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_meltingContractAddress","type":"address"}],"name":"setMeltingContract","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"status","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_source","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferViaProxy","outputs":[{"name":"status","type":"bool"},{"name":"sendFrom","type":"address"},{"name":"sentTo","type":"address"},{"name":"sentToAmount","type":"uint256"},{"name":"burnAddress","type":"address"},{"name":"burnAmount","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"getGasForXau","outputs":[{"name":"sucess","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"lockdown","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"alliesContract","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalGoldSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"standard","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_amount","type":"uint256"}],"name":"doBurnFromContract","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_proxyContractAddress","type":"address"}],"name":"setProxyContract","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_accountAddress","type":"address"}],"name":"isAccountLocked","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":false,"inputs":[],"name":"fillGas","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_xaurAmount","type":"uint256"},{"name":"_goldAmount","type":"uint256"}],"name":"doMelt","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_coinageAddresses","type":"address[]"},{"name":"_coinageAmounts","type":"uint256[]"},{"name":"_usdAmount","type":"uint256"},{"name":"_xaurCoined","type":"uint256"},{"name":"_goldBought","type":"uint256"}],"name":"doCoinage","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"burningAdress","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"coinageContract","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"dev","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"status","type":"bool"}],"type":"function"},{"constant":false,"inputs":[],"name":"freezeCoin","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_source","type":"address"},{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFromViaProxy","outputs":[{"name":"status","type":"bool"},{"name":"sendFrom","type":"address"},{"name":"sentTo","type":"address"},{"name":"sentToAmount","type":"uint256"},{"name":"burnAddress","type":"address"},{"name":"burnAmount","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_block","type":"uint256"}],"name":"lockAccount","outputs":[{"name":"answer","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_source","type":"address"},{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowanceFromProxy","outputs":[{"name":"remaining","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"proxyContract","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_source","type":"address"},{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approveFromProxy","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"meltingContract","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_coinageContractAddress","type":"address"}],"name":"setCoinageContract","outputs":[],"type":"function"},{"inputs":[{"name":"_burningAddress","type":"address"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"burningType","type":"XaurumToken.BurningType"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"xaurAmount","type":"uint256"},{"indexed":false,"name":"goldAmount","type":"uint256"}],"name":"Melt","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"coinageId","type":"uint256"},{"indexed":false,"name":"usdAmount","type":"uint256"},{"indexed":false,"name":"xaurAmount","type":"uint256"},{"indexed":false,"name":"goldAmount","type":"uint256"},{"indexed":false,"name":"totalGoldSupply","type":"uint256"},{"indexed":false,"name":"totalSupply","type":"uint256"}],"name":"Coinage","type":"event"}]

  • Click OK



How To Watch The Token In Ethereum Wallet / Mist

In Ethereum Wallet / Mist, select the CONTRACTS tab and click WATCH TOKEN to open the Add token window. Then:

  • Under TOKEN CONTRACT ADDRESS, enter 0x4df812f6064def1e5e029f1ca858777cc98d2d81. The additional fields should automatically be filled in.

  • Click OK



How To Check Your Token Balance In Ethereum Wallet / Mist

Watch The Token Contract, then:

  • Click on the XAUR contract
  • Click on SHOW CONTRACT INFO
  • In the READ FROM CONTRACT section and under Balance of:
  • Enter the address you want to check the token balance of
  • The token balance will be displayed in the Natural Units with 8 decimal places, e.g., 123000000 is 123000000 / 1e8 = 1.23 token units



How To Transfer Your Tokens In Ethereum Wallet / Mist

Watch The Token Contract, then:

  • Click on the XAUR contract
  • Click on SHOW CONTRACT INFO
  • In the WRITE TO CONTRACT section and under Select function:
  • Select the Transfer function
  • Under to, enter the address you want to transfer the token to
  • Under value, enter the amount of tokens you want to transfer. This amount needs to be specified in the natural units with 8 decimal places, e.g., 123000000 is 123000000 / 1e8 = 1.23 token units
  • Under Execute from, select the account you want to transfer your tokens from
  • Click on Execute, then confirm your transaction



The Token Contract Source Code

The verified source code can be found at 0x4df812f6064def1e5e029f1ca858777cc98d2d81 and follows:

contract ERC20TokenInterface {

    /// @return total amount of tokens
    function totalSupply() constant returns (uint256 supply) {}

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance) {}

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) returns (bool success) {}

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}

    /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of wei to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) returns (bool success) {}

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}   

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

contract XaurumProxyERC20 is ERC20TokenInterface {

    bool public xaurumProxyWorking;

    XaurumToken xaurumTokenReference; 

    address proxyCurrator;
    address owner;
    address dev;

    /* Public variables of the token */
    string public standard = 'XaurumERCProxy';
    string public name = 'Xaurum';
    string public symbol = 'XAUR';
    uint8 public decimals = 8;


    modifier isWorking(){
        if (xaurumProxyWorking && !xaurumTokenReference.lockdown()){
            _
        }
    }

    function XaurumProxyERC20(){
        dev = msg.sender;
        xaurumProxyWorking = true;
    }

    function setTokenReference(address _xaurumTokenAress) returns (bool){
        if (msg.sender == proxyCurrator){
            xaurumTokenReference = XaurumToken(_xaurumTokenAress);
            return true;
        }
        return false;
    }

    function EnableDisableTokenProxy() returns (bool){
        if (msg.sender == proxyCurrator){        
            xaurumProxyWorking = !xaurumProxyWorking;
            return true;
        }
        return false;
    }

    function setProxyCurrator(address _newCurratorAdress) returns (bool){
        if (msg.sender == owner || msg.sender == dev){        
            proxyCurrator = _newCurratorAdress;
            return true;
        }
        return false;
    }

    function setOwner(address _newOwnerAdress) returns (bool){
        if ( msg.sender == dev ){        
            owner = _newOwnerAdress;
            return true;
        }
        return false;
    }

    function totalSupply() constant returns (uint256 supply) {
        return xaurumTokenReference.totalSupply();
    }

    function balanceOf(address _owner) constant returns (uint256 balance) {
        return xaurumTokenReference.balanceOf(_owner);
    }

    function transfer(address _to, uint256 _value) isWorking returns (bool success) {
        bool answerStatus;
        address sentFrom;
        address sentTo;
        uint256 sentToAmount;
        address burningAddress;
        uint256 burningAmount;

        (answerStatus, sentFrom, sentTo, sentToAmount, burningAddress, burningAmount) = xaurumTokenReference.transferViaProxy(msg.sender, _to, _value);
        if(answerStatus){
            Transfer(sentFrom, sentTo, sentToAmount);
            Transfer(sentFrom, burningAddress, burningAmount);
            return true;
        }
        return false;
    }

    function transferFrom(address _from, address _to, uint256 _value) isWorking returns (bool success) {
        bool answerStatus;
        address sentFrom;
        address sentTo;
        uint256 sentToAmount;
        address burningAddress;
        uint256 burningAmount;

        (answerStatus, sentFrom, sentTo, sentToAmount, burningAddress, burningAmount) = xaurumTokenReference.transferFromViaProxy(msg.sender, _from, _to, _value);
        if(answerStatus){
            Transfer(sentFrom, sentTo, sentToAmount);
            Transfer(sentFrom, burningAddress, burningAmount);
            return true;
        }
        return false;
    }

    function approve(address _spender, uint256 _value) isWorking returns (bool success) {
        if (xaurumTokenReference.approveFromProxy(msg.sender, _spender, _value)){
            Approval(msg.sender, _spender, _value);
            return true;
        }
        return false;
    }

    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
        return xaurumTokenReference.allowanceFromProxy(msg.sender, _owner, _spender);
    } 
}

contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }

contract XaurumToken {
    
    /* Public variables of the token */
    string public standard = 'Xaurum v1.0';
    string public name = 'Xaurum';
    string public symbol = 'XAUR';
    uint8 public decimals = 8;

    uint256 public totalSupply = 0;
    uint256 public totalGoldSupply = 0;
    bool public lockdown = false;
    uint256 numberOfCoinages;

    /* Private variabiles for the token */
    mapping (address => uint256) balances;
    mapping (address => mapping (address => uint256)) allowed;
    mapping (address => uint) lockedAccounts;

    /* Events */
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
    event Burn(address from, uint256 value, BurningType burningType);
    event Melt(uint256 xaurAmount, uint256 goldAmount);
    event Coinage(uint256 coinageId, uint256 usdAmount, uint256 xaurAmount, uint256 goldAmount, uint256 totalGoldSupply, uint256 totalSupply);

    /*enums*/
    enum BurningType { TxtFee, AllyDonation, ServiceFee }

   /* Contracts */
    XaurumMeltingContract public meltingContract;
    function setMeltingContract(address _meltingContractAddress){
        if (msg.sender == owner || msg.sender == dev){
            meltingContract = XaurumMeltingContract(_meltingContractAddress);
        }
    }

    XaurumDataContract public dataContract;
    function setDataContract(address _dataContractAddress){
        if (msg.sender == owner || msg.sender == dev){
            dataContract = XaurumDataContract(_dataContractAddress);
        }
    }

    XaurumCoinageContract public coinageContract;
    function setCoinageContract(address _coinageContractAddress){
        if (msg.sender == owner || msg.sender == dev){
            coinageContract = XaurumCoinageContract(_coinageContractAddress);
        }
    }

    XaurmProxyContract public proxyContract;
    function setProxyContract(address _proxyContractAddress){
        if (msg.sender == owner || msg.sender == dev){
            proxyContract = XaurmProxyContract(_proxyContractAddress);
        }
    }

    XaurumAlliesContract public alliesContract;
    function setAlliesContract(address _alliesContractAddress){
        if (msg.sender == owner || msg.sender == dev){
            alliesContract = XaurumAlliesContract(_alliesContractAddress);
        }
    }
    
    
    

    /* owner */
    address public owner;
    function setOwner(address _newOwnerAdress) returns (bool){
        if ( msg.sender == dev ){        
            owner = _newOwnerAdress;
            return true;
        }
        return false;
    }

    address public dev;

    /* Xaur for gas */
    address xaurForGasCurrator;
    function setXauForGasCurrator(address _curratorAddress){
        if (msg.sender == owner || msg.sender == dev){
            xaurForGasCurrator = _curratorAddress;
        }
    }

    /* Burrning */
    address public burningAdress;

    /* Constructor */
    function XaurumToken(address _burningAddress) { 
        burningAdress = _burningAddress;
        lockdown = false;
        dev = msg.sender;
       
        
        // initial
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] += 5999319593600000;
         totalSupply += 5999319593600000;
         totalGoldSupply += 1696620000000;
         Coinage(numberOfCoinages, 0, 5999319593600000, 1696620000000, totalGoldSupply, totalSupply);      
		

        // Mint 1
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] += 1588947591000000;
         totalSupply += 1588947591000000;
         totalGoldSupply += 1106042126000;
         Coinage(numberOfCoinages, 60611110000000, 1588947591000000, 1106042126000, totalGoldSupply, totalSupply);
        		
		
        // Mint 2
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] += 151127191000000;
         totalSupply += 151127191000000;
         totalGoldSupply += 110134338200;
         Coinage(numberOfCoinages, 6035361000000, 151127191000000, 110134338200, totalGoldSupply, totalSupply);
        
		
		   // Mint 3
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] += 63789854418800;
         totalSupply += 63789854418800;
         totalGoldSupply +=  46701000000;
         Coinage(numberOfCoinages, 2559215000000, 63789854418800, 46701000000, totalGoldSupply, totalSupply);
        

		   // Mint 4
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] +=  393015011191000;
         totalSupply += 393015011191000;
         totalGoldSupply +=  290692000000;
         Coinage(numberOfCoinages, 15929931000000, 393015011191000, 290692000000, totalGoldSupply, totalSupply);
        

		   // Mint 5
         numberOfCoinages += 1;
         balances[0x097B7b672fe0dc3eF61f53B954B3DCC86382e7B9] +=  49394793870000;
         totalSupply += 49394793870000;
         totalGoldSupply +=  36891368614;
         Coinage(numberOfCoinages, 2021647000000, 49394793870000, 36891368614, totalGoldSupply, totalSupply);
    }
    
    function freezeCoin(){
        if (msg.sender == owner || msg.sender == dev){
            lockdown = !lockdown;
        }
    }

    /* Get balance of the account */
    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
    }

    /* Send coins */
    function transfer(address _to, uint256 _amount) returns (bool status) {
        uint256 goldFee = dataContract.goldFee();

        if (balances[msg.sender] >= _amount &&                                  // Check if the sender has enough
            balances[_to] + _amount > balances[_to] &&                          // Check for overflows
            _amount > goldFee &&                                                // Check if there is something left after burning fee
            !lockdown &&                                                        // Check if coin is on lockdown
            lockedAccounts[msg.sender] <= block.number) {                       // Check if the account is locked
            balances[msg.sender] -= _amount;                                    // Subtract from the sender minus the fee
            balances[_to] += (_amount - goldFee );                              // Add the same to the recipient
            Transfer(msg.sender, _to, (_amount - goldFee ));                    // Notify anyone listening that this transfer took place
            doBurn(msg.sender, goldFee, BurningType.TxtFee);                    // Notify anyone listening that this burn took place
            return true;
        } else {
            return false;
        }
    }
    
    /* A contract attempts to get the coins and sends them*/
    function transferFrom(address _from, address _to, uint256 _amount) returns (bool status) {
        uint256 goldFee = dataContract.goldFee();

        if (balances[_from] >= _amount &&                                  // Check if the sender has enough
            balances[_to] + _amount > balances[_to] &&                          // Check for overflows
            _amount > goldFee &&                                                // Check if there is something left after burning fee
            !lockdown &&                                                        // Check if coin is on lockdown
            lockedAccounts[_from] <= block.number) {                       // Check if the account is locked
            if (_amount > allowed[_from][msg.sender]){                          // Check allowance
                return false;
            }
            balances[_from] -= _amount;                                    // Subtract from the sender minus the fee
            balances[_to] += (_amount - goldFee);                               // Add the same to the recipient
            Transfer(_from, _to, (_amount - goldFee));                     // Notify anyone listening that this transfer took place
            doBurn(_from, goldFee, BurningType.TxtFee);                    
            allowed[_from][msg.sender] -= _amount;                              // Update allowance
            return true;
        } else {
            return false;
        }
    }
    
    /* Allow another contract to spend some tokens in your behalf */
    function approveAndCall(address _spender, uint256 _value, bytes _extraData)
        returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        tokenRecipient spender = tokenRecipient(_spender);
        spender.receiveApproval(msg.sender, _value, this, _extraData);
        return true;
    }

     function approve(address _spender, uint256 _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
    }

    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
      return allowed[_owner][_spender];
    }

    /* Send coins via proxy */
    function transferViaProxy(address _source, address _to, uint256 _amount) returns (bool status, address sendFrom, address sentTo, uint256 sentToAmount, address burnAddress, uint256 burnAmount){
        if (!proxyContract.isProxyLegit(msg.sender)){                                        // Check if proxy is legit
            return (false, 0, 0, 0, 0, 0);
        }

        uint256 goldFee = dataContract.goldFee();

        if (balances[_source] >= _amount &&                                     // Check if the sender has enough
            balances[_to] + _amount > balances[_to] &&                          // Check for overflows
            _amount > goldFee &&                                                // Check if there is something left after burning fee
            !lockdown &&                                                        // Check if coin is on lockdown
            lockedAccounts[_source] <= block.number) {                          // Check if the account is locked
            
            balances[_source] -= _amount;                                       // Subtract from the sender minus the fee
            balances[_to] += (_amount - goldFee );                              // Add the same to the recipient
            Transfer(_source, _to, ( _amount - goldFee ));                    // Notify anyone listening that this transfer took place
            doBurn(_source, goldFee, BurningType.TxtFee);                         // Notify anyone listening that this burn took place
        
            return (true, _source, _to, (_amount - goldFee), burningAdress, goldFee);
        } else {
            return (false, 0, 0, 0, 0, 0);
        }
    }
    
    /* a contract attempts to get the coins and sends them via proxy */
    function transferFromViaProxy(address _source, address _from, address _to, uint256 _amount) returns (bool status, address sendFrom, address sentTo, uint256 sentToAmount, address burnAddress, uint256 burnAmount) {
        if (!proxyContract.isProxyLegit(msg.sender)){                                            // Check if proxy is legit
            return (false, 0, 0, 0, 0, 0);
        }

        uint256 goldFee = dataContract.goldFee();

        if (balances[_from] >= _amount &&                                       // Check if the sender has enough
            balances[_to] + _amount > balances[_to] &&                          // Check for overflows
            _amount > goldFee &&                                                // Check if there is something left after burning fee
            !lockdown &&                                                        // Check if coin is on lockdown
            lockedAccounts[_from] <= block.number) {                            // Check if the account is locked

            if (_amount > allowed[_from][_source]){                             // Check allowance
                return (false, 0, 0, 0, 0, 0); 
            }               

            balances[_from] -= _amount;                                         // Subtract from the sender minus the fee
            balances[_to] += ( _amount - goldFee );                             // Add the same to the recipient
            Transfer(_from, _to, ( _amount - goldFee ));                        // Notify anyone listening that this transfer took place
            doBurn(_from, goldFee, BurningType.TxtFee);
            allowed[_from][_source] -= _amount;                                 // Update allowance
            return (true, _from, _to, (_amount - goldFee), burningAdress, goldFee);
        } else {
            return (false, 0, 0, 0, 0, 0);
        }
    }
    
     function approveFromProxy(address _source, address _spender, uint256 _value) returns (bool success) {
        if (!proxyContract.isProxyLegit(msg.sender)){                                        // Check if proxy is legit
            return false;
        }
        allowed[_source][_spender] = _value;
        Approval(_source, _spender, _value);
        return true;
    }

    function allowanceFromProxy(address _source, address _owner, address _spender) constant returns (uint256 remaining) {
      return allowed[_owner][_spender];
    }
    
    /* -----------------------------------------------------------------------*/
    
    /* Lock account for X amount of blocks */
    function lockAccount(uint _block) returns (bool answer){
        if (lockedAccounts[msg.sender] < block.number + _block){
            lockedAccounts[msg.sender] = block.number + _block;
            return true;
        }
        return false;
    }

    function isAccountLocked(address _accountAddress) returns (bool){
        if (lockedAccounts[_accountAddress] > block.number){
            return true;
        }
        return false;
    }
    
    ///
    /// Xaur for gas region
    ///

    /* user get small amout of wei for a small amout of Xaur */
    function getGasForXau(address _to) returns (bool sucess){
        uint256 xaurForGasLimit = dataContract.xaurForGasLimit();
        uint256 weiForXau = dataContract.weiForXau();

        if (balances[msg.sender] > xaurForGasLimit && 
            balances[xaurForGasCurrator] < balances[xaurForGasCurrator]  + xaurForGasLimit &&
            this.balance > dataContract.weiForXau()) {
            if (_to.send(dataContract.weiForXau())){
                balances[msg.sender] -= xaurForGasLimit;
                balances[xaurForGasCurrator] += xaurForGasLimit;
                return true;
            }
        } 
        return false;
    }
    
    /* Currator fills eth through this function */
    function fillGas(){
        if (msg.sender != xaurForGasCurrator) { 
            throw; 
        }
    }

    ///
    /// Melting region
    ///

    function doMelt(uint256 _xaurAmount, uint256 _goldAmount) returns (bool){
        if (msg.sender == address(meltingContract)){
            totalSupply -= _xaurAmount;
            totalGoldSupply -= _goldAmount;
            Melt(_xaurAmount, _goldAmount);
            return true;
        }
        return false;
    }
    
    ///
    /// Proxy region
    ///

    

    ///
    /// Coinage region
    ///
    function doCoinage(address[] _coinageAddresses, uint256[] _coinageAmounts, uint256 _usdAmount, uint256 _xaurCoined, uint256 _goldBought) returns (bool){
        if (msg.sender == address(coinageContract) && 
            _coinageAddresses.length == _coinageAmounts.length){
            
            totalSupply += _xaurCoined;
            totalGoldSupply += _goldBought;
            numberOfCoinages += 1;
            Coinage(numberOfCoinages, _usdAmount, _xaurCoined, _goldBought, totalGoldSupply, totalSupply);
            for (uint256 cnt = 0; cnt < _coinageAddresses.length; cnt++){
                balances[_coinageAddresses[cnt]] += _coinageAmounts[cnt]; 
            }
            return true;
        }
        return false;
    }

    ///
    /// Burining region
    ///
    function doBurn(address _from, uint256 _amountToBurn, BurningType _burningType) internal {
        balances[burningAdress] += _amountToBurn;                              // Burn the fee
        totalSupply -= _amountToBurn;                                          // Edit total supply
        Burn(_from, _amountToBurn, _burningType);                              // Notify anyone listening that this burn took place
    }

    function doBurnFromContract(address _from, uint256 _amount) returns (bool){
        if (msg.sender == address(alliesContract)){
            balances[_from] -= _amount;
            doBurn(_from, _amount, BurningType.AllyDonation);
            return true;
        }
        else if(msg.sender == address(coinageContract)){
            balances[_from] -= _amount;
            doBurn(_from, _amount, BurningType.ServiceFee);
            return true;
        }
        else{
            return false;
        }

    }

    /* This unnamed function is called whenever someone tries to send ether to it */
    function () {
        throw;     // Prevents accidental sending of ether
    }
}

contract XaurumMeltingContract {}

contract XaurumAlliesContract {}

contract XaurumCoinageContract {}

contract XaurmProxyContract{

    address public owner;
    address public curator;
    address public dev;

    function XaurmProxyContract(){
        dev = msg.sender;
    }

    function setProxyCurrator(address _newCurratorAdress) returns (bool){
        if (msg.sender == owner || msg.sender == dev){        
            curator = _newCurratorAdress;
            return true;
        }
        return false;
    }

    function setOwner(address _newOwnerAdress) returns (bool){
        if ( msg.sender == dev ){        
            owner = _newOwnerAdress;
            return true;
        }
        return false;
    }

    /* Proxy Contract */
    
    address[] approvedProxys; 
    mapping (address => bool) proxyList;
    
    /* Adds new proxy to proxy lists and grants him the permission to use transferViaProxy */
    function addNewProxy(address _proxyAdress){
        if(msg.sender == curator){
            proxyList[_proxyAdress] = true;
            approvedProxys.push(_proxyAdress);
        }
    }

    function isProxyLegit(address _proxyAddress) returns (bool){
        return proxyList[_proxyAddress];
    }
    
    function getApprovedProxys() returns (address[] proxys){
        return approvedProxys;
    }

    function () {
        throw;
    }
}

contract XaurumDataContract {

    /* Minting data */
    uint256 public xauToEur;
    uint256 public goldToEur;
    uint256 public mintingDataUpdatedAtBlock;

    /* Gas for xaur data */
    uint256 public xaurForGasLimit;
    uint256 public weiForXau;
    uint256 public gasForXaurDataUpdateAtBlock;

    /* Other data */
    uint256 public goldFee;
    uint256 public goldFeeDataUpdatedAtBlock;

    address public owner;
    address public curator;
    address public dev;

    function XaurumDataContract(){
        xaurForGasLimit = 100000000;
        weiForXau = 100000000000000000;
        goldFee = 50000000;
       // dev = _dev;
	   dev = msg.sender;
    }

    function setProxyCurrator(address _newCurratorAdress) returns (bool){
        if (msg.sender == owner || msg.sender == dev){        
            curator = _newCurratorAdress;
            return true;
        }
        return false;
    }

    function setOwner(address _newOwnerAdress) returns (bool){
        if ( msg.sender == dev ){        
            owner = _newOwnerAdress;
            return true;
        }
        return false;
    }

    function updateMintingData(uint256 _xauToEur, uint256 _goldToEur) returns (bool status){
        if (msg.sender == curator || msg.sender == dev){
            xauToEur = _xauToEur;
            goldToEur = _goldToEur;
            mintingDataUpdatedAtBlock = block.number;
            return true;
        }
        return false;
    }

    function updateGasForXaurData(uint256 _xaurForGasLimit, uint256 _weiForXau) returns (bool status){
        if (msg.sender == curator || msg.sender == dev){
            xaurForGasLimit = _xaurForGasLimit;
            weiForXau = _weiForXau;
            gasForXaurDataUpdateAtBlock = block.number;
            return true;
        }
        return false;
    }

    function updateGoldFeeData(uint256 _goldFee) returns (bool status){
        if (msg.sender == curator || msg.sender == dev){
            goldFee = _goldFee;
            goldFeeDataUpdatedAtBlock = block.number;
            return true;
        }
        return false;
    }

    function () {
        throw;
    }
}
Clone this wiki locally