0

I have developed some smart contracts and deployed/interacted with them successfully using truffle framework. However, when copying the main smart contract's address and it's ABI into myetherwallet to interact with its functions, not all functions appear although they seem to be defined correctly in the ABI. I noticed the functions that do not appear in myetherwallet, are those that call other internal functions.

For example assume we have

pragma solidity ^0.6.0;

contract DemoERC20 is X, Y, Z{

...

function balanceOf(address account) public view returns (uint256) {
    return _balances[account];
}

function transfer(address recipient, uint256 amount) public virtual returns (bool) {
    _transfer(_msgSender(), recipient, amount);
    return true;
}

function _transfer(address sender, address recipient, uint256 amount) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");

    _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
    _balances[recipient] = _balances[recipient].add(amount);
    emit Transfer(sender, recipient, amount);
}

}

Both balanceOf and transfer are defined in the ABI, but I can only see balanceOf when trying to interact with the Demo contract over Myetherwallet. This is also the same with any function defined within contracts X, Y, or Z.

  • 1
    What network have you deployed it to, and what is its address on that network? – goodvibration Mar 28 at 4:49
  • Also, it shouldn't be possible to call _foo2 from foo2, since the latter is read-only (view) and the former is not. Did you actually compile this contract? – goodvibration Mar 28 at 4:52
  • That was a mistake when writing the question. It should be virtual instead of views. Yes, I actually compiled it. I deployed it over Ropsten. – user_eth Mar 28 at 5:48
  • I have updated the question with some of the real functions. I was just trying to simplify it. – user_eth Mar 28 at 6:02
  • balanceOf is read-only, and transfer. I would imagine the MyEtherWallet shows the former in one page and the latter in another (similarly to Etherscan). Or perhaps you haven't entered your credentials, so you obviously cannot send a transaction, hence transfer is not showing. You have yet to answer my original question BTW. – goodvibration Mar 29 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.