Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit e93809d

Browse files
tur-nraphelionz
authored andcommitted
adds code example for using Ethereum wallets
1 parent b5c23ef commit e93809d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ const didProvider = new Ed25519Provider(seed)
7474
const identity = await Identities.createIdentity({ type: 'DID', didProvider })
7575
```
7676

77+
#### Creating an identity with an Ethereum wallet
78+
Identities can also be created using Ethereum wallets. The example below uses [ethers](https://docs.ethers.io/) to open a users wallet and sign the identity.
79+
```js
80+
import Identities from "orbit-db-identity-provider";
81+
import { ethers } from "ethers";
82+
83+
const provider = new ethers.providers.Web3Provider(/* window.ethereum */);
84+
const wallet = provider.getSigner();
85+
const identity = await Identities.createIdentity({
86+
type: "ethereum",
87+
wallet,
88+
});
89+
```
90+
_Note: If you don't supply a `wallet`, a random one will be created for you._
91+
7792
### Create identity using existing keys
7893

7994
To create an identity using existing keys, you need to install `localstorage-level-migration`

0 commit comments

Comments
 (0)