Web3.js: The method eth_sendTransaction does not exist/is not available

Created on 17 May 2018  ·  4Comments  ·  Source: ChainSafe/web3.js

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"));

Note :

  • Node : v8.10.0
  • NPM : 5.6.0
  • OS : Ubuntu
  • Truffle v4.1.6 (core: 4.1.6)
  • Solidity v0.4.21 (solc-js)
clarification needed

Most helpful comment

Infura doesn't support sending non-raw transactions. See: https://infura.io/docs/ethereum/json-rpc/eth_sendRawTransaction

All 4 comments

Same thing happen with me on version ^1.0.0-beta.34.

Try to call .send method, this is the log :
{ jsonrpc: '2.0', id: 0, error: { code: -32601, message: 'The method eth_sendTransaction does not exist/is not available' } }

I've reproduced the same issue,web3 version: 1.0.0-beta.34, using infura ropsten as external provider.

this is after following the PKEY tip:
https://ethereum.stackexchange.com/questions/26999/invalid-json-rpc-response-error-for-sendtransaction-on-infura-ropsten-node-t

used:

this.web3.eth.accounts.wallet.add(this.pkey)

this.walletOwnerAddress = '0x'+ethUtils.privateToAddress(ethUtils.toBuffer('0x' + this.pkey)).toString('hex')

this.web3.eth.defaultAccount = this.walletOwnerAddress

this.web3.eth.sendTransaction({ to: toAddr, value: this.web3.utils.toWei("0.1", "ether") })

回退web3版本为 0.20.4。 1.0.0-beta.34版本确实有这个问题,拿用户私钥绕过钱包服务端签名也不行 ,会出现 交易哈希,但是区块链查询不到,矿工很久没有被挖矿。

demo地址 https://github.com/LinkIdol/eth-dapp-demo

Infura doesn't support sending non-raw transactions. See: https://infura.io/docs/ethereum/json-rpc/eth_sendRawTransaction

Was this page helpful?
0 / 5 - 0 ratings