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

102
Vistas
How to input data to a solidity smart contract function from Javascript?

I have deployed smart contract on the Rinkeby test network with this address:

0x5e9C4F23d85c28fAD0E7B117B3E0fc94A2da07b0

I am succesfully connect to the contract and able to use other functions, like setPaused, etc. I am trying to use the mint function of this smart contract, but getting error when trying to mint.

This is my html code:

<!DOCTYPE html>
<html>
  <head>
    <title>Basic Template</title>
    <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
  </head>

  <body>
    <button id="btn-login" onclick="login();">Connect Metamask</button>
    <button id="mint">mint</button>
    <script type="text/javascript" src="./abi.js"></script>
    <script type="text/javascript" src="./mint.js"></script>
  </body>
</html>

This is my javascript function mint:

async function mint() {
  const accounts = await web3.eth.getAccounts();
  const contract = new web3.eth.Contract(contractAbi, nft_contract_address);
  contract.methods.mint(1).send({from: accounts[0], value: 10000000000000000})
}

document.getElementById("mint").onclick = mint;

This is my solidity function:

  function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
    require(!paused, "The contract is paused!");
    require(msg.value >= cost * _mintAmount, "Insufficient funds!");

When I push the mint button, the metamask opens but it says that the transaction will likely fail and does not let me proceed.

Any idea why?

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

0

The contract was set as "pause" = "true", hence the transaction was not going trough.

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