Skip to content

Provides creation and signing of identities using an Ethereum wallet.

License

Notifications You must be signed in to change notification settings

orbitdb/orbitdb-identity-provider-ethereum

Repository files navigation

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

About

Provides creation and signing of identities using an Ethereum wallet.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published