Answer the question
In order to leave comments, you need to log in
Why does this message 'gas limit must be at last 21000' occur?
<script>
const ethereumButton = document.querySelector('.enableEthereumButton');
const sendEthButton = document.querySelector('.sendEthButton');
console.log(sendEthButton)
const amountInput = document.querySelector('.ticketAmount');
window.web3 = new Web3(ethereum);
let accounts = [];
document.addEventListener("DOMContentLoaded", function(event) {
getAccount();
});
//Sending Ethereum to an address
sendEthButton.addEventListener('click', () => {
let inputAmount = document.getElementById("ticketAmount").value * 0.07;
const amount = web3.utils.toWei((Math.round(inputAmount*100)/100).toString(), 'ether');
const value = web3.utils.toHex(amount);
ethereum
.request({
method: 'eth_sendTransaction',
params: [
{
from: accounts[0],
to: '0xdCa0c00862A6a965ED2799499555f50986E9c2C3',
value: web3.utils.toHex(amount),
gasPrice: '0x09184e72a000',
gas: '400',
gasLimit:'210000'
},
],
})
.then((txHash) => console.log(txHash))
.catch((error) => console.error);
});
async function getAccount() {
accounts = await ethereum.request({ method: 'eth_requestAccounts' });
}
document.querySelector('#mint-options').onsubmit =function(){
return false;
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question