{"id":20800918,"url":"https://github.com/MystenLabs/minting-server","last_synced_at":"2025-05-11T16:31:59.839Z","repository":{"id":248832891,"uuid":"787844564","full_name":"MystenLabs/minting-server","owner":"MystenLabs","description":"A scalable system architecture that can process multiple Sui transactions in parallel using a producer-consumer worker scheme.","archived":false,"fork":false,"pushed_at":"2025-02-14T13:12:29.000Z","size":908,"stargazers_count":5,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-14T14:22:56.101Z","etag":null,"topics":["bullmq","concurrency","move","sui"],"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/MystenLabs.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-04-17T09:38:57.000Z","updated_at":"2025-02-14T13:12:32.000Z","dependencies_parsed_at":"2025-01-14T15:42:13.751Z","dependency_job_id":"cab9cc5e-3f72-4f9b-9c1a-55ee10de06c3","html_url":"https://github.com/MystenLabs/minting-server","commit_stats":null,"previous_names":["mystenlabs/minting-server"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystenLabs%2Fminting-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystenLabs%2Fminting-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystenLabs%2Fminting-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystenLabs%2Fminting-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MystenLabs","download_url":"https://codeload.github.com/MystenLabs/minting-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253595657,"owners_count":21933434,"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":["bullmq","concurrency","move","sui"],"created_at":"2024-11-17T18:16:03.318Z","updated_at":"2025-05-11T16:31:59.824Z","avatar_url":"https://github.com/MystenLabs.png","language":"TypeScript","funding_links":[],"categories":["dApp Development"],"sub_categories":["dApp Toolkits"],"readme":"# minting-server\n\nA system that can process multiple Sui transactions in parallel using\na producer-consumer worker scheme.\n\n## QuickStart\n\n### 1. Publish Your Smart Contracts\n\nEnsure that your smart contract is published and accessible. Refer to [the official guide](https://docs.sui.io/guides/developer/first-app/publish) for detailed instructions on how to publish a Sui smart contract(package).\n\n### 2. Download and unzip the latest release\n\nDownload the latest release from [releases](https://github.com/MystenLabs/minting-server/releases). Extract the contents of the downloaded file and navigate to the extracted folder, which will be your working directory.\n\nThe release file includes the following:\n\n- `smart_contract_config.yaml`: Specifies your contract's functions and the object types of their arguments.\n- `deploy.sh`: A script that deploys your minting server container network.\n- `docker-compose.yaml`: Defines the minting server services.\n\n### 3. Configure Environment and Smart Contract Files\n\nFill in the mandatory fields in the `.env` and `smart_contract_config.yaml` files to match your environment and contract specifics.\n\n### 4. Deploy the Container\n\nRun `chmod u+x deploy.sh \u0026\u0026 ./deploy.sh` to deploy the entire container setup, ensuring all necessary components and configurations are correctly initialized and running.\n\n### 5. Access the Dashboard\n\nMonitor the progress of the jobs by accessing the dashboard at the URL where you deployed the service, on port 3000.\n\nThe Dashboard provides comprehensive information about active, completed, and failed jobs.\n![Dashboard Overview](/media/DashboardOverview.png)\n\nIt offers detailed insights into the status of completed jobs and error messages for failed transactions.\n![Completed Jobs](/media/CompletedJobs.png)\n![Failed Jobs](/media/FailedJobs.png)\n\n## Implementation details\n\n- Runtime: https://bun.sh/\n- Sequence and C4 diagrams can be found inside `docs/`\n\n## Local Setup\n\nTo test the system locally, you need to first publish an example smart contract.\nWe provide an example contract in the `move` directory.\n\n[Optional] Export an `ADMIN_ADDRESS` in your terminal with the address you want to use as the admin. Otherwise, the current CLI selected address will be used.\n\n[Optional] Export an `ADMIN_PHRASE` in your terminal if you want to use a brand new wallet. Otherwise, the current CLI selected wallet will be used.\n\nSimply run `cd move/ \u0026\u0026 chmod +x ./publish.sh \u0026\u0026 ./publish.sh` to deploy the contract to the Sui network.\nA `.publish.res.json` file will be generated with important information that you will need to set up the cluster.\nThese fields are used to configure the `request_processor` service and test the system using an example smart contract.\n\nCreate a `.env` file to the root directory as indicated in the `.env.example` file.\n\nThen, to set up the cluster simply run:\n\n`bun run deploy-${ENV}`\n\nWhere `ENV` can be `local` or `prod`.\n\n\u003e Tip: to quickly test your changes back to back, rebuild the services use `docker compose down \u0026\u0026 docker compose up -d --build --force-recreate`.\n\nThis will generate a network of the containers:\n\n- `request_handler`: The web server (producer) that accepts requests (jobs) and saves them to the `queue` service.\n  You can access a [dashboard](https://github.com/felixmosh/bull-board) to monitor all the jobs on `localhost:3000`.\n- `queue`: A redis database that contains the queue of the requests (jobs) to be processed.\n- `request_processor`: A worker that processes (consumes) the requests that have been queued up.\n- `notifier`: A websocket server that exposes (publishes) the results of thef jobs to clients.\n  You can open a websocket connection in your terminal with `websocat ws://localhost:3001`.\n\nIt is also necessary to create a `request_processor/smart_contract_config.yaml` where for each function\nof the smart contract you must provide the function name the function arguments types.\n\ne.g. assuming the smart contract has a function `mint_nft` that takes an `object` as an argument and a\n`modify_nft` function that takes a `pure` type argument and an `object` type argument, the configuration file would look like this:\n\n```yaml\nsmart_contract_functions:\n  - name: \"mint_nft\" #\n    types_of_arguments: [\"object\"]\n  - name: \"modify_nft\" #\n    types_of_arguments: [\"pure\", \"object\"]\n```\n\nSo if you want to test the system (calling the `mint_nft`),\nyou can send a POST request to the `request_handler` service with the following curl command:\n\n```bash\ncurl --request POST \\\n  --url 'http://localhost:3000/?=' \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n\t\"smartContractFunctionName\": \"mint_nft\",\n\t\"smartContractFunctionArguments\": [\"0x9320eaaf945570b1baf7607f98a9cf5585fdcb8ed09d46da93199fee16b48196\"],\n\t\"receiverAddress\": \"0xe40c8cf8b53822829b3a6dc9aea84b62653f60b771e9da4bd4e214cae851b87b\"\n}'\n```\n\n## Architecture diagrams\n\nThe architecture of the system is described in the `docs/` directory.\nTo edit the diagrams, you can edit the `docs/workspace.dsl` file.\n\nTo see an interactive version of the diagrams: being on the project's root directory,\nrun an instance of a `structurizr` container with: `docker run -it --rm -p 8080:8080 -v ./docs:/usr/local/structurizr structurizr/lite:latest `\n\nAccess the UI on `localhost:8080`.\n\n## Tests\n\n### Request Handler\n\nThe endpoint tests in the request handler require that the `queue` service is already up and running,\nso if you need to try it out, make sure to run first from the repo's root dir `docker compose up -d queue`\nand then `cd request_handler \u0026\u0026 bun test`.\n\n### Load testing\n\nInstall k6 with `brew install k6`.\n\nInstall ioredis with `bun install ioredis`.\n\nexport the redis password as an env variable\n`export REDIS_PASSWORD=\u003cyour_password\u003e` so that it can be read by `stats.ts`.\n\nRun with: `cd load_testing/ \u0026\u0026 k6 run --vus \u003cnumber of virtual users\u003e --duration \u003ctime in seconds\u003e mint.js`.\n\nFor example vus = 2 and duration = 30s\n\nAt the end of the test runs, a new `summary.html` file will be generated that contains the results of k6.\n\nIf you need statistics about average response time, requests per second etc from the moment a request is handled to the moment it's completed, use `bun stats.ts`.\n\n## Calculate gas cost\n\nTo define the variables PTE_INITIAL_COIN_BALANCE and PTE_MINIMUM_COIN_BALANCE, use the dryRunTransactionBlock method from [Typescript SDK](https://sdk.mystenlabs.com/typescript). This approach helps you estimate the transaction costs by simulating the execution without actually performing it.\n\nFor example, you can use a script like the following:\n\n```typescript\nconst tx = new Transaction();\n\nlet result = tx.moveCall({\ntarget: // contract function to call,\narguments: [\n// the arguments of your function\n   ],\n});\n\nconst txBytes = await tx.build({ client: suiClient });\nlet resp = await suiClient.dryRunTransactionBlock({\n    transactionBlock: txBytes,\n});\n\nif (resp.effects.status.status !== \"success\") {\n    console.log(resp.effects);\n    return undefined;\n}\n\nconsole.log(\"Success\");\nconst amount = resp.balanceChanges[0]?.amount;\nconsole.log(amount);\nreturn amount;\n```\n\nNote that the result of this function will vary based on the move calls included in the transaction and the specific arguments provided.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMystenLabs%2Fminting-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMystenLabs%2Fminting-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMystenLabs%2Fminting-server/lists"}