{"id":19747521,"url":"https://github.com/phantasma-io/phantasma-node-examples","last_synced_at":"2026-06-09T02:31:44.690Z","repository":{"id":237344292,"uuid":"770328803","full_name":"phantasma-io/Phantasma-node-examples","owner":"phantasma-io","description":"Phantasma Node / JS / TS code example to interact with the Phantasma Blockchain.","archived":false,"fork":false,"pushed_at":"2024-03-11T11:13:03.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T08:01:13.317Z","etag":null,"topics":[],"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/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}},"created_at":"2024-03-11T11:12:49.000Z","updated_at":"2024-03-11T12:19:46.000Z","dependencies_parsed_at":"2024-05-01T00:54:49.433Z","dependency_job_id":null,"html_url":"https://github.com/phantasma-io/Phantasma-node-examples","commit_stats":null,"previous_names":["phantasma-io/phantasma-node-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phantasma-io/Phantasma-node-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2FPhantasma-node-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2FPhantasma-node-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2FPhantasma-node-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2FPhantasma-node-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phantasma-io","download_url":"https://codeload.github.com/phantasma-io/Phantasma-node-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantasma-io%2FPhantasma-node-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34089326,"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-09T02:00:06.510Z","response_time":63,"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":[],"created_at":"2024-11-12T02:18:05.982Z","updated_at":"2026-06-09T02:31:44.672Z","avatar_url":"https://github.com/phantasma-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phantasma Node Examples\n\nThis repository contains a collection of examples demonstrating how to integrate with the Phantasma blockchain using the `phantasma-ts` library in a Node.js / TypeScript environment. These examples are designed to help developers understand the basics of Phantasma blockchain operations including account balance retrieval, transaction creation, signing, and sending, as well as wallet generation and management.\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [Setup](#setup)\n- [Examples](#examples)\n  - [Get User Balances](#get-user-balances)\n  - [Decode a Transaction Event Data](#decode-a-transaction-event-data)\n  - [Make a Transaction](#make-a-transaction)\n  - [Sign a Transaction](#sign-a-transaction)\n  - [Send a Transaction](#send-a-transaction)\n  - [Get a Transaction](#get-a-transaction)\n  - [Get WIF from Private Key](#get-wif-from-private-key)\n  - [Generate a Wallet from WIF](#generate-a-wallet-from-wif)\n  - [Generate a Wallet from Private Key](#generate-a-wallet-from-private-key)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n\n- You have installed Node.js and npm.\n- You are familiar with TypeScript and Node.js environments.\n\n## Setup\n\nClone the repository and install the dependencies:\n\n```sh\ngit clone https://github.com/phantasma-io/phantasma-node-examples.git\ncd phantasma-node-examples\nnpm install # Or bun install\n```\n\n## Examples\n\nEach example is a standalone script that illustrates a specific functionality of the Phantasma blockchain.\n\n### Get User Balances\n\nThis example demonstrates how to retrieve the balance of a specific account on the Phantasma blockchain.\n\n```js\n// Usage\nGetUserBalance(\"your-phantasma-address-here\");\n```\n\n### Decode a Transaction Event Data\n\nShows how to decode a transaction event data for a **TokenSend** and a **TokenReceive** event.\n\n```js\n// Usage\nDecodeTransactionTransferEventData(\"data field from the event\");\n```\n\n### Make a Transaction\n\nIllustrates how to create a transaction.\n\n```js\n// Usage\nMakeATransaction();\n```\n\n### Sign a Transaction\n\nShows how to sign a transaction with a given WIF.\n\n```js\n// Usage\nSignATransaction(yourTransactionObject);\n```\n\n### Send a Transaction\n\nDescribes the process of sending a signed transaction to the Phantasma network.\n\n```js\n// Usage\nSendATransaction(yourSignedTransactionObject);\n```\n\n### Get a Transaction\n\nExplains how to retrieve the details of a transaction using its hash.\n\n```js\n// Usage\nGetATransaction(\"your-transaction-hash-here\");\n```\n\n### Get WIF from Private Key\n\nConverts a private key into a Wallet Import Format (WIF) string.\n\n```js\n// Usage\nGetWifFromPrivateKey(\"your-private-key-here\");\n```\n\n### Generate a Wallet from WIF\n\nGenerates wallet details from a WIF string.\n\n```js\n// Usage\nGenerateAWalletFromWIF(\"your-wif-here\");\n```\n\n### Generate a Wallet from Private Key\n\nCreates a wallet using a given private key.\n\n```js\n// Usage\nGenerateAWalletFromPrivateKey(\"your-private-key-here\");\n```\n\n### Get Block by Height\n\nThis example demonstrates how to retrieve the Block by the height on the Phantasma Blockchain.\n\n```js\n// Usage\nGetBlockHeight(10);\n```\n\n### Check for new Blocks\n\nThis function continuously monitors the blockchain for new blocks. When it detects that the height of the chain has increased, it fetches the latest block and processes each transaction within it, specifically looking for \"TokenReceive\" events. When such an event is found, it triggers a predefined action.\n\n```js\n// Usage\nCheckForNewBlocks();\n```\n\n## Contributing\n\nContributions to the `phantasma-node-examples` repository are welcome. To contribute, please follow the instructions in [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantasma-io%2Fphantasma-node-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphantasma-io%2Fphantasma-node-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantasma-io%2Fphantasma-node-examples/lists"}