Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 10:58
Show Gist options
  • Save percybolmer/9b64800eaa3ce7045ad80db53a315dc5 to your computer and use it in GitHub Desktop.
Save percybolmer/9b64800eaa3ce7045ad80db53a315dc5 to your computer and use it in GitHub Desktop.
useEffect(() => {
// Only get profile if we are completly loaded
if (loaded && (accounts !== 0)) {
// get user info
getUserProfile()
// Subscribe to Stake events
// Options allows us to specify filters so we dont grab all events, in this case we only select our current account in metamask
let options = {
filter: {
address: [accounts[0]]
},
};
// Our contract has a field called events which has all Available events.
devToken.events.Staked(options)
// data is when
.on('data', event => console.log("Data: " , event))
.on('changed', changed => console.log("Changed: ", changed))
.on('error', err => console.log("Err: ", err))
.on('connected', str => console.log("Conntected: ", str))
} else {
setTimeout(setLoaded(true), 500);
}
// This here subscribes to changes on the loaded state
}, [loaded, accounts, devToken]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment