{"id":22243430,"url":"https://github.com/ton-community/contract-verifier-sdk","last_synced_at":"2025-04-09T06:13:12.175Z","repository":{"id":64658384,"uuid":"554194173","full_name":"ton-community/contract-verifier-sdk","owner":"ton-community","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-01T08:53:44.000Z","size":12055,"stargazers_count":38,"open_issues_count":8,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T04:08:02.404Z","etag":null,"topics":["sdk","ton"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ton-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":"https://hge.to/thanks"}},"created_at":"2022-10-19T12:05:55.000Z","updated_at":"2025-03-21T00:22:54.000Z","dependencies_parsed_at":"2024-04-22T09:54:30.008Z","dependency_job_id":"108a3507-1c37-41f8-bbf2-6a54eb1c2ac8","html_url":"https://github.com/ton-community/contract-verifier-sdk","commit_stats":{"total_commits":67,"total_committers":2,"mean_commits":33.5,"dds":0.02985074626865669,"last_synced_commit":"21f7b0daca4e993ff0baa2e9a525a4756e8bc912"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-community%2Fcontract-verifier-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-community%2Fcontract-verifier-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-community%2Fcontract-verifier-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-community%2Fcontract-verifier-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ton-community","download_url":"https://codeload.github.com/ton-community/contract-verifier-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"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":["sdk","ton"],"created_at":"2024-12-03T04:26:51.036Z","updated_at":"2025-04-09T06:13:12.154Z","avatar_url":"https://github.com/ton-community.png","language":"TypeScript","funding_links":["https://hge.to/thanks"],"categories":[],"sub_categories":[],"readme":"# TON Contract Verifier SDK\n\n## TL;DR\nTON verifier data fetcher and code viewer with FunC code highlighting \n\n## Related repositories\n\nThis repo is a part of the following:\n\n1. [contract-verifier-contracts](https://github.com/ton-community/contract-verifier-contracts) - Sources registry contracts which stores an on-chain proof per code cell hash.\n2. [contract-verifier-backend](https://github.com/ton-community/contract-verifier-backend) - Backend for compiling FunC and returning a signature over a message containing the resulting code cell hash.\n3. [contract-verifier-sdk](https://github.com/ton-community/contract-verifier-sdk) (this repo) - A UI component to fetch and display sources from TON blockchain and IPFS, including FunC code highlighting.\n4. [contract-verifier](https://github.com/ton-community/contract-verifier) - A UI app to interact with the backend, contracts and publish an on-chain proof.\n\n## ⭐️ Features\n- Queries the Sources Registry for the existence of a Source Item contract\n- Fetches contract source code from IPFS via a sources.json url  \n- Displays a code navigator with code highlighting for FunC, FIFT, based on [highlight.js plugin](https://github.com/highlightjs/highlightjs-func)\n- Customizable data fetching (IPFS GW, TON API endpoint, verifier id)\n\n## 📦 Getting Started\n\n### Step 1: Prepare DOM ###\nAdd this to your HTML structure\n```html\n\u003cdiv id=\"myVerifierContainer\"\u003e\n    \u003cdiv id=\"myVerifierFiles\"\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"myVerifierContent\"\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\n### Installation\n\n#### NPM\n```\nnpm install @ton-community/contract-verifier-sdk\n```\n\n#### Web CDN\n```\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/ton-community/contract-verifier-sdk@1.1.0/dist/index.min.js\"\u003e\u003c/script\u003e\n```\n\n### Usage\n\n#### Node\n```typescript\nimport { ContractVerifier } from \"@ton-community/contract-verifier-sdk\";\n\nconst ipfsLink = await ContractVerifier.getSourcesJsonUrl(\n    \"45cE5NYJuT5l2bJ+HfRI0hUhR3LsBI6wER6yralqPyY=\",\n    {\n        testnet: false\n    }\n  );\n\nconst src = await ContractVerifier.getSourcesData(ipfsLink!, {testnet: false});\n\n// use contract data\n```\n\n#### Browser\n```html\n\u003cscript\u003e\n    document.addEventListener(\"DOMContentLoaded\", async function () {\n        const codeCellHash = \"/rX/aCDi/w2Ug+fg1iyBfYRniftK5YDIeIZtlZ2r1cA=\";\n        \n        const ipfslink = await ContractVerifier.getSourcesJsonUrl(codeCellHash);\n\n        // means there exists a verified source for this contract\n        if (ipfslink) {\n            // By default, it's best to leave the default IPFS gateway as it has all verified source code pinned and ready\n            const sourcesData = await ContractVerifier.getSourcesData(ipfslink);\n            const theme = window.matchMedia \u0026\u0026 window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n\n            ContractVerifierUI.loadSourcesData(sourcesData, {\n                containerSelector: \"#myVerifierContainer\",\n                fileListSelector: \"#myVerifierFiles\",\n                contentSelector: \"#myVerifierContent\",\n                theme\n            });\n        }\n    });\n\u003c/script\u003e\n```\n\n## ℹ️ Interface\n\n### ContractVerifier\n```typescript\ninterface GetSourcesOptions {\n  verifier?: string, // Defaults to \"orbs.com\"\n  httpApiEndpointV4?: string, // Defaults to an Orbs L3 TON Gateway\n  testnet?: boolean\n}\n\n// Returns an `ipfs://` prefixed URL if the given code cell hash has a corresponding source verifier contract \nasync ContractVerifier.getSourcesJsonUrl(codeCellHash: string, options?: GetSourcesOptions): Promise\u003cstring | null\u003e;\n\n\ninterface SourcesData {\n  files: { name: string; content: string }[];\n  commandLine: string;\n  compiler: string;\n  version: string;\n  verificationDate: Date;\n}\ntype IpfsUrlConverterFunc (ipfsUrl: string) =\u003e string;\n\n// Returns file names and their source code content\nasync ContractVerifier.getSourcesData(sourcesJsonUrl: string, options?: {\n    ipfsConverter?: IpfsUrlConverterFunc;\n    testnet?: boolean;\n}): Promise\u003cSourcesData\u003e;\n```\n\n### ContractVerifierUI\n\n```typescript\nContractVerifierUI.loadSourcesData(sourcesData: SourcesData, opts: {\n    containerSelector: string; // main container\n    fileListSelector?: string; // if omitted, the file list will not be populated and the setCode function can be used instead to switch between files\n    contentSelector: string; // code container\n    theme: Theme; // \"light\" or \"dark\"\n});\n\n// To be used usually only if the file list is manually built\nContractVerifierUI.setCode(contentSelector: string, content: string);\n```\n\n## 👀 Demo\n1. Clone this repo\n2. Run `npm install`\n3. Run `npm run build`\n\n### Web - Minimal\n1. Navigate to `example/vanilla-minimal`\n4. Open `index.html`\n\n### Web - Vanilla\n1. Navigate to `example/vanilla-vite`\n2. Run `npm install`\n3. Run `npm link ../../`\n4. Run `npm run dev`\n\n### Node.js\n1. Navigate to `example/node`\n2. Run `npm install`\n3. Run `npm link ../../`\n4. Run `ts-node index.ts`\n\n## 💎 Customization\n\n### CSS\nThe widget will attach the following classnames to its components:\n```\ncontract-verifier-container\ncontract-verifier-files\ncontract-verifier-file\ncontract-verifier-code\n```\n\nWhich can be customized according to your needs.\n\n## 📔 License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fton-community%2Fcontract-verifier-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fton-community%2Fcontract-verifier-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fton-community%2Fcontract-verifier-sdk/lists"}