Почему возникает данное сообщение 'gas limit must be at last 21000'?

<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>

вот сам код,возникает ошибка 'gas limit must be at last 21000' - почему?
  • Вопрос задан
  • 247 просмотров
Решения вопроса 1
@KingstonKMS
gasLimit должен быть равен 21000 для ETH, для ERC токенов 110000.
gasPrice вы указываете такой, чтобы gasLimit * gasPrice = сумма монет, которую готовы заплатить за транзакцию.
Отсюда можно брать цену
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы