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

329
Visualizações
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 à 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