{"id":22275727,"url":"https://github.com/deepsquare-io/deepsquare-client","last_synced_at":"2025-07-28T16:32:26.869Z","repository":{"id":132500538,"uuid":"601562896","full_name":"deepsquare-io/deepsquare-client","owner":"deepsquare-io","description":"DeepSquare typescript SDK","archived":false,"fork":false,"pushed_at":"2024-02-14T00:11:34.000Z","size":41424,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-15T23:50:56.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepsquare-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-02-14T10:34:53.000Z","updated_at":"2024-02-14T08:53:01.000Z","dependencies_parsed_at":"2024-02-07T15:52:18.527Z","dependency_job_id":null,"html_url":"https://github.com/deepsquare-io/deepsquare-client","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepsquare-io%2Fdeepsquare-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepsquare-io%2Fdeepsquare-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepsquare-io%2Fdeepsquare-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepsquare-io%2Fdeepsquare-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepsquare-io","download_url":"https://codeload.github.com/deepsquare-io/deepsquare-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227932626,"owners_count":17843136,"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":[],"created_at":"2024-12-03T14:11:48.443Z","updated_at":"2024-12-03T14:11:49.259Z","avatar_url":"https://github.com/deepsquare-io.png","language":"TypeScript","readme":"# DeepSquare SDK\n\nThis package provides a straightforward interface to the DeepSquare Grid. It allows users to easily **submit jobs** to the Grid, **pay** with their credits, and retrieve job information for status checks and cost tracking.\n\n## Introduction\n\nThe DeepSquare Grid operates through [workflows](https://docs.deepsquare.run/workflow/getting-started/part-1-helloworld#hello-world-workflow). These workflows break down operations to be run on the Grid into simple steps, providing easy access to high-performance computing resources.\n\nStart your journey with our platform by following the guide below.\n\nStay updated with the latest changes and enhancements by following [this repository](https://github.com/deepsquare-io/deepsquare-client).\n\nWe are excited to see what you'll create!\n\n## Set up the library\n\n### Installation\n\nInstall the library with:\n\n```shell\nnpm install @deepsquare/deepsquare-client viem\n```\n\nViem is used as the main Ethereum runtime. It can be used for with the browser runtime, or with a Node.js runtime.\n\n## Setting up a Wallet and Obtaining Credits\n\n### Prerequisites\n\nEnsure you have:\n\n- A crypto wallet and your associated private key. You can use wallets like `MetaMask` or `Core Wallet` and/or CLI tools like `avalanche-cli`\n\n- Sufficient [credit tokens](#obtaining-credits) for job costs, and a minor amount of SQUARE tokens for transaction fees on the DeepSquare `Deepji network`:\n\nDeepSquare network details:\n\n```yaml\nNetwork name: DeepSquare Testnet C-Chain\nRPC URL: https://testnet.deepsquare.run/rpc\nChain ID: 179188\n```\n\nYou can automatically add this network if you have a wallet extension like `MetaMask` or `Core Wallet` installed on your browser. Visit [app.deepsquare.run](https://app.deepsquare.run/) and connect to the app via your crypto wallet. A pop-up will prompt you to install the DeepSquare network.\n\n### Obtaining Credits\n\nUsing the platform requires credit tokens for job execution and a minor amount of SQUARE tokens to cover the fees. Apply for free credits through [this form](https://app.deepsquare.run/credits).\n\n## Getting Started\n\nHere is a high-level overview of the library covering various functionalities including setting the credit allowance, submitting a job, retrieving job information, retrieving job logs, and cancelling a job. Detailed instructions on using the client are available in the [examples](https://chat.openai.com/examples) directory.\n\nPlease refer to the [official DeepSquare documentation](https://docs.deepsquare.run/workflow/workflow-api-reference/job) for a detailed API reference and job specification.\n\n### Compatibility Matrix\n\nTo launch a job you technically submit a transaction to a smart contract called the meta-scheduler.\nIn general, you will be using the address corresponding to the `main` SDK Version, the deprecated version is the last contract supported that will be discontinued when a new version of the SDK is released.\n\n| SDK Version          | Meta-scheduler Smart-contract address      |\n| -------------------- | ------------------------------------------ |\n| v0.14.X              | 0x7524fBB0c1e099A4A472C5A7b0B1E1E3aBd3fE97 |\n| v0.13.X              | 0x196A7EB3E16a8359c30408f4F79622157Ef86d7c |\n| v0.12.X              | 0xeD6Deb4c6E7e5D35c0d0FE3802663142e3E266da |\n| v0.11.X              | 0x3707aB457CF457275b7ec32e203c54df80C299d5 |\n| v0.10.X (deprecated) | 0xc9AcB97F1132f0FB5dC9c5733B7b04F9079540f0 |\n\n### Submitting a job\n\nIn this example we assume you have a `PRIVATE_KEY` (see section [Setup a wallet](#set-up-the-wallet)) and a `METASCHEDULER_ADDR` (see section [Compatibility Matrix](#compatibility-matrix) below).\n\n```typescript\nimport DeepSquareClient from \"@deepsquare/deepsquare-client\";\nimport { createLoggerClient } from \"@deepsquare/deepsquare-client/grpc/node\";\nimport type { Hex } from \"viem\";\n\nasync function main() {\n  // Create the DeepSquareClient\n  const deepSquareClient = DeepSquareClient.withPrivateKey(\n    process.env.PRIVATE_KEY as Hex, // Hex is a `0x{string}`\n    createLoggerClient, // Select the logger (use node or browser depending on the platform)\n    process.env.METASCHEDULER_ADDR as Hex, // Passing the smart-contracts address explicitely avoid unexpected changes.\n  );\n}\n```\n\nLet's run a simple \"Hello World\" job with 1000 credits allocated.\n\nIn this example, we assume that you have an allowance of at least 1000 credits. You can establish this allowance either from the [nexus portal](https://app.deepsquare.run/) header or by using the `setAllowance` method.\n\n```typescript\nimport DeepSquareClient from \"@deepsquare/deepsquare-client\";\nimport { createLoggerClient } from \"@deepsquare/deepsquare-client/grpc/node\";\nimport { parseEther, type Hex } from \"viem\";\n\nasync function main() {\n  // ...\n\n  const myJob = {\n    resources: {\n      tasks: 1,\n      gpus: 0,\n      cpusPerTask: 1,\n      memPerCpu: 1024,\n    },\n    enableLogging: true,\n    steps: [\n      {\n        name: \"hello world\",\n        run: {\n          command: 'echo \"Hello World\"',\n        },\n      },\n    ],\n  };\n\n  // 'Allowance' lets DeepSquare use a set amount of your tokens to pay for jobs, like a spending limit.\n  // DeepSquare can only use up to the limit you set, ensuring control and security over your wallet.\n  const depositAmount = parseEther(\"1000\");\n  await deepSquareClient.setAllowance(depositAmount);\n\n  // Launch the job\n  // The 'credits' specify how much of your allowance is used for a particular job. For instance,\n  // if you set an allowance of 1000 and use 100 credits for a job, you'll still have 900 in allowance\n  // for future jobs, no need to set a new allowance until your total credits exceed it.\n  const credits = parseEther(\"1000\");\n  const jobId = await deepSquareClient.submitJob(myJob, \"myJob\", credits);\n}\n\nmain();\n```\n\n\u003e [!WARNING]\n\u003e The amount must be a `bigint` with 18 decimals (like Wei). The easiest is to use the `parseEther` utility from Viem to convert a number to bigint with the right number of digits.\n\n### More examples\n\nMore complete examples are available in the [examples directory](https://github.com/deepsquare-io/deepsquare-client/tree/main/examples).\n\n## Job specification\n\nA Job is a finite sequence of instructions.\n\nThe API reference can be read [in the official DeepSquare documentation](https://docs.deepsquare.run/workflow/workflow-api-reference/job).\n\n## Troubleshooting\n\nIf you run into any issues:\n\n- Ensure that the environment variables in the `.env` file are set correctly.\n- Verify that you have a stable internet connection and can access the DeepSquare platform.\n- Check that you have the required permissions and resources on the platform to submit jobs.\n\nIf these steps don't resolve the issue:\n\n- Create an [issue](https://github.com/deepsquare-io/deepsquare-client/issues) on the DeepSquare GitHub repository, providing a detailed account of the problem.\n- Reach the [Discord community](https://discord.gg/KYWh28BkUE) for direct support and engaging discussions.\n\nThe DeepSquare team is always happy to help you and ensure a seamless experience for you.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepsquare-io%2Fdeepsquare-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepsquare-io%2Fdeepsquare-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepsquare-io%2Fdeepsquare-client/lists"}