{"id":50499214,"url":"https://github.com/phantasma-io/phantasma-sdk-ts","last_synced_at":"2026-06-02T10:01:40.106Z","repository":{"id":227134340,"uuid":"770321787","full_name":"phantasma-io/phantasma-sdk-ts","owner":"phantasma-io","description":"A TypeScript SDK for the Phantasma blockchain","archived":false,"fork":false,"pushed_at":"2026-05-13T20:57:07.000Z","size":4649,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-13T21:05:18.229Z","etag":null,"topics":["blockchain","crypto","cryptocurrency","dapps-development","layer1","phantasma","phantasmachain","phantasmaio","sdk","smartcontract","smartnft","smartnfts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phantasma-io.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-11T10:57:30.000Z","updated_at":"2026-05-13T20:57:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"708663fc-b232-4d92-bb13-9cf61a0df363","html_url":"https://github.com/phantasma-io/phantasma-sdk-ts","commit_stats":null,"previous_names":["phantasma-io/phantasma-ts","phantasma-io/phantasma-sdk-ts"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/phantasma-io/phantasma-sdk-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2Fphantasma-sdk-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2Fphantasma-sdk-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2Fphantasma-sdk-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2Fphantasma-sdk-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phantasma-io","download_url":"https://codeload.github.com/phantasma-io/phantasma-sdk-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2Fphantasma-sdk-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33816488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["blockchain","crypto","cryptocurrency","dapps-development","layer1","phantasma","phantasmachain","phantasmaio","sdk","smartcontract","smartnft","smartnfts"],"created_at":"2026-06-02T10:01:39.415Z","updated_at":"2026-06-02T10:01:40.097Z","avatar_url":"https://github.com/phantasma-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phantasma TypeScript SDK\n\nTypeScript SDK for Phantasma RPC access, transaction construction, VM script helpers, wallet/link integration, and Carbon binary types.\n\n## Install\n\n```bash\nnpm install phantasma-sdk-ts\n```\n\nThe package ships CommonJS, ESM, and type declarations.\n\n## Entry Points\n\nUse the curated public entrypoint for new code:\n\n```ts\nimport {\n  Address,\n  PhantasmaAPI,\n  PhantasmaKeys,\n  ScriptBuilder,\n  Transaction,\n} from 'phantasma-sdk-ts/public';\n```\n\nDeep imports are available for stable source areas:\n\n```ts\nimport { Transaction } from 'phantasma-sdk-ts/tx/transaction';\nimport { ScriptBuilder } from 'phantasma-sdk-ts/vm';\nimport { Bytes32 } from 'phantasma-sdk-ts/types/carbon/bytes32';\n```\n\nThe root export and `core/**` deep imports remain for existing consumers that still depend on the old SDK layout:\n\n```ts\nimport { PhantasmaTS } from 'phantasma-sdk-ts';\nimport { Transaction } from 'phantasma-sdk-ts/core/tx/Transaction';\n```\n\nThose compatibility paths are deprecated. New code should use `/public` or the lowercase module paths shown above.\n\n## RPC Example\n\n```ts\nimport { PhantasmaAPI } from 'phantasma-sdk-ts/public';\n\nconst api = new PhantasmaAPI('http://localhost:5172/rpc', null, 'localnet');\nconst height = await api.getBlockHeight('main');\nconst latestBlock = await api.getLatestBlock('main');\n\nconsole.log({ height, latestBlockHash: latestBlock.hash });\n```\n\nHigh-level RPC methods keep the historical `Promise\u003cT\u003e` shape for existing consumers. New code that wants explicit result-style handling can call `JSONRPCResult\u003cT\u003e()` and check `isRpcErrorResult(result)` or use `unwrapRpcResult(result)`.\n\n## Transaction Example\n\nThis builds and signs a local transaction object. It does not broadcast anything.\n\n```ts\nimport { PhantasmaKeys, ScriptBuilder, Transaction } from 'phantasma-sdk-ts/public';\n\nconst keys = PhantasmaKeys.generate();\nconst script = new ScriptBuilder().beginScript().emitVarString('example').endScript();\nconst tx = new Transaction('localnet', 'main', script, new Date(Date.now() + 5 * 60 * 1000), '');\n\ntx.signWithKeys(keys);\n\nconsole.log(tx.toStringEncoded(true));\n```\n\n## Examples\n\nThe `examples/` folder contains TypeScript examples that are compiled by `npm run test:package-exports`.\n\n- `examples/read-only-rpc.ts` reads block height and latest block data from an RPC endpoint.\n- `examples/build-transaction.ts` builds and signs a local transaction object without broadcasting.\n- `examples/logging.ts` enables and disables SDK logging.\n- `examples/invoke-raw-script.ts` invokes `Runtime.GetTokenDecimals(\"SOUL\")` through RPC and decodes the VM result.\n- `examples/scan-token-events.ts` reads one block and decodes token send/receive event data.\n- `examples/wallet-link.ts` shows the Phantasma Link and EasyConnect wallet connection shape.\n- `examples/carbon-link-signing.ts` builds a Carbon transfer message and forwards it to a Link v4 wallet for signing.\n\n## Compatibility Aliases\n\nThe SDK keeps legacy PascalCase methods and typoed aliases where existing consumers may still import them, for example `Transaction.FromBytes`, `ScriptBuilder.BeginScript`, `GetAddressFromLedeger`, `CarbonBlob.Serialize`, and `Serialization.Unserialize`.\n\nFor new code, prefer the canonical camelCase APIs:\n\n```ts\nTransaction.fromBytes(bytes);\nnew ScriptBuilder().beginScript().endScript();\nCarbonBlob.serialize(value);\nSerialization.deserialize(bytes, SomeType);\n```\n\nDeprecated aliases are intentionally covered by compatibility tests and deprecated-usage checks so new SDK code does not keep spreading them internally.\n\nFor consumer projects that want CI-visible diagnostics for legacy SDK calls,\nenable the type-aware ESLint rule `@typescript-eslint/no-deprecated`. TypeScript\nand editors read the SDK's `@deprecated` declarations, but `tsc` does not fail\nbuilds on deprecated API use by itself.\n\n## Development\n\n```bash\nnpm install\nnpm run typecheck\nnpm run lint\nnpm test\nnpm run test:package-exports\n```\n\nExamples under `examples/` are type-checked by `npm run test:package-exports`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantasma-io%2Fphantasma-sdk-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphantasma-io%2Fphantasma-sdk-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantasma-io%2Fphantasma-sdk-ts/lists"}