Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0xb6498220c9aaAD5474176B2efe134f326D0352e2
Balance 0.514000 ETH ($1092.07)
Nonce 1
Code Size 4489 bytes
Indexed Transactions 0 (1 on-chain, 0.8% indexed)
External Etherscan · Sourcify

Contract Bytecode

4489 bytes
0x606060405236156101225763ffffffff60e060020a6000350416630b97bc8681146101985780630d616d20146101bd5780631be05289146101e25780631f13076114610207578063299ed37a1461022c5780633c0679451461025357806342e94c901461027857806354fd4d50146102a957806358c62b12146103345780636c1a5b8c14610359578063720c47981461037e5780637da63c59146103ad57806387efeeb6146103d75780638da5cb5b14610406578063a8fa8e5214610435578063ad1aa2521461045a578063b3f0ca511461047f578063b60d4288146104b0578063be9a6555146104ca578063c040e6b8146104ef578063c062f57814610526578063c53adaff1461055d578063ec81b4831461058c578063f3a44fe1146105b1575b5b60015b600f5460ff16600481111561013757fe5b1480610154575060035b600f5460ff16600481111561015257fe5b145b15610167576101616105d8565b50610194565b60025b600f5460ff16600481111561017b57fe5b141561018f576101616108c2565b50610194565b600080fd5b5b5b005b34156101a357600080fd5b6101ab610a88565b60405190815260200160405180910390f35b34156101c857600080fd5b6101ab6108c2565b60405190815260200160405180910390f35b34156101ed57600080fd5b6101ab610a8e565b60405190815260200160405180910390f35b341561021257600080fd5b6101ab610a94565b60405190815260200160405180910390f35b341561023757600080fd5b61023f610a9a565b604051901515815260200160405180910390f35b341561025e57600080fd5b6101ab610b0e565b60405190815260200160405180910390f35b341561028357600080fd5b6101ab600160a060020a0360043516610b14565b60405190815260200160405180910390f35b34156102b457600080fd5b6102bc610b26565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156102f95780820151818401525b6020016102e0565b50505050905090810190601f1680156103265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561033f57600080fd5b6101ab610bc4565b60405190815260200160405180910390f35b341561036457600080fd5b6101ab610bca565b60405190815260200160405180910390f35b341561038957600080fd5b610391610bd0565b604051600160a060020a03909116815260200160405180910390f35b34156103b857600080fd5b61023f600435610bdf565b604051901515815260200160405180910390f35b34156103e257600080fd5b610391610c2e565b604051600160a060020a03909116815260200160405180910390f35b341561041157600080fd5b610391610c3d565b604051600160a060020a03909116815260200160405180910390f35b341561044057600080fd5b6101ab610c4c565b60405190815260200160405180910390f35b341561046557600080fd5b6101ab610c52565b60405190815260200160405180910390f35b341561048a57600080fd5b6101ab600160a060020a0360043516610da3565b60405190815260200160405180910390f35b6101ab6105d8565b60405190815260200160405180910390f35b34156104d557600080fd5b6101ab610db5565b60405190815260200160405180910390f35b34156104fa57600080fd5b610502610eb8565b6040518082600481111561051257fe5b60ff16815260200191505060405180910390f35b341561053157600080fd5b610502610ec1565b6040518082600481111561051257fe5b60ff16815260200191505060405180910390f35b341561056857600080fd5b610391610f47565b604051600160a060020a03909116815260200160405180910390f35b341561059757600080fd5b6101ab610f56565b60405190815260200160405180910390f35b34156105bc57600080fd5b61023f610f5c565b604051901515815260200160405180910390f35b6009546006546000918291829142039081106106525760015b600f5460ff16600481111561060257fe5b141561062257600f80546002919060ff19166001835b0217905550610652565b60035b600f5460ff16600481111561063657fe5b141561065257600f80546004919060ff19166001835b02179055505b5b5b60016003815b600f5460ff16600481111561066b57fe5b14158015610694575080600481111561068057fe5b600f5460ff16600481111561069157fe5b14155b1561069e57600080fd5b600b5434670de0b6b3a7640000028115156106b557fe5b049450600085116106c557600080fd5b60055485600c540111156106dd57600c546005540394505b600c805486019055600b54670de0b6b3a76400009086025b049350833411801561072e575033600160a060020a03166108fc8534039081150290604051600060405180830381858888f19350505050155b1561073857600080fd5b600a805485019055600160a060020a03338181166000908152600d6020908152604080832080548a019055600e90915280822080548a0190556001549093169263a9059cbb92918991516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156107c957600080fd5b6102c65a03f115156107da57600080fd5b5050506040518051905015156107ef57600080fd5b60015b600f5460ff16600481111561080357fe5b141561082a57600754600c541061082a57600f80546003919060ff19166001835b02179055505b5b60035b600f5460ff16600481111561083f57fe5b141561086757600554600c54141561086757600f80546004919060ff19166001835b02179055505b5b610870611141565b33600160a060020a03167ffa35a310d7113dddce1c275da946348e9aaebf9050b00b372033c4d84b0bd6eb858760405191825260208201526040908101905180910390a28495505b5b50505b50505090565b60095460065460009182918291420390811061093c5760015b600f5460ff1660048111156108ec57fe5b141561090c57600f80546002919060ff19166001835b021790555061093c565b60035b600f5460ff16600481111561092057fe5b141561093c57600f80546004919060ff19166001835b02179055505b5b5b6002805b600f5460ff16600481111561095357fe5b1461095d57600080fd5b600160a060020a03338181166000908152600e60205260408082208054908390556001546008549199508516946323b872dd9493911691899190516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156109eb57600080fd5b6102c65a03f115156109fc57600080fd5b505050604051805190501515610a1157600080fd5b600160a060020a0333166000908152600d60205260408120805490829055600a805482900390559350831115610a7257600160a060020a03331683156108fc0284604051600060405180830381858888f193505050501515610a7257600080fd5b5b610a7b611141565b8294505b5b505b50505090565b60095481565b60065481565b600c5481565b600030600160a060020a031631600a541115610b0757600030600160a060020a031631118015610af55750600354600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050155b15610aff57600080fd5b506001610b0b565b5060005b90565b600a5481565b600d6020526000908152604090205481565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bbc5780601f10610b9157610100808354040283529160200191610bbc565b820191906000526020600020905b815481529060010190602001808311610b9f57829003601f168201915b505050505081565b60045481565b60075481565b600254600160a060020a031681565b60085460009033600160a060020a03908116911614610bfd57600080fd5b6000805b600f5460ff166004811115610c1257fe5b14610c1c57600080fd5b600b839055600191505b5b505b919050565b600154600160a060020a031681565b600854600160a060020a031681565b600b5481565b60008060006009544203905060065481101515610ccd5760015b600f5460ff166004811115610c7d57fe5b1415610c9d57600f80546002919060ff19166001835b0217905550610ccd565b60035b600f5460ff166004811115610cb157fe5b1415610ccd57600f80546004919060ff19166001835b02179055505b5b5b6002805b600f5460ff166004811115610ce457fe5b14610cee57600080fd5b600c54600554039250600083118015610d855750600154600854600160a060020a039182169163a9059cbb91168560006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610d6857600080fd5b6102c65a03f11515610d7957600080fd5b50505060405180519050155b15610d8f57600080fd5b610d97611141565b8293505b5b505b505090565b600e6020526000908152604090205481565b60085460009033600160a060020a03908116911614610dd357600080fd5b6000805b600f5460ff166004811115610de857fe5b14610df257600080fd5b600154600554600160a060020a03909116906323b872dd903390309060006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b1515610e6657600080fd5b6102c65a03f11515610e7757600080fd5b505050604051805190501515610e8c57600080fd5b42600955600f80546001919060ff191682805b0217905550610eac611141565b60095491505b5b505b90565b600f5460ff1681565b6009546006546000914203908110610f375760015b600f5460ff166004811115610ee757fe5b1415610f0757600f80546002919060ff19166001835b0217905550610f37565b60035b600f5460ff166004811115610f1b57fe5b1415610f3757600f80546004919060ff19166001835b02179055505b5b5b600f5460ff1691505b5b5090565b600354600160a060020a031681565b60055481565b60008060008060006009544203905060065481101515610fda5760015b600f5460ff166004811115610f8a57fe5b1415610faa57600f80546002919060ff19166001835b0217905550610fda565b60035b600f5460ff166004811115610fbe57fe5b1415610fda57600f80546004919060ff19166001835b02179055505b5b5b6004805b600f5460ff166004811115610ff157fe5b14610ffb57600080fd5b600a80546000918290559550851161101257600080fd5b60045460649086025b6002549190049450600160a060020a031684860380156108fc0290604051600060405180830381858888f19350505050151561105657600080fd5b600354600160a060020a031684156108fc0285604051600060405180830381858888f19350505050151561108957600080fd5b600c546005540392506000831180156111205750600154600854600160a060020a039182169163a9059cbb91168560006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561110357600080fd5b6102c65a03f1151561111457600080fd5b50505060405180519050155b1561112a57600080fd5b611132611141565b600195505b5b505b5050505090565b30600160a060020a031631600a54111561115a57600080fd5b5b5600a165627a7a723058208b81003276feed36b8c7132b62d3d688315295f625da832898a0f1940b2d51ee0029

Verified Source Code Partial Match

Compiler: v0.4.15+commit.bbb8e64f Optimization: Yes (200 runs)
SingularDTVLaunch.sol 357 lines
pragma solidity ^0.4.15;


contract Token {
    /* This is a slight change to the ERC20 base standard.
    function totalSupply() constant returns (uint256 supply);
    is replaced with:
    uint256 public totalSupply;
    This automatically creates a getter function for the totalSupply.
    This is moved to the base contract since public getter functions are not
    currently recognised as an implementation of the matching abstract
    function by the compiler.
    */
    /// total amount of tokens
    uint256 public totalSupply;

    /// @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 `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens 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 AbstractSingularDTVToken is Token {

}


/// @title Token Creation contract - Implements token creation functionality.
/// @author Stefan George - <[email protected]>
/// @author Razvan Pop - <[email protected]>
/// @author Milad Mostavi - <[email protected]>
contract SingularDTVLaunch {
    string public version = "0.1.0";

    event Contributed(address indexed contributor, uint contribution, uint tokens);

    /*
     *  External contracts
     */
    AbstractSingularDTVToken public singularDTVToken;
    address public workshop;
    address public SingularDTVWorkshop = 0xc78310231aA53bD3D0FEA2F8c705C67730929D8f;
    uint public SingularDTVWorkshopFee;

    /*
     *  Constants
     */
    uint public CAP; // in wei scale of tokens
    uint public DURATION; // in seconds
    uint public TOKEN_TARGET; // Goal threshold in wei scale of tokens

    /*
     *  Enums
     */
    enum Stages {
        Deployed,
        GoingAndGoalNotReached,
        EndedAndGoalNotReached,
        GoingAndGoalReached,
        EndedAndGoalReached
    }

    /*
     *  Storage
     */
    address public owner;
    uint public startDate;
    uint public fundBalance;
    uint public valuePerToken; //in wei
    uint public tokensSent;

    // participant address => value in Wei
    mapping (address => uint) public contributions;

    // participant address => token amount in wei scale
    mapping (address => uint) public sentTokens;

    // Initialize stage
    Stages public stage = Stages.Deployed;

    modifier onlyOwner() {
        // Only owner is allowed to do this action.
        if (msg.sender != owner) {
            revert();
        }
        _;
    }

    modifier atStage(Stages _stage) {
        if (stage != _stage) {
            revert();
        }
        _;
    }

    modifier atStageOR(Stages _stage1, Stages _stage2) {
        if (stage != _stage1 && stage != _stage2) {
            revert();
        }
        _;
    }

    modifier timedTransitions() {
        uint timeElapsed = now - startDate;

        if (timeElapsed >= DURATION) {
            if (stage == Stages.GoingAndGoalNotReached) {
                stage = Stages.EndedAndGoalNotReached;
            } else if (stage == Stages.GoingAndGoalReached) {
                stage = Stages.EndedAndGoalReached;
            }
        }
        _;
    }

    /*
     *  Contract functions
     */
    /// dev Validates invariants.
    function checkInvariants() constant internal {
        if (fundBalance > this.balance) {
            revert();
        }
    }

    /// @dev Can be triggered if an invariant fails.
    function emergencyCall()
        public
        returns (bool)
    {
        if (fundBalance > this.balance) {
            if (this.balance > 0 && !SingularDTVWorkshop.send(this.balance)) {
                revert();
            }
            return true;
        }
        return false;
    }

    /// @dev Allows user to create tokens if token creation is still going and cap not reached. Returns token count.
    function fund()
        public
        timedTransitions
        atStageOR(Stages.GoingAndGoalNotReached, Stages.GoingAndGoalReached)
        payable
        returns (uint)
    {
        uint tokenCount = (msg.value * (10**18)) / valuePerToken; // Token count in wei is rounded down. Sent ETH should be multiples of valuePerToken.
        require(tokenCount > 0);
        if (tokensSent + tokenCount > CAP) {
            // User wants to create more tokens than available. Set tokens to possible maximum.
            tokenCount = CAP - tokensSent;
        }
        tokensSent += tokenCount;

        uint contribution = (tokenCount * valuePerToken) / (10**18); // Ether spent by user.
        // Send change back to user.
        if (msg.value > contribution && !msg.sender.send(msg.value - contribution)) {
            revert();
        }
        // Update fund and user's balance and total supply of tokens.
        fundBalance += contribution;
        contributions[msg.sender] += contribution;
        sentTokens[msg.sender] += tokenCount;
        if (!singularDTVToken.transfer(msg.sender, tokenCount)) {
            // Tokens could not be issued.
            revert();
        }
        // Update stage
        if (stage == Stages.GoingAndGoalNotReached) {
            if (tokensSent >= TOKEN_TARGET) {
                stage = Stages.GoingAndGoalReached;
            }
        }
        // not an else clause for the edge case that the CAP and TOKEN_TARGET are reached in one call
        if (stage == Stages.GoingAndGoalReached) {
            if (tokensSent == CAP) {
                stage = Stages.EndedAndGoalReached;
            }
        }
        checkInvariants();

        Contributed(msg.sender, contribution, tokenCount);

        return tokenCount;
    }

    /// @dev Allows user to withdraw ETH if token creation period ended and target was not reached. Returns contribution.
    function withdrawContribution()
        public
        timedTransitions
        atStage(Stages.EndedAndGoalNotReached)
        returns (uint)
    {
        // We get back the tokens from the contributor before giving back his contribution
        uint tokensReceived = sentTokens[msg.sender];
        sentTokens[msg.sender] = 0;
        if (!singularDTVToken.transferFrom(msg.sender, owner, tokensReceived)) {
            revert();
        }

        // Update fund's and user's balance and total supply of tokens.
        uint contribution = contributions[msg.sender];
        contributions[msg.sender] = 0;
        fundBalance -= contribution;
        // Send ETH back to user.
        if (contribution > 0) {
            msg.sender.transfer(contribution);
        }
        checkInvariants();
        return contribution;
    }

    /// @dev Withdraws ETH to workshop address. Returns success.
    function withdrawForWorkshop()
        public
        timedTransitions
        atStage(Stages.EndedAndGoalReached)
        returns (bool)
    {
        uint value = fundBalance;
        fundBalance = 0;

        require(value > 0);

        uint networkFee = value * SingularDTVWorkshopFee / 100;
        workshop.transfer(value - networkFee);
        SingularDTVWorkshop.transfer(networkFee);

        uint remainingTokens = CAP - tokensSent;
        if (remainingTokens > 0 && !singularDTVToken.transfer(owner, remainingTokens)) {
            revert();
        }

        checkInvariants();
        return true;
    }

    /// @dev Allows owner to get back unsent tokens in case of launch failure (EndedAndGoalNotReached).
    function withdrawUnsentTokensForOwner()
        public
        timedTransitions
        atStage(Stages.EndedAndGoalNotReached)
        returns (uint)
    {
        uint remainingTokens = CAP - tokensSent;
        if (remainingTokens > 0 && !singularDTVToken.transfer(owner, remainingTokens)) {
            revert();
        }

        checkInvariants();
        return remainingTokens;
    }

    /// @dev Sets token value in Wei.
    /// @param valueInWei New value.
    function changeValuePerToken(uint valueInWei)
        public
        onlyOwner
        atStage(Stages.Deployed)
        returns (bool)
    {
        valuePerToken = valueInWei;
        return true;
    }

    // updateStage allows calls to receive correct stage. It can be used for transactions but is not part of the regular token creation routine.
    // It is not marked as constant because timedTransitions modifier is altering state and constant is not yet enforced by solc.
    /// @dev returns correct stage, even if a function with timedTransitions modifier has not yet been called successfully.
    function updateStage()
        public
        timedTransitions
        returns (Stages)
    {
        return stage;
    }

    function start()
        public
        onlyOwner
        atStage(Stages.Deployed)
        returns (uint)
    {
        if (!singularDTVToken.transferFrom(msg.sender, this, CAP)) {
            revert();
        }

        startDate = now;
        stage = Stages.GoingAndGoalNotReached;

        checkInvariants();
        return startDate;
    }

    /// @dev Contract constructor function sets owner and start date.
    function SingularDTVLaunch(
        address singularDTVTokenAddress,
        address _workshop,
        address _owner,
        uint _total,
        uint _unit_price,
        uint _duration,
        uint _threshold,
        uint _singulardtvwoskhop_fee
        ) {
        singularDTVToken = AbstractSingularDTVToken(singularDTVTokenAddress);
        workshop = _workshop;
        owner = _owner;
        CAP = _total; // Total number of tokens (wei scale)
        valuePerToken = _unit_price; // wei per token
        DURATION = _duration; // in seconds
        TOKEN_TARGET = _threshold; // Goal threshold
        SingularDTVWorkshopFee = _singulardtvwoskhop_fee;
    }

    /// @dev Fallback function acts as fund() when stage GoingAndGoalNotReached
    /// or GoingAndGoalReached. And act as withdrawFunding() when EndedAndGoalNotReached.
    /// otherwise throw.
    function ()
        public
        payable
    {
        if (stage == Stages.GoingAndGoalNotReached || stage == Stages.GoingAndGoalReached)
            fund();
        else if (stage == Stages.EndedAndGoalNotReached)
            withdrawContribution();
        else
            revert();
    }
}

Write Contract 24 functions

These functions modify contract state and require a wallet transaction to execute.

CAP 0xec81b483
No parameters
returns: uint256
DURATION 0x1be05289
No parameters
returns: uint256
SingularDTVWorkshop 0xc53adaff
No parameters
returns: address
SingularDTVWorkshopFee 0x58c62b12
No parameters
returns: uint256
TOKEN_TARGET 0x6c1a5b8c
No parameters
returns: uint256
changeValuePerToken 0x7da63c59
uint256 valueInWei
returns: bool
contributions 0x42e94c90
address
returns: uint256
emergencyCall 0x299ed37a
No parameters
returns: bool
fund 0xb60d4288
No parameters
returns: uint256
fundBalance 0x3c067945
No parameters
returns: uint256
owner 0x8da5cb5b
No parameters
returns: address
sentTokens 0xb3f0ca51
address
returns: uint256
singularDTVToken 0x87efeeb6
No parameters
returns: address
stage 0xc040e6b8
No parameters
returns: uint8
start 0xbe9a6555
No parameters
returns: uint256
startDate 0x0b97bc86
No parameters
returns: uint256
tokensSent 0x1f130761
No parameters
returns: uint256
updateStage 0xc062f578
No parameters
returns: uint8
valuePerToken 0xa8fa8e52
No parameters
returns: uint256
version 0x54fd4d50
No parameters
returns: string
withdrawContribution 0x0d616d20
No parameters
returns: uint256
withdrawForWorkshop 0xf3a44fe1
No parameters
returns: bool
withdrawUnsentTokensForOwner 0xad1aa252
No parameters
returns: uint256
workshop 0x720c4798
No parameters
returns: address

Recent Transactions

This address has 1 on-chain transactions, but only 0.8% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →