{"id":13573023,"url":"https://github.com/chainapsis/cosmosjs","last_synced_at":"2025-04-04T11:31:10.619Z","repository":{"id":54081446,"uuid":"206756512","full_name":"chainapsis/cosmosjs","owner":"chainapsis","description":null,"archived":true,"fork":false,"pushed_at":"2021-03-09T16:52:51.000Z","size":711,"stargazers_count":35,"open_issues_count":10,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T02:45:40.375Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainapsis.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}},"created_at":"2019-09-06T09:07:36.000Z","updated_at":"2024-09-21T19:40:34.000Z","dependencies_parsed_at":"2022-08-13T06:31:36.637Z","dependency_job_id":null,"html_url":"https://github.com/chainapsis/cosmosjs","commit_stats":null,"previous_names":["everett-protocol/cosmosjs"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainapsis%2Fcosmosjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainapsis%2Fcosmosjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainapsis%2Fcosmosjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainapsis%2Fcosmosjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainapsis","download_url":"https://codeload.github.com/chainapsis/cosmosjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247170139,"owners_count":20895416,"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-08-01T15:00:27.049Z","updated_at":"2025-04-04T11:31:05.605Z","avatar_url":"https://github.com/chainapsis.png","language":"TypeScript","funding_links":[],"categories":["Client Libraries","Frameworks and tools"],"sub_categories":["JavaScript"],"readme":"\n\u003ch1  align=\"center\"\u003eWelcome to cosmosjs 👋\u003c/h1\u003e\n\u003cp\u003e\n\u003cimg  src=\"https://img.shields.io/badge/version-0.0.1-blue.svg?cacheSeconds=2592000\" /\u003e\n\u003ca  href=\"https://twitter.com/Chainapsis\"\u003e\n\u003cimg  alt=\"Twitter: Chainapsis\"  src=\"https://img.shields.io/twitter/follow/Chainapsis.svg?style=social\"  target=\"_blank\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e General purpose library for cosmos-sdk\n\nOur goal is to create a general purpose library for the Cosmos ecosystem. Through this library, blockchains that use cosmos-sdk, as well as Cosmos hub (Gaia), can create their own API for JavaScript client side.  \n\nDocumentation can be found [here](https://chainapsis.github.io/cosmosjs/).  \n\n## Install\n```sh\nnpm install --save @chainapsis/cosmosjs\n```\n\n## How to use\nMore examples will be provided [here](https://github.com/chainapsis/cosmosjs/tree/master/example) soon.\n```ts\nimport { GaiaApi } from \"../src/gaia/api\";\nimport { LedgerWalletProvider } from \"../src/core/ledgerWallet\";\nimport { MsgSend } from \"../src/x/bank\";\nimport { AccAddress } from \"../src/common/address\";\nimport { Coin } from \"../src/common/coin\";\nimport { Int } from \"../src/common/int\";\nimport bigInteger from \"big-integer\";\n\n(async () =\u003e {\n  // Here you can see the type of transport\n  // https://github.com/LedgerHQ/ledgerjs\n  const wallet = new LedgerWalletProvider(\"HID\", \"cosmos\");\n  /*\n    // You should not use local wallet provider in production\n    const wallet = new LocalWalletProvider(\n    \"anger river nuclear pig enlist fish demand dress library obtain concert nasty wolf episode ring bargain rely off vibrant iron cram witness extra enforce\"\n  );\n  */\n\n  const api = new GaiaApi({\n    chainId: \"cosmoshub-3\",\n    walletProvider: wallet,\n    rpc: \"http://localhost:26657\",\n    rest: \"http://localhost:1317\"\n  });\n\n  // You should sign in before using your wallet\n  await api.enable();\n\n  const key = (await api.getKeys())[0];\n  const accAddress = new AccAddress(key.address, \"cosmos\");\n\n  await api.sendMsgs(\n    [\n      new MsgSend(accAddress, accAddress, [new Coin(\"uatom\", new Int(\"1\"))]),\n      new MsgSend(accAddress, accAddress, [new Coin(\"uatom\", new Int(\"1\"))])\n    ],\n    {\n      // If account number or sequence is omitted, they are calculated automatically\n      gas: bigInteger(60000),\n      memo: \"test\",\n      fee: new Coin(\"uatom\", new Int(\"111\"))\n    },\n    \"commit\"\n  );\n})();\n```\n\n## Making your own messages\nBelow is Gaia's basic sending message.\nMore examples are [here](https://github.com/chainapsis/cosmosjs/tree/master/src/x).\n```ts\nimport { Amino, Type } from \"ts-amino\";\nconst { Field, Concrete, DefineStruct } = Amino;\nimport { Msg }  from \"../../core/tx\";\nimport { AccAddress } from \"../../common/address\";\nimport { Coin } from \"../../common/coin\";\nimport { Int } from \"../../common/int\";\n\n@Concrete(\"cosmos-sdk/MsgSend\")\n@DefineStruct()\nexport class MsgSend extends Msg {\n  @Field.Defined(0, {\n    jsonName:  \"from_address\"\n  })\n  public fromAddress: AccAddress;\n\n  @Field.Defined(1, {\n    jsonName:  \"to_address\"\n  })\n  public toAddress: AccAddress;\n\n  @Field.Slice(\n    2,\n    { type: Type.Defined },\n    {\n      jsonName: \"amount\"\n    }\n  )\n  public amount: Coin[];\n\n  constructor(fromAddress: AccAddress, toAddress: AccAddress, amount: Coin[]) {\n    super();\n    this.fromAddress = fromAddress;\n    this.toAddress = toAddress;\n    this.amount = amount;\n  }\n\n  public getSigners(): AccAddress[] {\n    return [this.fromAddress];\n  }\n\n  /**\n  * ValidateBasic does a simple validation check that\n  * doesn't require access to any other information.\n  * You can throw error in this when msg is invalid.\n  */\n  public validateBasic(): void {\n    for (const coin of this.amount) {\n      if (coin.amount.lte(new  Int(0))) {\n        throw new Error(\"Send amount is invalid\");\n      }\n    }\n  }\n  \n  /**\n  * Get the canonical byte representation of the Msg.\n  * @return Return sorted by alphabetically amino encoded json by default.\n  */\n  // public getSignBytes(): Uint8Array {\n  //   return Buffer.from(sortJSON(marshalJson(this)), \"utf8\");\n  // }\n}\n```\n\n## Making api for your own blockchain\nCheck out [this](https://github.com/chainapsis/cosmosjs/tree/master/src/gaia).\n\n## Run tests\n```sh\nnpm run test\n```\n\n## Author\n👤 **chainapsis**\n* Twitter: [@Chainapsis](https://twitter.com/chainapsis)\n* Github: [chainapsis](https://github.com/chainapsis)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainapsis%2Fcosmosjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainapsis%2Fcosmosjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainapsis%2Fcosmosjs/lists"}