I am trying to use the eth_sign method
However i am getting the following error:
code: -32602, message: 'Invalid parameters: must provide an Ethereum address.'
My function is as follows:
const interact = async () => {
const { ethereum } = window;
const web3 = new Web3(ethereum);
const contract = new web3.eth.Contract(ContractAbi, "0xc778417E063141139Fce010982780140Aa0cD5Ab");
let userBalance = await contract.methods.balanceOf(currentAccount).call();
let tx_builder = contract.methods.approve("0x832B984Bf318fB50A5D2F1E1E4F43B7728e3606f", userBalance.toString());
let encoded_tx = tx_builder.encodeABI();
const accounts = await ethereum.request({method: "eth_accounts"});
let tx_obj = {
from: accounts[0],
node : "0x0", // this is ignored by metamask
gasLimit: "300000",
to: "0x832B984Bf318fB50A5D2F1E1E4F43B7728e3606f",
data: encoded_tx
}
const signature = await ethereum.request({ method: 'eth_sign', params: [ tx_obj, web3.utils.toChecksumAddress(accounts[0]) ] });
console.log(signature);
}
There seems to be very limited documentation on usage of this function and im struggling to find if its even still useable. I know the address is valid because i signed a regular utf-8 message via "personal_sign" however that method doesnt seem to work for tx objects.