{"id":16193501,"url":"https://github.com/pyramation/thorchain","last_synced_at":"2025-04-07T15:18:52.267Z","repository":{"id":65231825,"uuid":"587978630","full_name":"pyramation/thorchain","owner":"pyramation","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-30T13:45:27.000Z","size":1268,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-13T02:03:53.624Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyramation.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":"2023-01-12T03:01:59.000Z","updated_at":"2024-10-07T16:09:11.000Z","dependencies_parsed_at":"2024-11-03T05:02:15.905Z","dependency_job_id":"af64aed8-2c99-4ad6-8170-73c9d1537b44","html_url":"https://github.com/pyramation/thorchain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fthorchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fthorchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fthorchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyramation%2Fthorchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyramation","download_url":"https://codeload.github.com/pyramation/thorchain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675598,"owners_count":20977378,"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-10-10T08:15:02.887Z","updated_at":"2025-04-07T15:18:52.187Z","avatar_url":"https://github.com/pyramation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thorchain\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg\" width=\"80\"\u003e\u003cbr /\u003e\n    thorchain\n\u003c/p\u003e\n\n\n## install\n\n```sh\nnpm install thorchain\n```\n## Table of contents\n\n- [thorchain](#thorchain)\n  - [Install](#install)\n  - [Table of contents](#table-of-contents)\n- [Usage](#usage)\n    - [RPC Clients](#rpc-clients)\n    - [Composing Messages](#composing-messages)\n        - Cosmos, CosmWasm, and IBC\n            - [CosmWasm](#cosmwasm-messages)\n            - [IBC](#ibc-messages)\n            - [Cosmos](#cosmos-messages)\n- [Wallets and Signers](#connecting-with-wallets-and-signing-messages)\n    - [Stargate Client](#initializing-the-stargate-client)\n    - [Creating Signers](#creating-signers)\n    - [Broadcasting Messages](#broadcasting-messages)\n- [Advanced Usage](#advanced-usage)\n- [Developing](#developing)\n- [Credits](#credits)\n\n## Usage\n### RPC Clients\n\n```js\nimport { thorchain } from 'thorchain';\n\nconst { createRPCQueryClient } = thorchain.ClientFactory; \nconst client = await createRPCQueryClient({ rpcEndpoint: RPC_ENDPOINT });\n\n// now you can query the cosmos modules\nconst balance = await client.cosmos.bank.v1beta1\n    .allBalances({ address: 'thorchain1addresshere' });\n\n// you can also query the thorchain modules\nconst balances = await client.thorchain.exchange.v1beta1\n    .exchangeBalances()\n```\n\n### Composing Messages\n\nImport the `thorchain` object from `thorchain`. \n\n```js\nimport { thorchain } from 'thorchain';\n\nconst {\n    createSpotLimitOrder,\n    createSpotMarketOrder,\n    deposit\n} = thorchain.exchange.v1beta1.MessageComposer.withTypeUrl;\n```\n\n#### CosmWasm Messages\n\n```js\nimport { cosmwasm } from \"thorchain\";\n\nconst {\n    clearAdmin,\n    executeContract,\n    instantiateContract,\n    migrateContract,\n    storeCode,\n    updateAdmin\n} = cosmwasm.wasm.v1.MessageComposer.withTypeUrl;\n```\n\n#### IBC Messages\n\n```js\nimport { ibc } from 'thorchain';\n\nconst {\n    transfer\n} = ibc.applications.transfer.v1.MessageComposer.withTypeUrl\n```\n\n#### Cosmos Messages\n\n```js\nimport { cosmos } from 'thorchain';\n\nconst {\n    fundCommunityPool,\n    setWithdrawAddress,\n    withdrawDelegatorReward,\n    withdrawValidatorCommission\n} = cosmos.distribution.v1beta1.MessageComposer.fromPartial;\n\nconst {\n    multiSend,\n    send\n} = cosmos.bank.v1beta1.MessageComposer.fromPartial;\n\nconst {\n    beginRedelegate,\n    createValidator,\n    delegate,\n    editValidator,\n    undelegate\n} = cosmos.staking.v1beta1.MessageComposer.fromPartial;\n\nconst {\n    deposit,\n    submitProposal,\n    vote,\n    voteWeighted\n} = cosmos.gov.v1beta1.MessageComposer.fromPartial;\n```\n\n## Connecting with Wallets and Signing Messages\n\n⚡️ For web interfaces, we recommend using [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit). Continue below to see how to manually construct signers and clients.\n\nHere are the docs on [creating signers](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) in cosmos-kit that can be used with Keplr and other wallets.\n\n### Initializing the Stargate Client\n\nUse `getSigningthorchainClient` to get your `SigningStargateClient`, with the proto/amino messages full-loaded. No need to manually add amino types, just require and initialize the client:\n\n```js\nimport { getSigningthorchainClient } from 'thorchain';\n\nconst stargateClient = await getSigningthorchainClient({\n  rpcEndpoint,\n  signer // OfflineSigner\n});\n```\n### Creating Signers\n\nTo broadcast messages, you can create signers with a variety of options:\n\n* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) (recommended)\n* [keplr](https://docs.keplr.app/api/cosmjs.html)\n* [cosmjs](https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9)\n### Amino Signer\n\nLikely you'll want to use the Amino, so unless you need proto, you should use this one:\n\n```js\nimport { getOfflineSignerAmino as getOfflineSigner } from 'cosmjs-utils';\n```\n### Proto Signer\n\n```js\nimport { getOfflineSignerProto as getOfflineSigner } from 'cosmjs-utils';\n```\n\nWARNING: NOT RECOMMENDED TO USE PLAIN-TEXT MNEMONICS. Please take care of your security and use best practices such as AES encryption and/or methods from 12factor applications.\n\n```js\nimport { chains } from 'chain-registry';\n\nconst mnemonic =\n  'unfold client turtle either pilot stock floor glow toward bullet car science';\n  const chain = chains.find(({ chain_name }) =\u003e chain_name === 'thorchain');\n  const signer = await getOfflineSigner({\n    mnemonic,\n    chain\n  });\n```\n### Broadcasting Messages\n\nNow that you have your `stargateClient`, you can broadcast messages:\n\n```js\nconst { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl;\n\nconst msg = send({\n    amount: [\n    {\n        denom: 'coin',\n        amount: '1000'\n    }\n    ],\n    toAddress: address,\n    fromAddress: address\n});\n\nconst fee: StdFee = {\n    amount: [\n    {\n        denom: 'coin',\n        amount: '864'\n    }\n    ],\n    gas: '86364'\n};\nconst response = await stargateClient.signAndBroadcast(address, [msg], fee);\n```\n\n## Advanced Usage\n\n\nIf you want to manually construct a stargate client\n\n```js\nimport { OfflineSigner, GeneratedType, Registry } from \"@cosmjs/proto-signing\";\nimport { AminoTypes, SigningStargateClient } from \"@cosmjs/stargate\";\n\nimport { \n    cosmosAminoConverters,\n    cosmosProtoRegistry,\n    cosmwasmAminoConverters,\n    cosmwasmProtoRegistry,\n    ibcProtoRegistry,\n    ibcAminoConverters,\n    thorchainAminoConverters,\n    thorchainProtoRegistry\n} from 'thorchain';\n\nconst signer: OfflineSigner = /* create your signer (see above)  */\nconst rpcEndpint = 'https://rpc.cosmos.directory/thorchain'; // or another URL\n\nconst protoRegistry: ReadonlyArray\u003c[string, GeneratedType]\u003e = [\n    ...cosmosProtoRegistry,\n    ...cosmwasmProtoRegistry,\n    ...ibcProtoRegistry,\n    ...thorchainProtoRegistry\n];\n\nconst aminoConverters = {\n    ...cosmosAminoConverters,\n    ...cosmwasmAminoConverters,\n    ...ibcAminoConverters,\n    ...thorchainAminoConverters\n};\n\nconst registry = new Registry(protoRegistry);\nconst aminoTypes = new AminoTypes(aminoConverters);\n\nconst stargateClient = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, {\n    registry,\n    aminoTypes\n});\n```\n\n## Developing\n\nWhen first cloning the repo:\n\n```\nyarn\nyarn build\n```\n\n### Codegen\n\nContract schemas live in `./contracts`, and protos in `./proto`. Look inside of `scripts/codegen.js` and configure the settings for bundling your SDK and contracts into `thorchain`:\n\n```\nyarn codegen\n```\n\n### Publishing\n\nBuild the types and then publish:\n\n```\nyarn build:ts\nyarn publish\n```\n## Credits\n\n🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)\n\nCode built with the help of these related projects:\n\n* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes\n* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a \"babel for the Cosmos\", Telescope is a TypeScript Transpiler for Cosmos Protobufs.\n* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️\n\n## Disclaimer\n\nAS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.\n\nNo developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fthorchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyramation%2Fthorchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyramation%2Fthorchain/lists"}