{"id":20475560,"url":"https://github.com/planetable/enskit","last_synced_at":"2025-04-13T12:30:28.545Z","repository":{"id":42573424,"uuid":"471571020","full_name":"Planetable/ENSKit","owner":"Planetable","description":"Swift library for Ethereum Name Service","archived":false,"fork":false,"pushed_at":"2025-03-24T00:04:08.000Z","size":85,"stargazers_count":22,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T01:20:10.620Z","etag":null,"topics":["eip-1577","ens","ethereum","nft-avatar","swift","web3"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Planetable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-19T02:21:27.000Z","updated_at":"2025-03-24T00:04:12.000Z","dependencies_parsed_at":"2025-01-06T20:27:29.517Z","dependency_job_id":"e4566a5c-20a2-4c26-a0f6-b47afaa90b7b","html_url":"https://github.com/Planetable/ENSKit","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Planetable%2FENSKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Planetable%2FENSKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Planetable%2FENSKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Planetable%2FENSKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Planetable","download_url":"https://codeload.github.com/Planetable/ENSKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248714194,"owners_count":21149846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eip-1577","ens","ethereum","nft-avatar","swift","web3"],"created_at":"2024-11-15T15:16:26.002Z","updated_at":"2025-04-13T12:30:28.509Z","avatar_url":"https://github.com/Planetable.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ENSKit\n\nA swift utility to resolve Ethereum Domain Names ([ENS](https://ens.domains/)).\n\n## Quick Start\n\nSetup:\n```swift\n// Use default options with Cloudflare Ethereum Gateway\nlet enskit = ENSKit()\n\n// Use a built-in public RPC\nlet flashbot = ENSKit(jsonrpcClient: EthereumAPI.Flashbots)\n\n// Use Infura Ethereum API\nlet infuraURL = URL(string: \"https://mainnet.infura.io/v3/\u003cprojectid\u003e\")!\nlet infura = ENSKit(jsonrpcClient: InfuraEthereumAPI(url: infuraURL))\n// Use Infura Ethereum API with project secret\nlet infuraSecret = \"\u003cprojectsecret\u003e\"\nlet infuraWithProjectSecret = ENSKit(jsonrpcClient: InfuraEthereumAPI(url: infuraURL, projectSecret: infuraSecret))\n// Use Infura Ethereum API with JWT token\nlet infuraJWT = \"\u003cJWT\u003e\"\nlet infuraWithJWT = ENSKit(jsonrpcClient: InfuraEthereumAPI(url: infuraURL, jwt: infuraJWT))\n```\n\nGet [contenthash](https://docs.ens.domains/ens-improvement-proposals/ensip-7-contenthash-field) URL:\n```swift\n// in async function\nif let url = try await enskit.contenthash(name: \"\u003cyour_ens\u003e.eth\") {\n    // try fetch the content from IPFS/IPNS/Swarm URL\n}\n```\n\nGet avatar:\n```swift\n// in async function\nlet avatar = try await enskit.avatar(name: \"\u003cyour_ens\u003e.eth\")\nif let avatar = avatar,\n   let image = NSImage(data: avatar) { // or UIImage\n    // use image in your application\n}\n```\n\nGet text information associated with ENS:\n```swift\n// in async function\nif let email = try await enskit.text(name: \"\u003cyour_ens\u003e.eth\", key: \"email\") {\n    // use email in your application\n}\n```\n\nResolve address to name:\n```swift\n// in async function\nif let name = try await enskit.name(addr: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\") {\n    // 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 would resolve to vitalik.eth\n}\n```\n\n## Advanced Usage\n\n### `ENSResolver` Interface\n\nIt is recommended to use `ENSResolver` if you would like to query several records of an ENS at once.\n\nFor example, use `ENSResolver` to get the Ethereum wallet address, email, avatar, and contenthash associated with an ENS:\n```swift\n// in async function\nlet enskit = ENSKit()\nif let resolver = try await enskit.resolver(name: \"\u003cyour_ens\u003e.eth\") {\n    let address = try await resolver.addr()\n    let email = try await resolver.text(key: \"email\")\n    let avatar = try await resolver.avatar()\n    let contenthash = try await resolver.contenthash()\n    // process information in your application\n}\n```\n\nMethods in resolver reuse the same [public resolver contract](https://docs.ens.domains/contract-api-reference/ens#get-resolver) when the instance is created. This can save a few requests to Ethereum API.\n\nIn addition, all methods in resolver are marked with `throw` keyword. An empty result from resolver means a successful query, not an error interacting with Ethereum. **In contrast, convenience methods in `ENSKit` main class do NOT distinguish between empty records and error results.**\n\n### Contract Events\n\nENSKit supports contract events. You can search for history of contenthash changes and Ethereum wallet changes of an ENS:\n```swift\n// Cloudflare Ethereum Gateway (default) does not support full history of events\nlet enskit = ENSKit(jsonrpcClient: EthereumAPI.Flashbots)\nif let resolver = try await enskit.resolver(name: \"\u003cyour_ens\u003e.eth\") {\n    if let addrHistory = try await resolver.searchAddrHistory(),\n       !addrHistory.isEmpty {\n        let currentAddressChangedOn = addrHistory[0].date\n        let address = addrHistory[0].addr // this address should be the same as calling resolver.addr()\n    }\n    if let contenthashHistory = try await resolver.searchContenthashHistory(),\n       contenthashHistory.count \u003e 1 {\n        let previousContenthashChangedOn = addrHistory[1].date\n        let previousContenthash = addrHistory[1].contenthash\n    }\n}\n```\n\nHistory entries are sorted by newest first.\n\nIf you only concern about the latest change, there are also convenience methods in `ENSKit`:\n```swift\nlet enskit = ENSKit(jsonrpcClient: EthereumAPI.Flashbots)\nlet lastAddrChange = await enskit.lastAddrChange(name: \"\u003cyour_ens\u003e.eth\")\n```\n\n### Extensibility\n\nYou can provide your own Ethereum node to interact:\n```swift\nlet client = EthereumAPI(url: URL(\"https://rpc.myethnode\")!)\nlet enskit = ENSKit(jronrpcClient: client)\n```\nYou can also provide your own [JSONRPC implementation](Sources/ENSKit/Network/JSONRPC.swift) if `EthereumAPI` does not cover your need.\n\nENSKit uses OpenSea as a default NFT API provider to fetch NFT avatars that do not store metadata on chain. You can provide your own [NFTPlatform](Sources/ENSKit/Network/NFTPlatform.swift) implementation to use other services.\n\nENSKit uses [Cloudflare IPFS Gateway](https://developers.cloudflare.com/web3/ipfs-gateway/) to resolve IPFS content when fetching ENS avatar data. You can use another IPFS Gateway by passing a base URL:\n```swift\nlet ipfs = IPFSGatewayClient(baseURL: URL(\"http://localhost:8080\")!)\nlet enskit = ENSKit(ipfsClient: ipfs)\n```\nYou can also provide your own [IPFSClient](Sources/ENSKit/Network/IPFSClient.swift) implementation to fetch IPFS content.\n\n## License\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanetable%2Fenskit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanetable%2Fenskit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanetable%2Fenskit/lists"}