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

404
Visualizações
How would I send an eth value to specific smart contract function that is payable in ethers.js?

I'm trying to call a payable function on a smart contract that only accepts one argument.

How would I send an eth value to this function in ethers.js along with the function call? The docs don't seem to give much examples on the best way to do this.

My function call

const reciept = await contract.buyPunk(1001);

all other read and write function calls work as expected, but its calling a payable function that I have yet to solve.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

const options = {value: ethers.utils.parseEther("1.0")}
const reciept = await contract.buyPunk(1001, options);

When calling a contract function through ethers.js you can pass along an object of options at the end of your arguments. This object can set the the value to send along with the transaction.

Documentation here: https://docs.ethers.io/v5/api/contract/contract/#Contract-functionsCall

over 4 years ago · Santiago Trujillo Relatório
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