Hi,
I guess this correctly path as examine on the github sample codes. Have a any another way, can you share? I am new in contract development too.
I couldn't get any token on localhost I am using ganache (Is there any way for this?), I switched to ropsten for testing.
//SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.1;
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol';
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol';
contract InterTest {
using SafeERC20 for IERC20;
function getOwnerTokenBalance(address currency, address owner) public view returns(uint256){
if(currency == address(0)){
return address(owner).balance;
}else{
uint256 balance = IERC20(currency).balanceOf(address(owner));
return balance;
}
}
}
I have tested on the Remix. I added sample token to my MetaMask wallet on ropsten network and it is automatically setted 0. But I couldn't get balance that this token.
I getted error like this call to InterTest.getOwnerTokenBalance errored: execution reverted
.
What is problem?
Thank you for interest.
Good works..