I have used infura in my App.js to connect to the kovan network. Then I am creating an instance of the smart contract deployed on that network. Then I am calling a function on that smart contract which emits an event.
This returns a transaction hash but I want to access the event details emitted by that smart contract function. I thought I might use that transaction hash on kovan etherscan site and get the event details emitted but it didnot work. How do I access them?
I have sent a signed transaction through infura:
const Tx = require('ethereumjs-tx').Transaction
// connect to Infura node
const web3 = new Web3(new Web3.providers.HttpProvider("//kovan infura key"));
// the address that will send the test transaction
const addressFrom = '//myaccountaddress'
const privKey = '//my key'
// the destination address
const addressTo = '//contractaddress'
function sendSigned(txData,cb) {
const privateKey = new Buffer.from("privateKey", 'hex')
const transaction = new Tx(txData)
transaction.sign(privateKey)
const serializedTx = transaction.serialize().toString('hex')
web3.eth.sendSignedTransaction('0x' + serializedTx,cb)
}
const contract = new web3.eth.Contract(Contract.abi,Contract.address, {from: addressFrom,gasLimit: 3000000});
const contractFunction = contract.methods.getDetails(0);
const functionAbi = contractFunction.encodeABI();
web3.eth.getTransactionCount(addressFrom).then(txCount => {
const txData = {
nonce: web3.utils.toHex(txCount),
gasLimit: web3.utils.toHex(25000),
gasPrice: web3.utils.toHex(10e12), // 10 Gwei
to: addressTo,
from: addressFrom,
data: functionAbi
}
sendSigned(txData, function(err, result) {
if (err) return console.log('error', err)
console.log('sent', result)
})