Javascript inpage.js:1未捕获错误:无效地址

Javascript inpage.js:1未捕获错误:无效地址,javascript,transactions,ethereum,web3js,Javascript,Transactions,Ethereum,Web3js,这是我的合同 pragma solidity ^0.5.11; contract test{ mapping(string => address payable) pizzaPlace; address contractOwner; address payable userWallet; constructor() public{ contractOwner=msg.sender; pizzaPlace["piaazOne"]=0xd806F6b4888ff997dB4A0

这是我的合同

pragma solidity ^0.5.11;
contract test{
mapping(string => address payable) pizzaPlace;
address contractOwner;
address payable userWallet;
constructor() public{
    contractOwner=msg.sender;
    pizzaPlace["piaazOne"]=0xd806F6b4888ff997dB4A073fD9EdD40ab92BCbD4;
}
function paymentHandlerer() public payable returns(bool){
        userWallet = pizzaPlace["pizzaOne"];
        userWallet.transfer(msg.value);
        return true;
}
function showMessage() public view returns(string memory){
    return "Hello Solidity";
}
我已经学习了一段时间的稳固性,但这似乎是我没有解决的问题。 上面的合同是用remix编写的,我正在本地机器上使用Ganache部署合同

以下是我的函数调用代码:

const contractAddress = '0xEe1C4287b37de1ADFE2aD78C7B7c96D7694093cb';
const contractAbi=[...];
var contract = web3.eth.contract(contractAbi).at(contractAddress);
contract.showMessage(function (error, message) {
    $("#targetText").html(message);
});
const btn = document.querySelector("#sendEtherBtn");
btn.addEventListener("click", function () {
contract.paymentHandlerer(
{"to":contractAddress,
 "from":web3.eth.accounts[0],
 "value":web3.toWei("10.0","ether")
});
});
当我运行此代码时。当我在浏览器屏幕上看到消息“Hello Solidity”时,会调用函数showMessage()。这证明合同运行良好。在第二个函数中,我想将一些乙醚从msg.sender传输到接收方,但该函数始终出错

错误如下所示:

Uncaught Error: invalid address
at c (inpage.js:1)
at inputTransactionFormatter (inpage.js:1)
at inpage.js:1
at Array.map (<anonymous>)
at o.formatInput (inpage.js:1)
at o.toPayload (inpage.js:1)
at w.e [as sendTransaction] (inpage.js:1)
at u.sendTransaction (inpage.js:1)
at u.execute (inpage.js:1)
at HTMLButtonElement.<anonymous> (index.html:101)
未捕获错误:地址无效
在c(inpage.js:1)
在inputTransactionFormatter(inpage.js:1)
在inpage.js:1
在Array.map()处
在o.formatInput(inpage.js:1)
在o.toPayload时(inpage.js:1)
在w.e[as sendTransaction](inpage.js:1)
at u.sendTransaction(inpage.js:1)
在u.execute(inpage.js:1)
在HTMLButtoneElement。(index.html:101)
谁能帮我解决这个问题。
另外,我没有使用node js或任何纯js和JQuery,在
Web3.js
v1.0中,
Web3.eth.accounts
默认情况下不填充

相反,您需要使用以下方式获取帐户:

web3.eth.getAccounts().then(console.log);
>[“0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe”,“0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf”]

那么我应该使用什么来触发函数调用而不使用任何errors@SurajShrestha通过调用
web3.eth.getAccounts()
而不是使用
web3.eth.accounts[0]
设置
from
字段来获取地址