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

283
Vistas
NFT transfer with web3 signTransaction()

I want to transfer an nft from a 'AdminWallet' to a user with js. I have a AdminWallet that has all the nft's in it. Now I want users to be able to claim them with a press of a button.

I am using js code to accomplish this.

I have the following code:

    const tx = {
        from: PUBLIC_KEY,
        to: user_address,
        nonce: nonce,
        gas: 500000,
        data: contract.methods.safeTransferFrom(PUBLIC_KEY, user_address, "1").encodeABI(),
        chain: "rinkeby",
        hardfork: "petersburg"
    }

    const signPromise = web3.eth.accounts.signTransaction(tx, PRIVATE_KEY)
    signPromise
        .then((signedTx) => {
            web3.eth.sendSignedTransaction(
                signedTx.rawTransaction,
                function(err, hash) {
                    if (!err) {
                        console.log(
                            "The hash of your transaction is: ",
                            hash,
                        )
                    } else {
                        console.log(
                            "Something went wrong when submitting your transaction:",
                            err
                        )
                    }
                }
            )
        })
        .catch((err) => {
            console.log(" Promise failed:", err)
        }) 

So what I am trying to do here is send an nft with tokenid '1' from the 'AdminWallet' on the address of PUBLIC_KEY to the user_address.

If I would do it without the signtransaction(), I would call the following: contract.methods.safeTransferFrom(PUBLIC_KEY, user_address, "1").send({ from: PUBLIC_KEY})

From what I could find the signTransaction() calls the .Call() of the tx data. If I want to transfer the nft with my original way I have to call the .send() function.

Is there anyway to call the .send() function to sign the automatically sign the transaction?

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