same contract from ropsten to main fail?

thomasgthomasg Member Posts: 6
Hi,

I am having a problem with creating the contract. I had created contract on test network and it seemed to work there. But after I deploy on main network, when I look at read contract everything is show at 0? Is this normal?

Comments

  • thomasgthomasg Member Posts: 6
    Is this forum dead?
  • iosmaniosman Member Posts: 5
    I didn't find any issue while creating this contact hope you will get a solution in upcoming days.
  • thomasgthomasg Member Posts: 6
    Is there a test network that behaves the same like main network. As it is kind of stupid to have a test network that behaves different than the main network imho.
  • thomasgthomasg Member Posts: 6
    This is my contract code. I had tested this in ropsten and it was working, but I tried deploying the exact same on main, and it shows up with all 0 in readcontract ...
    pragma solidity ^0.4.24;
    
    library SafeMath {
        
        function add(uint a, uint b) internal pure returns (uint c) {
            c = a + b;
            require(c >= a);
        }
        function sub(uint a, uint b) internal pure returns (uint c) {
            require(b <= a);
            c = a - b;
        }
        function mul(uint a, uint b) internal pure returns (uint c) {
            c = a * b;
            require(a == 0 || c / a == b);
        }
        function div(uint a, uint b) internal pure returns (uint c) {
            require(b > 0);
            c = a / b;
        }
    }
    
    contract ERC20Interface {
        
        function totalSupply() public constant returns (uint);
        function balanceOf(address tokenOwner) public constant returns (uint balance);
        function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
        function transfer(address to, uint tokens) public returns (bool success);
        function approve(address spender, uint tokens) public returns (bool success);
        function transferFrom(address from, address to, uint tokens) public returns (bool success);
    
        event Transfer(address indexed from, address indexed to, uint tokens);
        event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
    }
    
    contract Owned {
        
        address public owner;
        address public newOwner;
    
        event OwnershipTransferred(address indexed _from, address indexed _to);
    
        constructor() public {
            owner = msg.sender;
        }
    
        modifier onlyOwner {
            require(msg.sender == owner);
            _;
        }
    
        function transferOwnership(address _newOwner) public onlyOwner {
            newOwner = _newOwner;
        }
        function acceptOwnership() public {
            require(msg.sender == newOwner);
            emit OwnershipTransferred(owner, newOwner);
            owner = newOwner;
            newOwner = address(0);
        }
    }
    
    contract Crowdsale is Owned{
    
      	using SafeMath for uint256;
      	
      	ERC20Interface private token;
      	
      	uint256 public weiRaised;
    	
    	address public wallet;
    	
    	bool isCrowdsalePaused = false;
    	
    	uint256 public rate;
    	
    	uint256 public cap;
    	
    	uint8 public decimals;
    	
    	event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
    
    	constructor() public {
    		wallet = 0x00000000000000000000000000000000000000;
    		token = ERC20Interface(0x00000000000000000000000000);
    		decimals = 18;
    	 	cap = 20000 * 10**uint(decimals);
        	rate = 1000;
        	require(wallet != address(0));
    		require(token != address(0));
    		require(cap > 0);
    		require(rate > 0);
    	}
    	
    	function () external payable {
        	buyTokens(msg.sender);
     	}
     	
     	function buyTokens(address beneficiary) public payable {
     	
       		require(beneficiary != 0x0);
    
    	    uint256 amount = msg.value;
    	    
    	    require(isCrowdsalePaused == false);
    	    
    	    require(weiRaised.add(amount) <= cap);
    
        	uint256 tokens = getTokenAmount(amount);
    
        	weiRaised = weiRaised.add(amount);
    
        	processPurchase(beneficiary, tokens);
        	
    		emit TokenPurchase(msg.sender, beneficiary, amount, tokens);
    
        	forwardFunds();
        	
    	}
    	
    	function rate() public view returns(uint256){
    		return rate;
    	}
    	
    	function weiRaised() public view returns (uint256) {
        	return weiRaised;
    	}
    	
    	function deliverTokens(address beneficiary,uint256 tokenAmount) internal{
    		token.transferFrom(wallet, beneficiary, tokenAmount);
    	}
    	
    	function processPurchase(address beneficiary,uint256 tokenAmount) internal{
    		deliverTokens(beneficiary, tokenAmount);
    	}
    
    	function getTokenAmount(uint256 amount) internal view returns (uint256){
        	return rate.mul(amount);
      	}
      	
      	function forwardFunds() internal {
    		wallet.transfer(msg.value);
    	}
    	
    	function remainingTokens() public view returns (uint256) {
    		return token.allowance(wallet, this);
    	}
    
    	function capReached() public view returns (bool) {
    		return weiRaised >= cap;
    	}
    	
    	function pauseCrowdsale() public onlyOwner {
            isCrowdsalePaused = true;
        }
        
        function resumeCrowdsale() public onlyOwner {
            isCrowdsalePaused = false;
        }
        
        function takeTokensBack() public onlyOwner {
             uint remainingTokensInTheContract = token.balanceOf(address(this));
             token.transfer(owner,remainingTokensInTheContract);
        }
    }
  • thomasgthomasg Member Posts: 6
    When I checked the contract on etherscan a day later. It showed up correct....
Sign In or Register to comment.