I am trying to send the args on function from owner account but getting Returned error.
I am using web3 1.0 .
Function in contract :
/**
* @dev Adds single address to whitelist.
* @param trusted Address to be added to the whitelist
*/
function addToWhiteList(address trusted) public onlyOwner {
require(!whitelist[trusted]);
whitelist[trusted] = true;
emit UserWhitelist(true);
}
Code on index.html :
// Add user on whitelist
abc.methods.addToWhiteList("0x9DA80947ACf5Fc16299311EdAabc37fF7d201C95")
.send({ from: "0x61A44075419C4402f6DE631341d875Ece6A3922e" })
.on("receipt", function(receipt) {
console.log(receipt);
})
.on("error", function(error) {
console.error(error);
});
ERROR : Returned error: The method eth_sendTransaction does not exist/is not available
Note : I add web3 in script tag :
<script language="javascript" type="text/javascript" src="web3.min.js"></script>
and init. like this :
web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws"));
personal.unlock(owner)
sendTransaction
you have to sign your own transactions and usesendSignedTransaction
, or use a plugin like MetaMask to sign transactions.