Last active
August 6, 2021 10:58
-
-
Save percybolmer/9b64800eaa3ce7045ad80db53a315dc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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