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

167
Vistas
web3 javascript unable to transfer

I am tring to transfer my TOKEN from metamask to another address, but I am stuck at the following error and am unable to find a solution.

Error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'transfer')

I have tried changing the ABI but it doesn't work...

Here is the code:

<!DOCTYPE html>
<html>
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://unpkg.com/@metamask/legacy-web3@latest/dist/metamask.web3.min.js"></script>
        <script src="contractAbi.js"></script>
    </head>
    <body>
        <div>
            <button class="pay-button">Pay</button>
            <div id="status"></div>
        </div>
        <script type="text/javascript">
            window.addEventListener('load', async () => {
                if (typeof window.ethereum !== 'undefined') {
                    ethereum.request({ method: 'eth_requestAccounts' });
                }
                else {
                    alert('Please install metamask');
                }
                const web3 = new Web3('https://bsc-dataseed.binance.org/');
                const contractAddress = '0xbdc6b4f65eae62574551951dddab27bfcd976c5c';
                const reciever = '';
                const amount = 10;
                const sendEthButton = document.querySelector('.pay-button');
                sendEthButton.addEventListener('click', () => {
                    (async () => {
                        const contract = new web3.eth.contract(ABI, contractAddress);
                        if (window.ethereum.chainId == '0x38') {
                            await contract.methods.transfer(reciever, amount).send('from',ethereum.selectedAddress).on('receipt', (receipt) => {
                                console.log(receipt);
                            })
                        }
                        else {
                            ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0x38' }] });
                        }
                    })();
                });
            })
        </script>
    </body>
</html>
about 4 years ago · Juan Pablo Isaza
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