Gnosis Safe DID Resolver
Safe is a DID method that uses the Ceramic network to resolve DID documents for Gnosis Safe
See CIP-101
Getting started
This implementation is still a prototype. Contributions are welcome!
Installation
$ npm install safe-did-resolver
Usage
import SafeResolver from 'safe-did-resolver'
import { Resolver } from 'did-resolver'
import Ceramic from '@ceramicnetwork/http-client'
const ceramic = new Ceramic()
const web3Provider = window.ethereum
const provider = new ethers.providers.Web3Provider(web3Provider)
const owner1 = provider.getSigner(0)
const ethAdapter = new EthersAdapter({
ethers,
signer: owner1,
})
const config = {
ceramic,
ethAdapter,
}
const safeResolver = SafeResolver.getResolver(config)
const didResolver = Resolver(safeResolver)
const safeResult = await didSafeResolver.resolve(
'did:safe:eip155:4:0x2Cb8c8dd6Cefb413884612DC16d187aBDcB64A52'
)
console.log(safeResult)
The resolver supports the following networks by default:
- Ethereum mainnet (
eip155:1),
- Ethereum Rinkeby (
eip155:4),
Testing
$ npm test
DID Specs
The token DIDs are prefixed with did:safe:, followed by method specific identifier, which is simply
a CAIP-10 Account ID.
DID: did:safe:{chainId}:{safeAddress}
CAIP-10: {chainId}:{safeAddress}
Conversions
DID->CAIP
const caip = did.substr(8).replace(/_/g, '/')
CAIP->DID
const did = `did:safe:${caip.replace(/\//g, '_')
There are helpers that help you with the conversion:
import { caipToDid, didToCaip, createSafeDidUrl } from 'safe-did-resolver'
import { AccountId } from 'caip'
const didUrl = createSafeDidUrl({
chainId: 'eip155:1',
address: '0x1234567891234567891234567891234596351156',
})
const accountId = didToCaip(didUrl)
ToDos
License
Apache-2.0 OR MIT