When I try to send EHT using the below code, the transaction executes, but 0 EHT is sent:
const getEthereumContract = () => {
// const provider = new ethers.provider.Web3Provider(ethereum);
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = provider.getSigner();
const transactionContract = new ethers.Contract(
contractAddress,
contractABI,
signer
);
console.log({ provider, signer, transactionContract });
return transactionContract;
};
const sendTransaction = async () => {
try {
if (!ethereum) return alert("Please install metamsak");
const { addressTo, amount, keyword, message } = formData;
// getEthereumContract();
const transactionContract = getEthereumContract();
// const parsedAmount = ethers.utils.parseEther(amount);
const parsedAmount = ethers.parseEther(amount);
console.log(
" ~ file: TransactionContext.jsx:71 ~ sendTransaction ~ amount:",
amount
);
await ethereum.request({
method: "eth_sendTransaction",
params: [
{
from: currentAccount,
to: addressTo,
gas: "0x5208",
value: parsedAmount._hex,
},
],
});
I see the follwing error in the browser console:
Error: contract runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.6.0)
at makeError (errors.ts:677:21)
at assert (errors.ts:694:25)
at send (contract.ts:288:9)
at Proxy.addToBlockchain (contract.ts:330:22)
at sendTransaction (TransactionContext.jsx:88:57)
TransactionContext.jsx:104 Uncaught (in promise) Error: No ethereum objsct.
at sendTransaction (TransactionContext.jsx:104:13)