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

144
Vistas
Issue in calling a smart contract function with web3

I'm trying to call the createCustomer function provided in this smart contract https://ropsten.etherscan.io/address/0xD3B462CbF6244ed21CD3cF334Bf8CB44A28795A9#code

and we basically have to provide three parameters like string memory _hashedEmail, string memory _name and string memory _phone.

So I've written the following program to call the createCustomer function

const addcustomer = async (req, res, next) => {
  try {
        const init = async() => {
            const provider = new  HDWalletProvider(
              privateKey1,
              'https://ropsten.infura.io/v3/1693cef23bd542968df2435f25726d39'
            );
            const web3 = new Web3(provider);

            let contract = new web3.eth.Contract(abi2, address3);
            contract.methods.createCustomer({_hashedemail: "a", _name: "nike", _phone: "99"}).call((err, result) => { console.log(result) });
            };
            init(); 
    }catch (err) {
        //throw error in json response with status 500. 
        return apiResponse.ErrorResponse(res, err);
    }
};

However it gives me this err which doesnt make any sense as i've already provided the three paramaters.

(node:14744) UnhandledPromiseRejectionWarning: Error: Invalid number of parameters for "createCustomer". Got 1 expected 3!
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Remove the { } inside createCustomer. So to be clear, this line:

contract.methods.createCustomer({_hashedemail: "a", _name: "nike", _phone: "99"})

should be:

contract.methods.createCustomer(_hashedemail: "a", _name: "nike", _phone: "99")

plus, when you try to interact with a function that modify the blockchain you shouldn't call it using .call but instead with .send.

To learn more you should check the web3.js docs

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