{"_id":"@cuonghx.ngen/bsc-unity-sdk","name":"@cuonghx.ngen/bsc-unity-sdk","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@cuonghx.ngen/bsc-unity-sdk","version":"0.0.1","main":"dist/index.js","directories":{"example":"examples"},"scripts":{"build":"webpack"},"keywords":[],"author":{"name":"0xcuonghx"},"license":"ISC","description":"SDK for seamless integration with the BSC network (sending sol, purchasing item, get balance) in pure JavaScript, making it easy to embed within Unity. (JS, Unity)","devDependencies":{"ts-loader":"^9.5.1","typescript":"^5.5.2","webpack":"^5.92.1","webpack-cli":"^5.1.4"},"dependencies":{"viem":"^2.21.57"},"_id":"@cuonghx.ngen/bsc-unity-sdk@0.0.1","gitHead":"b6fdf11ff1c56344bf1c9d64ab5f371859746a32","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-MZbs9aixSe+BZ2xwJClrwVYzbf5R2XlPbwluRWaQzM668yJR4Cm5qd71G/VoIRepowFAH0EYUlgE+FMQ/jTU+w==","shasum":"4a6fa63f3fa92fcda8102a0628752f9f024f3596","tarball":"https://registry.npmjs.org/@cuonghx.ngen/bsc-unity-sdk/-/bsc-unity-sdk-0.0.1.tgz","fileCount":5,"unpackedSize":212335,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF897htu/kSrO1T8tJxtQePaQmr5QBGoRek48rf39i5nAiEA+TwOqDw2ABK5AT/m8CBxwQjr4To5A5kWatBwc7nqH6A="}]},"_npmUser":{"name":"cuonghx.ngen","email":"cuonghx.ngen@gmail.com"},"maintainers":[{"name":"cuonghx.ngen","email":"cuonghx.ngen@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bsc-unity-sdk_0.0.1_1735026360826_0.855942538503401"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-24T07:46:00.760Z","0.0.1":"2024-12-24T07:46:01.026Z","modified":"2024-12-24T07:46:01.277Z"},"maintainers":[{"name":"cuonghx.ngen","email":"cuonghx.ngen@gmail.com"}],"description":"SDK for seamless integration with the BSC network (sending sol, purchasing item, get balance) in pure JavaScript, making it easy to embed within Unity. (JS, Unity)","keywords":[],"author":{"name":"0xcuonghx"},"license":"ISC","readme":"# Unity SDK\n\nSDK for seamless integration with the BSC network (sending sol, purchasing item, get balance) in pure JavaScript, making it easy to embed within Unity. (JS, Unity)\n\n## Features\n\n- Interact with BSC wallet\n- Purchasing item by sending BSC transactions\n\n## Payment process\n\n- The user sends a transaction with an attached memo containing userId and itemId.\n- The indexer service polls via RPC to confirm the purchase.\n- Upon successful confirmation, the indexer service notifies the game server to update the purchased resources.\n\n## Technique\n\n- viem: a JavaScript library that provides tools for interacting with the BSC blockchain\n- webpack: a powerful JavaScript bundler that compiles and packages modules, assets, and dependencies into optimized bundles for use in Unity HTML5.\n\n# Getting Started\n\n## Install with CDN\n\n- Add the script to your HTML file:\n\n```html\n<script src=\"https://unpkg.com/@cuonghx.ngen/bsc-unity-sdk@latest\"></script>\n```\n\n- ℹ️ If you don't want auto-update the library, pass concrete version instead of latest, e.g.\n\n```html\n<script src=\"https://unpkg.com/@cuonghx.ngen/bsc-unity-sdk@0.0.1\"></script>\n```\n\n- Add `load-sdk.js` scripts\n\n```html\n<script src=\"./load-sdk.js\"></script>\n```\n\n- Prepare `load-sdk.js` file\n\n```js\nconst plugin = new BscUnitySDK.default({\n  privateKey: \"xxx\",\n  purchaseItemAddress: \"xxx\",\n});\n```\n\n## Install with npm\n\n```shell\nnpm i @cuonghx.ngen/bsc-unity-sdk\n```\n\n# Usage\n\n- Using with Unity throw `jslib` plugin\n\n```jslib\nmergeInto(LibraryManager.library, {\n  GetPublicAddress: function () {\n    var returnStr = plugin.getPublicAddress();\n    var bufferSize = lengthBytesUTF8(returnStr) + 1;\n    var buffer = _malloc(bufferSize);\n    stringToUTF8(returnStr, buffer, bufferSize);\n    return buffer;\n  },\n  PurchaseItem: async function (args) {\n    var returnStr = await plugin.purchaseItem(UTF8ToString(args));\n    var bufferSize = lengthBytesUTF8(returnStr) + 1;\n    var buffer = _malloc(bufferSize);\n    stringToUTF8(returnStr, buffer, bufferSize);\n    return buffer;\n  },\n});\n```\n\n| Function              | Description                           |\n| --------------------- | ------------------------------------- |\n| plugin.getPublicKey() | Return account connected address      |\n| plugin.purchaseItem() | Send transaction form purchasing item |\n| plugin.getBalance()   | Get balance of connected address      |\n\n## Examples\n\n- Complete example via [Examples](./examples/)\n\n## Authors and acknowledgment\n\nPlayshub Team\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Project status\n\nWe are still developing this project following the roadmap in here: https://playshub.io/\n","readmeFilename":"README.md"}