Not able to verify SmartContract

Hello @abcoathup ,

i am trying to verify my contract. i followed step by step from the below tutorial but still got failed to verify.

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract MulaToken is ERC20, Ownable {

token address on rinkeby 0x78103a25ECeB14Cc8041e3938f6E0C837443574c

cc: @Skyge :grinning:

thanks for your help in advance.!

So what is your compiler version and could you please share the full source code?

i am using truffle version 5.4.0, solidity 0.8.0 and truffle-plugin-verify :0.5.11

and below is my complete code

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract MulaToken is ERC20, Ownable {
    using SafeMath for uint256;
    uint256 totalSupply = 100 * 10**6 * (10 ** uint256(decimals()));
    /** If false we are are in transfer lock up period.*/
    bool public released = false;
    /**Only the crowdsale address can make transfer during the lock up period */
    address public crowdsale;
    uint256 firstListingDate;
    struct lockAllowance{
        uint256 total; uint256 allowance; uint256 spent; uint lockStage;
    }
    mapping(address => lockAllowance) lockAllowances;
    mapping(address => bool) public earlyInvestors;
    

    /** Limit token transfer until the lockup period is over.*/
    modifier canTransfer() {
        if(!released) {
            require(crowdsale == msg.sender,"you are not permitted to make transactions");
        }
        _;
    }
    modifier onlyCrowdSale() {
        require(crowdsale == msg.sender,"you are not permitted to make transactions");
        _;
    }
    modifier investorChecks(uint256 _value){
        if(firstListingDate + 30 days < block.timestamp ){
            if(earlyInvestors[msg.sender]){
                updateLockAllownces();
                lockAllowance storage lock = lockAllowances[msg.sender];
                require(lock.spent <= _value);
                updateLockSpent(_value);
            }
        }
        _;
    }
    
    constructor() ERC20("Mula Token", "MULA") {
        _mint(msg.sender, totalSupply);
    }
    /** Allow only the crowdsale address to relase the tokens into the wild */
    function releaseTokenTransfer() onlyCrowdSale() public {
            released = true;       
    }
    /**Set the crowdsale address. **/
    function setReleaser(address _crowdsale) onlyOwner public {
        crowdsale = _crowdsale;
    }
    function addToLock(uint256 _total,address _investor)public onlyCrowdSale(){
        if(!earlyInvestors[_investor]){
            lockAllowance memory lock;
            lock.total = _total;
            lock.allowance = 0;
            lock.spent = 0;
            lockAllowances[_investor] = lock;
            earlyInvestors[_investor]=true;
        }else{
            updateLockTotal(_total);
        }
        
    }
    function updateLockTotal(uint256 _total) internal returns(bool){
        lockAllowance storage lock = lockAllowances[msg.sender];
        lock.spent = lock.total + _total;
        //emit LogVaultWithdrawal(msg.sender, amount);
        return true;
    }
    function updateLockSpent(uint256 _spent) internal returns(bool){
        lockAllowance storage lock = lockAllowances[msg.sender];
        lock.spent = lock.spent + _spent;
        //emit LogVaultWithdrawal(msg.sender, amount);
        return true;
    }
    function updateLockAllownces() internal returns (bool){
        lockAllowance storage lock = lockAllowances[msg.sender];
        if(firstListingDate + 7 days >= block.timestamp && firstListingDate + 13 days <= block.timestamp){
            if(lock.lockStage < 1){
                lock.allowance = (lock.total.mul(50 *100)).div(10000);
                lock.lockStage = 1;
            }
            //first allowance 
        }else if(firstListingDate + 14 days >= block.timestamp && firstListingDate + 29 days <= block.timestamp){
            //second allowance
            if(lock.lockStage == 1){
                lock.allowance = (lock.total.mul(70 *100)).div(10000);
                lock.lockStage = 2;
            }
        }
        
        return true; 
    }
    function transfer(address _to, uint256 _value) canTransfer() investorChecks(_value) public override returns (bool success) {
        super.transfer(_to,_value);
        return true;
    }

}
1 Like

I am not sure, but when I ran truffle compile, I got an error.
What is the version of the @openzeppelin/contracts in your package.json file?

here you go

@openzeppelin/contracts”: “^4.1.0”,

when i compiled i got an error with this error

Screenshot 2021-07-17 at 10.52.02

so i changed the variable name in totalSupply to tSupply
here

uint256 totalSupply = 100 * 10**6 * (10 ** uint256(decimals()));

and here

 constructor() ERC20("Mula Token", "MULA") {
        _mint(msg.sender, totalSupply);
    }

i ran the compile command and it was successful.

So the contract you shared above was not the original code that you deployed, right?