{"id":32639824,"url":"https://github.com/gigaquads/solana-program","last_synced_at":"2025-10-31T02:16:07.931Z","repository":{"id":137202652,"uuid":"428763635","full_name":"gigaquads/solana-program","owner":"gigaquads","description":"Lean, high-level client for interacting with on-chain Solana programs from typescript.","archived":false,"fork":false,"pushed_at":"2021-12-25T00:31:38.000Z","size":139,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-22T00:44:10.926Z","etag":null,"topics":["anchor","blockchain","client","sol","solana"],"latest_commit_sha":null,"homepage":"","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/gigaquads.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,"publiccode":null,"codemeta":null}},"created_at":"2021-11-16T18:05:08.000Z","updated_at":"2024-02-27T20:55:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2e9c9c5-f627-4a4d-9dd5-ab33778532df","html_url":"https://github.com/gigaquads/solana-program","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gigaquads/solana-program","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigaquads%2Fsolana-program","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigaquads%2Fsolana-program/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigaquads%2Fsolana-program/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigaquads%2Fsolana-program/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gigaquads","download_url":"https://codeload.github.com/gigaquads/solana-program/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigaquads%2Fsolana-program/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281914594,"owners_count":26583095,"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","status":"online","status_checked_at":"2025-10-31T02:00:07.401Z","response_time":57,"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":["anchor","blockchain","client","sol","solana"],"created_at":"2025-10-31T02:15:36.944Z","updated_at":"2025-10-31T02:16:07.922Z","avatar_url":"https://github.com/gigaquads.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solana Program\n\n`solana-program` builds upon @solana/web3.js with the intent of reducing the\namount of boilerplate code and lower-level data wrangling necessary when\ndeveloping client-side Solana apps. Our goal is to provide a more intuitive,\nobject-oriented API.\n\n## Installing\n\n`yarn add solana-program` or `npm install solana-program`.\n\n## Building \u0026 Executing Instructions\n\nCustom instructions can be built using the `InstructionBuilder` API. For example:\n\n```typescript\nconst instr = program\n  .instruction()\n  .account(user.publicKey, { isSigner: true, isWritable: true })\n  .account(dataAccountPublicKey, { isWritable: true })\n  .data(data);\n```\n\nYou can add one or more `InstructionBuilder` objects to a transaction, using\n`TransactionBuilder`, like so:\n\n```typescript\nconst tx = Solana.begin().add(instr).sign(user);\nconst signature = await tx.execute();\n```\n\n## Querying Program Accounts\n\n### Querying in `@solana/web3.js`\n\nIn order to retrieve a program's accounts using `@solana/web3.js`, you normally\nhave to use some form of the `getProgramAccounts` function. Queries can be\nfiltered according to two main criteria:\n\n1. The size (in bytes) of the target account's data.\n2. Contents of specific slices of base58-encoded data.\n\n#### Example:\n\nSuppose we have an account that stores an initial \"tag\" byte, which indicates\nwhat \"type\" of account something is, as well as a \"username\" string and an \"age\"\nint. Using only web3.js to select accounts that match this pattern looks\nsomehing like this:\n\n```typescript\nconst results = await getParsedProgramAccounts(programId, {\n  encoding: 'jsonParsed',\n  filters: [\n    {\n      memcmp: {\n        offset: 0,\n        bytes: b58.encode([1]),\n      },\n    },\n    {\n      memcmp: {\n        offset: 2,\n        bytes: b58.encode(Buffer.from('coolperson123')),\n      },\n    },\n    {\n      dataSize: 1 + 1 + 256,\n    },\n  ],\n});\n```\n\n### Querying in `solana-program`\n\nIn contrast, `solana-program` provides a more intuitive interface. The same\nquery would be written like this:\n\n```typescript\n// example data structure we're storing in account\nclass Comment extends ProgramObject {\n  @field('u8')\n  tag: number = 1;\n\n  @field('u8')\n  age?: number;\n\n  @field('String', { space: 256 })\n  username?: string;\n}\n\n// select all accounts with username glorp. note that the dataSize filter is\n// automatically added; however, it can be set explicitly, via\n// program.select(Comment).size(...)...\nconst accounts = await program\n  .select(Comment)\n  .match({ tag: 1, username: 'coolperson123' })\n  .execute();\n```\n\n## Basic Example\n\nThis is a complete example of building a client for a Solana program that simply\ninitializes and sets a \"lucky number\" in an account.\n\n```typescript\nclass LuckyNumber extends ProgramObject {\n  @field('u8')\n  value?: number;\n}\n\nclass LuckyNumberProgram extends Program {\n  public async main(user: Keypair) {\n    await Solana.initialize();\n\n    const seed = 'lucky-number'\n    const key = await this.deriveAddress(user.publicKey, seed);\n    const account = await this.getAccount(LuckyNumber, luckNumberKey);\n    const luckyNumber = Math.round(100 * Math.random());\n    const tx = Solana.begin();\n\n    if (account === null) {\n      const space = 1;\n      const instr = this.createAccountWithSeed(user, seed, key, space)\n      console.log('creating \"lucky number\" account');\n      tx.add(instr);\n    }\n    console.log('setting new \"lucky number\"');\n    tx.add(this.setLuckyNumber(user, key, luckyNumber));\n\n    const signature = await tx.sign(user).execute();\n    console.log('transaction signature:', signature);\n  }\n\n  public setLuckyNumber(\n    user: Address, key: Address, value: number,\n  ): CustomInstructionBuilder {\n    return this.instruction(0)  // 0 is the OP code of the instruction\n      .account(user, { isWritable: true, isSigner: true });\n      .account(key, { isWritable: true, });\n      .data(new LuckyNumber({ value }))\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigaquads%2Fsolana-program","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgigaquads%2Fsolana-program","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigaquads%2Fsolana-program/lists"}