what is contract type in solidity and what is the use of it

by md venkatesh   Last Updated November 15, 2018 14:28 PM

    contract DappToken {
        string  public name = "MDV";
        string  public symbol = "$$$";
        string  public standard = "DApp Token v1.0";
        uint256 public totalSupply;
        // having more code 
    }

I have Imported the These contract in my next file and used the the contract name as the name of the variable

contract DappTokenSale {
    address admin;
    **DappToken public tokenContract;**
    uint256 public tokenPrice;
    uint256 public tokensSold;

function DappTokenSale(DappToken _tokenContract, uint256 _tokenPrice) public {
    admin = msg.sender;
    tokenContract = _tokenContract;
    tokenPrice = _tokenPrice;
}
}

In migrations we passed the the addess of the deployed contract to the token contract

function DappTokenSale(DappToken _tokenContract, uint256 _tokenPrice) public {
    admin = msg.sender;
    tokenContract = _tokenContract;
    tokenPrice = _tokenPrice;
}

1) Why do we even have to declare a varable a contract type here

2) We know it is the address we are going to pass so why can't we declare a address type insted of contract type

3) What is diffrence between defining a varble a contract type and some data type

4) I have observed the same behaviour in interface defining the interface type before the varable initlization



Related Questions


fallback function is accepting more than 2300 gas

Updated February 22, 2018 08:28 AM


Fallback function in web3

Updated July 31, 2017 10:28 AM


What does Solidity's "call" function mean?

Updated September 25, 2017 02:28 AM