Observed since 20 Oct, 19:45 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
3id-blockchain-utils
Blockchain utils for 3ID
This package contains a bunch of utilities that is used by 3ID and 3Box in order to create and verify links from blockchain addresses.
$ npm install --save 3id-blockchain-utils
Import the package into your project
import { createLink, validateLink, authenticate } from '3id-blockchain-utils'
Use the library to create and verify links:
const did = 'did:3:bafypwg9834gf...'
const proof = await createLink(did, '0x123abc...', ethereumProvider)
console.log(proof)
const verified = await validateLink(proof)
if (verified) {
console.log('Proof is valid', proof)
} else {
console.log('Proof is invalid')
}
Use the library for 3ID authenticate:
await authenticate(message, '0x123abc...', ethereumProvider)
Below you can see a table which lists supported blockchains and their provider objects.
| Blockchain | CAIP-2 namespace | Supported providers |
|---|---|---|
| Ethereum | eip155 | metamask-like ethereum provider |
| Filecoin | fil | Filecoin Wallet Provider |
If you want to add support for a new blockchain to 3ID this is the place to do so. This library uses CAIP-10 to represent accounts in a blockchain agnostic way. If the blockchain you want to add isn't already part of the CAIP standards you shold make sure to add it there.
To begin adding support for a given blockchain add a file with the path: src/blockchains/<blockchain-name>.js. This module needs to export three functions:
createLink - creates a LinkProof object which associates the specified AccountID with the DIDvalidateLink - validates the given LinkProofauthenticate - signs a message and returns some entropy based on the signature. Needs to be deterministicIt also needs to export a constant called namespace. This constant is a string which contains the CAIP-2 chainId namespace.
Please see src/blockchains/ethereum.js for an example of how this is implemented for the eip155 (ethereum) CAIP-2 namespace.
Finally add support for your blockchain in src/index.js. Simply add it to the handlers array.
Test the code by running:
$ npm test
Apache-2.0 OR MIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@ethersproject/contractsEnvironment{
"local_name": "@ethersproject/contracts",
"alias": false,
"peer_metadata": null
} | 5.0.0-beta.152 | runtime |
@ethersproject/providersEnvironment{
"local_name": "@ethersproject/providers",
"alias": false,
"peer_metadata": null
} | 5.0.0-beta.144 | runtime |
@ethersproject/walletEnvironment{
"local_name": "@ethersproject/wallet",
"alias": false,
"peer_metadata": null
} | 5.0.0-beta.136 | runtime |
@babel/cliEnvironment{
"local_name": "@babel/cli",
"alias": false,
"peer_metadata": null
} | ^7.7.0 | development |
@babel/coreEnvironment{
"local_name": "@babel/core",
"alias": false,
"peer_metadata": null
} | ^7.7.2 | development |
@babel/plugin-transform-modules-commonjsEnvironment{
"local_name": "@babel/plugin-transform-modules-commonjs",
"alias": false,
"peer_metadata": null
} | ^7.7.0 | development |
@babel/preset-envEnvironment{
"local_name": "@babel/preset-env",
"alias": false,
"peer_metadata": null
} | ^7.7.1 | development |
babel-jestEnvironment{
"local_name": "babel-jest",
"alias": false,
"peer_metadata": null
} | ^24.9.0 | development |
eth-sig-utilEnvironment{
"local_name": "eth-sig-util",
"alias": false,
"peer_metadata": null
} | ^2.5.3 | development |
ganache-coreEnvironment{
"local_name": "ganache-core",
"alias": false,
"peer_metadata": null
} | ^2.10.1 | development |
jestEnvironment{
"local_name": "jest",
"alias": false,
"peer_metadata": null
} | ^24.9.0 | development |
standardEnvironment{
"local_name": "standard",
"alias": false,
"peer_metadata": null
} | ^14.3.1 | development |
Source distribution
{
"integrity": "sha512-GS3IfeXWnaLasHaOGvQukr9Gm+9IgofbysfkZF5X6lNztVysXhj5ZXv+Az5FmDNg3Q/ssVw7FfwK/r7HJYNi+g==",
"shasum": "7cad4d32bdc76772436b8977e56476c3d37ef05e",
"tarball": "https://registry.npmjs.org/3id-blockchain-utils/-/3id-blockchain-utils-0.3.4.tgz",
"fileCount": 20,
"unpackedSize": 45805,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewrkCCRA9TVsSAnZWagAAnvYQAIjIrt4VrJEsSyU2lEO7\nEfxQhFM76PVTqPTTTCoWxqL31/McT9oGlmxWmxzHfbNCSQ0Ifp0slAe89ltA\nxx36p4YA5Jt1S/SMm2pWrc25EZDC5E56vVVf1EvykGMjsGif0Ydm4chpR8GR\n/7Scpsu7gA6BvWUaZbszRpyBbYoxfZr11k3GShICGP6mGVmAwmX0XsmwCj7Q\n94gm/m5RNkwd78Vb88PBEEgdGSIPd2URp5Dbj5ATKQkHDWhrHnZo/vrzDprW\nom9oNmtveIJq07c6nYRjDBizFMat5amW8HkwE0N0uHDU8uErcQXISJvHgiBq\nMPJJ2AgrxQBqxqI1EDyic49MHv2U49qwSSesBzysxKgvLkYAQP+lfDg+U4xf\npL2+CfXvsPkaC237uZqx0wMDkoDRYuPvjkgJyHeZgzROetXujqLtj+IUAxX0\neFXXYemChGNx2S8KkMtDcrN06+0DtZh3XCtmoVgm38ibTmQwRnv2IhFrGFgk\n1zdOUI+Mhs6vDcODFQUdZisDVp6eVu0eITHJOUS0YPunUUWuJdfhR8Wqapu2\n1RMoAJeydMwjn/g6Chrx+PH9qxE/4yhBq3L4lUFiVvi5sykgbQ8bCPs+wLYd\nTmiHfM2c6ztC4CJoOfrsGRr77pkq61zzKzygBWSe+rDp8wbiTHDh9D6zxtDw\nIRWh\r\n=xuq/\r\n-----END PGP SIGNATURE-----\r\n",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCICt5OxDug+baXcj54yT6TxG7u9Ol7kYbKeHiUGLhm18SAiEAvUC1gztpOWJEF4Eftk38bIq09tFT+4D4A2KjvBe6yHc="
}
]
}Observed since 20 Oct, 19:45 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:104e1d768419571fa77b6429ff68cb9baeeaf80dbc504b7fc4f33ca48f8d2954