Last active
January 10, 2021 21:48
-
-
Save wissalHaji/399353dde0ded5717722d5f3c378c230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require("web3"); | |
const EventExample = require("../build/contracts/EventExample.json"); | |
const init = async () => { | |
const web3 = new Web3("ws://localhost:7545"); | |
const id = await web3.eth.net.getId(); | |
const deployedNetwork = EventExample.networks[id]; | |
const eventExample = new web3.eth.Contract( | |
EventExample.abi, | |
deployedNetwork.address | |
); | |
const accounts = await web3.eth.getAccounts(); | |
const receipt = await eventExample.methods | |
.storeData(1, 2) | |
.send({ from: accounts[0] }); | |
console.log(receipt.events.DataStored.raw); | |
}; | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment