Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

289
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda