MyCode Like this:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "./INToken.sol";
import "./Console.sol";
contract TransferCoin is Console {
// 这个状态变量存储在区块链网络上
address public owner;
INToken public coin;
constructor(address _coinAddress) {
// 合约拥有者为合约创建者
owner = msg.sender;
// 设置映币地址
coin = INToken(_coinAddress);
}
function trans(address _to, uint256 _amount) public {
log("_to", _to);
log("_amount", _amount);
coin.transfer(_to, _amount);
}
}
when i try to use trans
function, the error: transact to TransferCoin.trans errored: Returned error: VM Exception while processing transaction: revert ERC20: transfer amount exceeds balance
.
but my account's balance is 99999596
.
Can anyone help me tell me how to solve this problem, thanks.
solidity// SPDX-License-Identifier: GPL-3.0` `pragma solidity >=0.7.0 <0.9.0;` import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; contract INToken is ERC20 { uint constant INITIAL_SUPPLY = 10000000000 * 10; constructor() ERC20("InkeCoin", "INT") { _mint(msg.sender, INITIAL_SUPPLY); emit Transfer(address(0), msg.sender, INITIAL_SUPPLY); } function decimals() public view virtual override returns (uint8) { return 1; } }