Skip to content

Instantly share code, notes, and snippets.

@ryanpedersen42
Last active September 5, 2019 01:26
Show Gist options
  • Select an option

  • Save ryanpedersen42/5d97f7ec4a40bf9e0e478efbb171c919 to your computer and use it in GitHub Desktop.

Select an option

Save ryanpedersen42/5d97f7ec4a40bf9e0e478efbb171c919 to your computer and use it in GitHub Desktop.
simple auth flow
handleAuth = async () => {
//web3 actions to authenticate with metamask or other provider
const ethAddresses = await window.ethereum.enable();
const ethAddress = ethAddresses[0];
//Authenticate into 3Box
const box = await Box.openBox(ethAddress, window.ethereum, {});
//Promise resolution- waiting for 3Box onSyncDone confirmation
await new Promise((resolve, reject) => box.onSyncDone(resolve));
//Authenticate into your space
const dappSpace = await box.openSpace(<'your-space-name'>);
//Set all to state and continue
await this.setState({ box, dappSpace, ethAddress });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment