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

327
Views
Contract.methods.call() returning a error Web3-js

I am using web3 CDN and I have deployed contract with two variables. example:

pragma solidity ^0.5.0;

contract Sweet() {
    address public owner;
    uint256 sweets;
    uint256 shops;
    constructor(uint256 _sweets, uint256 _shops){
       owner = msg.sender;
       sweets = _sweet;
       shops = _shops;
    }

    function setSweetAndShop(uint256 _sweets, uint256 _shops) public {
       sweets = _sweets;
       shops = _shops;
    }
}

After deploying this example code everything works fine in the remix. After that, I have created an example DAPP.

async function change(){
var web3 = await new Web3(window.ethereum);
var account = await web3.eth.getAccounts();
var abi = [];
var contract = "0x000000000.........";
var token = new web3.eth.Contract(abi, contract);
try{
token.methods.setSweetAndShop(10, 20).call({
   from: account[0], 
   gas: 800000
})
.then(function(error, result) {
    if (!error){
            console.log(result);
        }else{
            console.log(error); //  This part is returning an error g{} , no data inside.
        }
    })
}catch(error){
    console.log(error)
}
}
about 4 years ago · Juan Pablo Isaza
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!