{"name":"nft-did-resolver","version":"0.2.0-alpha.1","description":"DID Resolver for the NFT method","keywords":["Ceramic","DID","identity","Data"],"author":{"name":"Joel Torstensson","email":"oed3933@gmail.com"},"contributors":[{"name":"Mike Roth","email":"mike@manyuses.com"}],"homepage":"https://github.com/ceramicnetwork/nft-did-resolver","repository":{"type":"git","url":"git://github.com/ceramicnetwork/nft-did-resolver.git"},"license":"(Apache-2.0 OR MIT)","main":"lib/index.js","types":"lib/index.d.ts","directories":{"lib":"lib"},"scripts":{"test":"jest --coverage","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build","prebuild":"npm run clean","lint":"eslint ./src --ext .js,.jsx,.ts,.tsx","clean":"rm -rf ./lib"},"dependencies":{"@ceramicnetwork/common":"^1.1.0","@ceramicnetwork/stream-caip10-link":"^1.0.7","cross-fetch":"^3.1.4","json-to-graphql-query":"^2.1.0","tslib":"^2.3.0","uint8arrays":"^2.1.8"},"devDependencies":{"@babel/core":"^7.14.8","@babel/preset-env":"^7.14.8","@babel/preset-typescript":"^7.14.5","@ceramicnetwork/blockchain-utils-linking":"^1.0.2","@types/jest":"^26.0.24","@types/node":"^16.4.8","@typescript-eslint/eslint-plugin":"^4.28.5","@typescript-eslint/parser":"^4.28.5","babel-jest":"^27.0.6","did-resolver":"^3.0.1","eslint":"^7.32.0","eslint-config-3box":"^0.2.0","eslint-plugin-jest":"^24.4.0","ethers":"^5.4.3","ganache-core":"^2.13.2","jest":"^27.0.6","jest-environment-ceramic":"^0.13.0","jest-fetch-mock":"^3.0.3","lru_map":"^0.4.1","prettier":"^2.3.2","typescript":"^4.3.5"},"jest":{"automock":false,"setupFiles":["./jest.setup.ts"],"testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"prettier":"eslint-config-3box/prettier.config","readme":"# NFT DID Resolver\n\n> NFT is a DID method that uses the Ceramic network to resolve DID documents for NFTs\n\n> See [CIP-94](https://github.com/ceramicnetwork/CIP/blob/main/CIPs/CIP-94/CIP-94.md)\n\n## Getting started\n\nThis implementation is still a prototype. Contributions are welcome!\n\nBy default, this package will resolve dids for both ERC721 and ERC1155 tokens on mainnet, if they are indexed by their respective public subgraphs: \n* [EIP721-Subgraph](https://api.thegraph.com/subgraphs/name/wighawag/eip721-subgraph)\n* [EIP1155-Subgraph](https://api.thegraph.com/subgraphs/name/amxx/eip1155-subgraph)\n\nTo resolve DIDs using your own subgraph, see [Custom Subgraphs](#custom-subgraphs)\n\n### Installation\n```\n$ npm install nft-did-resolver\n// or\n$ yarn add nft-did-resolver\n```\n\n### Usage\n\n```js\nimport NftResolver, { NftResolverConfig } from 'nft-did-resolver'\nimport { Resolver } from 'did-resolver'\nimport Ceramic from '@ceramicnetwork/http-client'\n\nconst ceramic = new Ceramic() // connects to localhost:7007 by default\n\nconst config: NftResolverConfig = {\n  ceramic,\n  subGraphUrls: { // optional, there are defaults for ethereum mainnet (erc721 and erc1155)\n    // CAIP2 ChainID (below is ETH mainnet)\n    'eip155:1': {\n      // Asset namespace\n      erc721: 'https://api.thegraph.com/subgraphs/name/xxx/yyy',\n      // erc721: 'http://localhost:8000/subgraphs/name/aoeu/qjkx' // also works!\n      erc1155: 'https://api.thegraph.com/subgraphs/name/abc/xyz'\n    },\n    // Fake cosmos example\n    'cosmos:nft-token-chainid': {\n      erc721: 'https://api.thegraph.com/subgraphs/name/aaa/ooo'\n    }\n  }\n}\n\n// getResolver will return an object with a key/value pair of { 'nft': resolver }\n// where resolver is a function used by the generic did resolver.\nconst nftResolver = NftResolver.getResolver(config)\nconst didResolver = Resolver(nftResolver)\n\nconst erc721result = await didResolver.resolve('did:nft:eip155.1_erc721.0xb300a43751601bd54ffee7de35929537b28e1488_2')\nconst erc1155result = await didResolver.resolve('did:nft:eip155.1_erc1155.0x06eb48572a2ef9a3b230d69ca731330793b65bdc_1')\nconsole.log(erc721result, erc1155result)\n```\n\n## Development\nStart a ceramic daemon using the `@ceramicnetwork/cli` package, and a ganache ethereum rpc using the `ganacle-cli` package.\n\n\nThen run tests:\n```\n$ npm test\n$ yarn test\n```\n\n## Custom Subgraphs\nYou may specify custom subgraph URLs in the configuration object as shown above in [usage](#usage).\n\n**Note**: custom subgraphs must conform to the below schemas at a *minimum* for assets to be resolved properly.\n\n**Note**: At the moment, only ERC721 and ERC1155 asset namespaces are supported. However, CAIP2 chains beside ETH,\nfor instance xDAI, with support for those namespaces *are* supported, as long as the subgraph schema is the same.\n\n### ERC721:\n\n```gql\ntype Token @entity {\n  id: ID!\n  contract: TokenContract!\n  owner: Owner!\n  ...\n}\n\ntype TokenContract @entity {\n  id: ID!\n  tokens: [Token!]! @derivedFrom(field: \"contract\")\n  ...\n}\n\ntype Owner @entity {\n  id: ID!\n  tokens: [Token!]! @derivedFrom(field: \"owner\")\n  ...\n}\n\n```\n\n### ERC1155:\n```gql\ntype Account @entity {\n  id: ID!\n  balances: [Balance!]! @derivedFrom(field: \"account\")\n  ...\n}\n \ntype TokenRegistry @entity {\n  id: ID!\n  tokens: [Token!]! @derivedFrom(field: \"registry\")\n  ...\n}\n\ntype Token @entity {\n  id: ID!\n  registry: TokenRegistry!\n  identifier: BigInt!\n  balances: [Balance!]! @derivedFrom(field: \"token\")\n  ...\n}\n \ntype Balance @entity {\n  id: ID!\n  token: Token!\n  account: Account!\n  ...\n}\n\n```\n\nFor more information on writing schemas for GraphProtocol, check out [their documentation](https://thegraph.com/docs/define-a-subgraph#defining-entities).\n\n## DID Specs\nThe token DIDs are prefixed with `did:nft:`, and the latter half is a modified CAIP format.\n\n**ERC721** ([CAIP-22](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/CAIP-22.md))\n\nDID: `did:nft:{chainNamespace}.{chainReference}_erc721.{contractAddress}_{tokenId}`\n\nCAIP-22: `{chainNamespace}:{chainReference}/erc721:{contractAddress}/{tokenId}`\n\n**ERC1155** ([CAIP-29](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/CAIP-29.md))\n\nDID: `did:nft:{chainNamespace}.{chainReference}_erc1155.{contractAddress}_{tokenId}`\n\nCAIP-29: `{chainNamespace}:{chainReference}/erc1155:{contractAddress}/{tokenId}`\n\n\n### Conversions\n**DID->CAIP**\n```\nconst caip = did.substr(8).replace(/_/g, '/').replace(/\\./g, ':')\n```\n**CAIP->DID**\n```\nconst did = `did:nft:${caip.replace(/\\//g, '_').replace(/:/g, '.')}`\n```\n\n\n## Contributing\nWe are happy to accept small and large contributions. Make sure to check out the [Ceramic specifications](https://github.com/ceramicnetwork/specs) for details of how the protocol works.\n\n\n## License\nApache-2.0 OR MIT\n","readmeFilename":"README.md","gitHead":"b99851deb80655da6a485e93fa3ad5e2e195f95d","bugs":{"url":"https://github.com/ceramicnetwork/nft-did-resolver/issues"},"_id":"nft-did-resolver@0.2.0-alpha.1","_nodeVersion":"16.3.0","_npmVersion":"7.15.1","dist":{"integrity":"sha512-GnyzPDO7oHXg5FuYDxTYLSr7HM1o4Mwqjo6ylDj8OVzvlLsSXEqZ7dKnL2joAtapO6pWBHwM5X+Tub1OGcyKxg==","shasum":"bada56d545814da0fac9638647a3523a1a1a2a45","tarball":"https://registry.npmjs.org/nft-did-resolver/-/nft-did-resolver-0.2.0-alpha.1.tgz","fileCount":14,"unpackedSize":42119,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCpuECRA9TVsSAnZWagAATvMP/RSap041BllMgoZVCy99\nJP1xb1dKISTIlnYR6f63D0hSL3RODAZSp930V+5lebwRB6Y1+GK2PmUaHJAo\nmp7fuGQartufovG5JlSrJoB/5NRcz826sKCj/4EvmLlrncoXXRdbIdXEkYG7\nVMZMvIN41adeCyRfvtaQXC7ZstoBbe7mJF5jFwe2t3wY8zEiQu67hvfGP6Ud\noDliXpjuUpQ31mkA/LCtLbzb137HbGJ8GiorgQ+kuh2d921AZVpSjxHXnYMd\nfXa/Q+edQb5WFAAr4ERCX0IKXgFHqAPQU/FhNMix+xbrBwAyMZlct+SWmbsY\nqeWJIRBR/YvF6T0G01e12pM5WkKmK23pGRYhw5qQgj2uN2S8y9xKQIGJKvrs\n7fQe5Vm0oTF4TEAUUIupWhFZ7mzwJ8ym+hTGIhpgs1MLAvBjKvCWocOzssxt\nSL/wIluG/ClerO9pIgpEWOzNb5U50LxhNmGKONRu/n0N6h6evQuJTqX2a5eo\n9HAt1aRGmA34LBg0YZDpqjac1PEXjUCAKq62jMjLP9I9Hili/ubRBkLnNL1y\nNXduGt2hB6PPnMLI95TcpJPRoy1z6WsWmqrQA8AGqKitEIa+GAQlbc9KXEtw\n6W1wOiNjgaEar6lvtzktTiToxGp6Pw30mwauEJRa4ord/pti9RJBTjPKQseg\nis6a\r\n=Qymr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGQ5jSTDSjpPvaKXxqYT9Css4PhmVTWTHhfo43twcFilAiEA7SfD8jBpMQLwR+Nn8RZubNPD96gW7Bx2ErHJGbeN+Xw="}]},"_npmUser":{"name":"ukstv","email":"sergey@ukstv.me"},"maintainers":[{"name":"ukstv","email":"sergey@ukstv.me"},{"name":"oed","email":"oed@3box.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nft-did-resolver_0.2.0-alpha.1_1628085124493_0.09457050307750237"},"_hasShrinkwrap":false}