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

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

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 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!