Skip to content

Instantly share code, notes, and snippets.

@wissalHaji
Last active January 10, 2021 21:48
Show Gist options
  • Save wissalHaji/399353dde0ded5717722d5f3c378c230 to your computer and use it in GitHub Desktop.
Save wissalHaji/399353dde0ded5717722d5f3c378c230 to your computer and use it in GitHub Desktop.
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