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

326
Vistas
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
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