Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Sending BNB with web3js won't log errors

I have this code that allows me to send bnb using web3.js using MetaMask I want to display a message when user rejects payment or there is any other error and if it is successful, display a success message. I can not find my way around it.

My Code is

$(".pay-button").click(async () => {
        await initWeb3('https://bsc-dataseed1.binance.org:443');
        // paymentAddress is where funds will be send to
        const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
const reciever = '0x5c03906C1c6f737eF982BDdA481D2E04D0089155';

            ethereum.request({
            method: 'eth_sendTransaction',
            params: [
                {
                    from: ethereum.selectedAddress,
                    to: reciever,
                    value: web3.toHex(web3.toWei('0.001', 'ether')),
                     gas: '0x76c0', // 30400
    gasPrice: '', // 10000000000000
    
                },
            ],
            })
            .then((txHash) => console.log(txHash))
            .catch((error) => console.error);
   
      });

I am using this package https://unpkg.com/@metamask/legacy-web3@latest/dist/metamask.web3.min.js

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try to check for the following error codes that are emitted by Metamask and tweak you UI accordingly.

Error codes given by metamask

https://docs.metamask.io/guide/ethereum-provider.html#events

If your transaction is success, i.e. when you receive the txHash, you can show success message in the UI https://github.com/skiran017/sol-tip-jar/blob/main/src/modules/TipWidget/TipWidget.tsx transaction status here is doing some similar job

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda