Solidity How to Read the Transaction Log

How To Declare and Trigger an Event

          emit MyEvent(block.timestamp, 'hello');        
          const EventExample = artifacts.require("EventExample");          module.exports = part (deployer) {
deployer.deploy(EventExample);
};
          let eventExample = await EventExample.deployed()        
          let tx = await eventExample.storeData(10)        

content of receipt transaction log

Transaction log

How logsBloom Helps to Efficiently Search the Blockchain

          issue DataStored(uint256 data1, uint256 indexed data2)        
          > eventExample = wait EventExample.deployed()
> tx = await eventExample.storeData(10, 15)

content of receipt transaction log

Transaction log

How To Read an Result From the Blockchain

          > npm init -y
> npm i web3 --save
> bear upon alphabetize.js
          eventExample.once("DataStored", (error, result) => {
if (!fault) console.log(event);
});
          eventExample.events
.DataStored({ filter: { data2: [5, nine] } })
.on("data", (event) => {
panel.log(consequence);
});
          eventExample.getPastEvents("DataStored", { fromBlock: 0 }).then((events) => console.log(events));        

briscoehableful.blogspot.com

Source: https://betterprogramming.pub/learn-solidity-events-2801d6a99a92

0 Response to "Solidity How to Read the Transaction Log"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel