这是我的javascript代码:我要发送给它的地址是来自app上用户的输入地址。调用方(当前选择的元问询地址有足够的ERC20令牌)
lookupVoterInfo: function() {
let toAddress = $("#voter-info").val();
Voting.deployed().then(function(contractInstance) {
contractInstance.transfer(toAddress, 10);
})MyERC20合同:
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "../openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import "../openzeppelin-contracts/contracts/math/SafeMath.sol";
contract MyERC20 is ERC20 {
uint256 public INITIAL_SUPPLY = 20000;
constructor() ERC20("MyToken", "MYT") {
_mint(msg.sender, INITIAL_SUPPLY);
}
}错误信息:

发布于 2022-01-16 02:17:55
我通过以下操作解决了这个问题:您需要指定煤气费和帐户地址。
contractInstance.approve(web3.currentProvider.selectedAddress,100,{gas: 1000000,出发地:web3.eth.accounts};contractInstance.transferFrom(web3.currentProvider.selectedAddress,toAddress,10,{gas: 1000000,出发地: web3.eth.accounts});
https://stackoverflow.com/questions/70709275
复制相似问题