Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error: Type contract pSDATokenSale is not implicitly convertible to expected type contract pSDA

Type contract pSDATokenSale is not implicitly convertible to expected type contract pSDA.

I am getting the error above ^^ at the line with tokenContract = _tokenContract;. Any suggestions as to why this is happening and how to fix it?

pragma solidity ^0.8.12;

import "./pSDAToken.sol";


contract pSDATokenSale {
    address admin;
    pSDA public tokenContract;
    uint256 public tokenPrice;
    uint256 public tokensSold;

    event Sell(address _buyer, uint256 _amount);

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

ehy
you wrote wrong the type of _tokenContract inside the function pSDAToken()

you wrote _tokenContract with type pSDATokenSale, and want to save it inside tokenContract that is pSDA type

this is the correct code:

pragma solidity ^0.8.12;

import "./pSDAToken.sol";


contract pSDATokenSale {
    address admin;
    pSDA public tokenContract;
    uint256 public tokenPrice;
    uint256 public tokensSold;

    event Sell(address _buyer, uint256 _amount);

    function pSDAToken(pSDA _tokenContract, uint256 _tokenPrice)
        public
    {
        admin = msg.sender;
        tokenContract = _tokenContract;
        tokenPrice = _tokenPrice;
    }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading