Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!