0

Anyone that can help me in how to interact with our smartcontract using web3.js.

I tried below code but this not work: This the code that I am using:

if (typeof web3 !== 'undefined')
{
  web3 = new Web3(web3.currentProvider);} 
else {
                web3 = new Web3(new Web3.providers.HttpProvider("htpp://localhost:8545"));
            }

            web3.eth.defaultAccount = web3.eth.accounts[0];

            var careercertificateContract = web3.eth.contract(CODE ABI);

        var careercertificate = careercertificateContract.at('0xe1EeCd0a848Bf59509F32f0c97B61d34727C84AB');
        console.log(Certificate);

        $("#button").click(function(){

            Certificate.createCertificate($("#id").val(), $("#fecha").val(), $("#NombreAlumno").val(), $("#RutA").val(), $("#NombreInstitucion").val(), $("#RutI").val(), $("#titulo").val(), $("#FechaTitulacion").val(), $("#NumeroRegistro").val(), $("#CodigoVer").val(), $("#TotalHash").val(),);

        });
  • Can you add error log that you faced during above code execution? – Mahesh Rajput Dec 29 '18 at 4:36
0

Use careercertificate.createCertificate(params) instead of Certificate.createCertificate(params) because careercertificate is the instance that is properly pointing to the contract. And if using web3js@0.20 then defiantly use callback functions for the response e.g

 careercertificate.createCertificate(params, (err, res) => { //es6 
    if(!err) //some logic
})

OR If using web3js1.0.0 then using async/await or then e.g

careercertificate.createCertificate(params).then(res => {
   //some logic
})

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.