Get Source

Fetches the source of a given contract. If the address is not a contract or the contract is not known to us, the call will return with a 404.

Example Request

curl -X GET \
  -H 'Content-Type: application/json' \

Example Response Observable

    "address": "0x8d31335be3be4a5f9e255e18b015961f34859323",
    "source":"pragma solidity 0.4.24;\r\n\r\nlibrary SafeMath {\r\n\r\n  function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {\r\n    if (a == 0) {\r\n      return 0;\r\n    }\r\n\r\n    c = a * b;\r\n    assert(c / a == b);\r\n    return c;\r\n  }\r\n\r\n  function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n    return a / b;\r\n  }\r\n\r\n  function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n    assert(b <= a);\r\n    return a - b;\r\n  }\r\n\r\n  function add(uint256 a, uint256 b) internal pure returns (uint256 c) {\r\n    c = a + b;\r\n    assert(c >= a);\r\n    return c;\r\n  }\r\n}\r\n\r\ncontract customIcoToken{\r\n    using SafeMath for uint256;\r\n\r\n    /* Events */\r\n    event Transfer(address indexed from, address indexed to, uint256 value);\r\n    event Approval(address indexed owner, address indexed spender, uint256 value);\r\n    event LogRefund(address indexed _to, uint256 _value);\r\n    event CreateToken(address indexed _to, uint256 _value);\r\n\r\n    // metadata\r\n    string public name;\r\n    string public symbol;\r\n    uint256 public decimals;\r\n\r\n    // contracts\r\n    address public ethFundDeposit;      // deposit address for ETH\r\n    address public tokenFundDeposit;\r\n\r\n    // crowdsale parameters\r\n    bool public isFinalized;              // switched to true in operational state\r\n    uint256 public fundingStartBlock;\r\n    uint256 public fundingEndBlock;\r\n    uint256 public tokenFund;\r\n    uint256 public tokenExchangeRate;\r\n    uint256 public tokenCreationCap;\r\n    uint256 public tokenCreationMin;\r\n\r\n    /* Storage */\r\n    mapping(address => uint256) balances;\r\n    mapping (address => mapping (address => uint256)) internal allowed;\r\n\r\n    uint256 public totalSupply;\r\n\r\n    /* Getters */\r\n    function totalSupply() public view returns (uint256) {\r\n        return totalSupply;\r\n    }\r\n\r\n    function balanceOf(address _owner) public view returns (uint256 balance) {\r\n        return balances[_owner];\r\n    }\r\n\r\n    function allowance(address _owner, address _spender) public view returns (uint256) {\r\n        return allowed[_owner][_spender];\r\n    }\r\n\r\n    /* Methods */\r\n    function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {\r\n    require(_to != address(0));\r\n    require(_value <= balances[_from]);\r\n    require(_value <= allowed[_from][msg.sender]);\r\n\r\n    balances[_from] = balances[_from].sub(_value);\r\n    balances[_to] = balances[_to].add(_value);\r\n    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);\r\n    emit Transfer(_from, _to, _value);\r\n    return true;\r\n    }\r\n\r\n    function approve(address _spender, uint256 _value) public returns (bool) {\r\n        allowed[msg.sender][_spender] = _value;\r\n        emit Approval(msg.sender, _spender, _value);\r\n        return true;\r\n    }\r\n\r\n    function increaseApproval(address _spender, uint _addedValue) public returns (bool) {\r\n        allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);\r\n        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\r\n        return true;\r\n    }\r\n\r\n    function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {\r\n        uint oldValue = allowed[msg.sender][_spender];\r\n        if (_subtractedValue > oldValue) {\r\n            allowed[msg.sender][_spender] = 0;\r\n        } else {\r\n            allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);\r\n        }\r\n        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\r\n        return true;\r\n  }\r\n\r\n    function transfer(address _to, uint256 _value) public returns (bool) {\r\n    require(_to != address(0));\r\n    require(_value <= balances[msg.sender]);\r\n\r\n    // SafeMath.sub will throw if there is not enough balance.\r\n    balances[msg.sender] = balances[msg.sender].sub(_value);\r\n    balances[_to] = balances[_to].add(_value);\r\n    emit Transfer(msg.sender, _to, _value);\r\n    return true;\r\n    }\r\n\r\n    /* Crowdsale methods */\r\n\r\n    /// @dev Accepts ether and creates new tokens.\r\n    function createTokens() payable external {\r\n      require (isFinalized == false);\r\n      require(block.number > fundingStartBlock);\r\n      require(block.number < fundingEndBlock);\r\n      require(msg.value > 0);\r\n\r\n      uint256 tokens = msg.value.mul(tokenExchangeRate);\r\n      uint256 checkedSupply = totalSupply.add(tokens);\r\n\r\n      // return money if something goes wrong\r\n      require(tokenCreationCap >= checkedSupply); // odd fractions won't be found\r\n\r\n      totalSupply = checkedSupply;\r\n      balances[msg.sender] += tokens;  // safeAdd not needed; bad semantics to use here\r\n      emit CreateToken(msg.sender, tokens);  // logs token creation\r\n    }\r\n\r\n    /// @dev Ends the funding period and sends the ETH home\r\n    function finalize() external {\r\n      require(isFinalized == false);\r\n      require(msg.sender == ethFundDeposit);\r\n      require(totalSupply > tokenCreationMin); // have to sell minimum to move to operational\r\n      require(block.number > fundingEndBlock || totalSupply == tokenCreationCap);\r\n      // move to operational\r\n      isFinalized = true;\r\n      assert(ethFundDeposit.send(address(this).balance)); // send the eth\r\n    }\r\n\r\n    /// @dev Allows contributors to recover their ether in the case of a failed funding campaign.\r\n    function refund() external {\r\n      require(isFinalized == false);                       // prevents refund if operational\r\n      require(block.number > fundingEndBlock); // prevents refund until sale period is over\r\n      require(totalSupply < tokenCreationMin); // no refunds if we sold enough\r\n      require(msg.sender != tokenFundDeposit);    // team not entitled to a refund\r\n      uint256 tokenVal = balances[msg.sender];\r\n      require(tokenVal > 0);\r\n      balances[msg.sender] = 0;\r\n      totalSupply = totalSupply.sub(tokenVal); // extra safe\r\n      uint256 ethVal = tokenVal / tokenExchangeRate; // should be safe; previous throws covers edges\r\n      emit LogRefund(msg.sender, ethVal); // log it\r\n      assert(msg.sender.send(ethVal)); // if you're using a contract; make sure it works with .send gas limits\r\n    }\r\n\r\n    constructor(\r\n        string _name,\r\n        string _symbol,\r\n        uint8 _decimals,\r\n        address _ethFundDeposit,\r\n        address _tokenFundDeposit,\r\n        uint256 _tokenFund,\r\n        uint256 _tokenExchangeRate,\r\n        uint256 _tokenCreationCap,\r\n        uint256 _tokenCreationMin,\r\n        uint256 _fundingStartBlock,\r\n        uint256 _fundingEndBlock) public\r\n    {\r\n      name = _name;\r\n      symbol = _symbol;\r\n      decimals = _decimals;\r\n      isFinalized = false;                   //controls pre through crowdsale state\r\n      ethFundDeposit = _ethFundDeposit;\r\n      tokenFundDeposit = _tokenFundDeposit;\r\n      tokenFund = _tokenFund*10**decimals;\r\n      tokenExchangeRate = _tokenExchangeRate;\r\n      tokenCreationCap = _tokenCreationCap*10**decimals;\r\n      tokenCreationMin = _tokenCreationMin*10**decimals;\r\n      fundingStartBlock = _fundingStartBlock;\r\n      fundingEndBlock = _fundingEndBlock;\r\n      totalSupply = tokenFund;\r\n      balances[tokenFundDeposit] = tokenFund;\r\n      emit CreateToken(tokenFundDeposit, tokenFund);\r\n    }\r\n}"