@orbitdb/identity-provider-ethereum

1.0.2 • Public • Published

OrbitDB Ethereum Identity Provider

Matrix npm (scoped) node-current (scoped)

Create and sign OrbitDB identities using an Ethereum wallet.

Install

This project uses npm and nodejs.

npm i @orbitdb/identity-provider-ethereum

Usage

Start by registering the OrbitDBIdentityProviderEthereum identity provider with useIdentityProvider.

Once registered, you can simply pass in the identity provider when creating an OrbitDB instance:

import { createOrbitDB, useIdentityProvider } from '@orbitdb/core'
import * as OrbitDBIdentityProviderEthereum from '@orbitdb/identity-provider-ethereum'
import { Wallet } from '@ethersproject/wallet'

const wallet = Wallet.createRandom()

useIdentityProvider(OrbitDBIdentityProviderEthereum)
const provider = OrbitDBIdentityProviderEthereum({ wallet })
await createOrbitDB({ ipfs, identity: { provider } })

If you require a more custom approach to managing identities, you can create an identity by passing the identity provider to createIdentity then use the resulting identity with OrbitDB:

import { createHelia, libp2pDefaults } from 'helia'
import { createOrbitDB, Identities, useIdentityProvider } from '@orbitdb/core'
import * as OrbitDBIdentityProviderEthereum from '@orbitdb/identity-provider-ethereum'

const libp2pOptions = libp2pDefaults()
const ipfs = await createHelia({ libp2p: libp2pOptions })

useIdentityProvider(OrbitDBIdentityProviderEthereum)
const provider = OrbitDBIdentityProviderEthereum({ wallet })

const identities = await Identities({ ipfs })
const identity = await identities.createIdentity({ id: 'userA', provider })

await createOrbitDB({ ipfs, identities, identity })

Contributing

Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there. Some questions may be answered in the FAQ, as well.

If you want to code but don't know where to start, check out the issues labelled "help wanted".

License

MIT Haja Networks Oy, OrbitDB Community

Package Sidebar

Install

npm i @orbitdb/identity-provider-ethereum

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

18.8 kB

Total Files

13

Last publish

Collaborators

  • julien.malard
  • aphelionz
  • spauldingsmails
  • haad