0

JS code

contract.methods
  .myFunction(
    "data1",
    1568545262,
    1568631662,
    1568718062,
    "0xD4496dA2a4b376fC8s4d786EB6B71483436077c4"
  )
  .send({
    from: "0xD4496dA2a4b376fC8s4d786EB6B71483436077c4",
    gas: "3000000",
    value: web3.utils.toWei("0.01", "ether")
  })
  .on("transactionHash", function(hash) {
    //console.log(hash);
  })
  .on("confirmation", function(confirmationNumber, receipt) {
    //console.log(confirmationNumber, receipt);
  })
  .on("receipt", function(receipt) {
    console.log(receipt);
    //console.log("blocknumber:", receipt.blockNumber);
    //console.log("Event: ", receipt.events);
  })
  .on("error", console.error);

Smart Contract code:

 event eventA(
    uint data,
    uint n1,
    uint n2,
    uint n3,
    address Addr1
);

function myFunction(

    // function Code 
    emit eventA(
        data1,num1,num2,num3,addr
    );
}

output:

{ blockHash: '0x83850fbb72e6376e8455b57e6bec75f043f9b90b1c0a02d4bf159052f77e6073', blockNumber: 6377715, contractAddress: null, cumulativeGasUsed: 2713822, from: '0xd4496da2a4b376fc8ce4786eb6b71483436077c4', gasUsed: 24984, logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', status: true, to: '0xb5fe528b887a52ded9196585ec698a66b366264d', transactionHash: '0xbdc6816b32572d1bfe28ddf7ad6f0d5282c025fff1fe78ca88b01e24360dd876', transactionIndex: 56, events: {} }

How can I catch that event?

  • Are you sure that you've got the right contract (i.e., byte-code) deployed? – goodvibration Sep 12 at 14:29
  • Yes. If I deploy same contract in Remix, I can see event in the logs. Same contract I used for web3 but getting empt response. I'll check again. – Junior_K27 Sep 13 at 5:00
  • My bytecode was wrong. I need help with bytecode conversion. According to latest solc docs, we need to get evm.bytecode.object and then convert it into hexformat. Right? – Junior_K27 Sep 13 at 7:00

Your Answer

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

Browse other questions tagged or ask your own question.