2. Create IdentityWallet Instance

Choose how your wallet creates an IdentityWallet

3Box accounts have a 3ID identity that they use to authorize and encrypt/decrypt data. In order to authorize, access, and update data saved in a 3Box, you will need to generate an IdentityWallet instance which contains the user's 3ID. There are two primary ways to accomplish this; choose the correct one for your use case:

Generate an IdentityWallet from a Seed

You should consider generating an IdentityWallet from a seed if your wallet implements a traditional cryptographic key-pair account model.

To create a wallet with a seed you can simply pass it as an option to the constructor. This will create an instance of the IdentityWallet that derives all it's keys from this seed. Be careful, if this seed is lost the identity and all of it's data will be lost as well.

const seed = '0xabc123...' // a hex encoded seed
const idWallet = new IdentityWallet({ seed })

This is best for...

  • Keypair account-based wallets

  • Node.js applications

  • Web applications with hosted wallets

Create an IdentityWallet for a Contract Account

You should consider creating an IdentityWallet this way if your wallet implements a contract-based user account mode. This will allow you to associate multiple signing/authentication accounts to the same user identity.

For wallets which doesn't have key-pair accounts/identities, e.g. smart contract wallets, we provide a way of creating an identity with multiple authentication secrets. In this model each authentication secret grants full access to the identity. To create an instance of the IdentityWallet in this way the ethereum address of the account also needs to be passed to the constructor.

const authSecret = '0xabc123...' // a hex encoded secret
const ethereumAddress = '0xabc123' // an ethereum address
const idWallet = new IdentityWallet({ authSecret, ethereumAddress })

This is best for...

  • Smart contract-based wallets

  • Sharing 3Box data across multiple signing/auth/eth accounts and contracts