{"id":23263162,"url":"https://github.com/wavesplatform/ts-contract","last_synced_at":"2025-08-20T18:34:58.963Z","repository":{"id":34982703,"uuid":"194100950","full_name":"wavesplatform/ts-contract","owner":"wavesplatform","description":"Create strongly typed invokes for your Ride contracts","archived":false,"fork":false,"pushed_at":"2023-08-15T21:41:46.000Z","size":56,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-03T11:47:51.606Z","etag":null,"topics":[],"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/wavesplatform.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}},"created_at":"2019-06-27T13:30:13.000Z","updated_at":"2023-11-16T13:02:07.000Z","dependencies_parsed_at":"2022-08-17T22:55:06.097Z","dependency_job_id":null,"html_url":"https://github.com/wavesplatform/ts-contract","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/wavesplatform%2Fts-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fts-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fts-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fts-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavesplatform","download_url":"https://codeload.github.com/wavesplatform/ts-contract/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230445917,"owners_count":18227060,"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-19T14:15:03.489Z","updated_at":"2024-12-19T14:15:04.136Z","avatar_url":"https://github.com/wavesplatform.png","language":"TypeScript","readme":"# ts-contract\nCreate strongly typed invokes for your ride contracts\n\n## Installation\n```\nnpm i @waves/ts-contract\n```\n\n## Contract definitions and Invoke script transaction\nLest take a look on a simple contract definition:\n```ts\ninterface myContract {\n  foo(value: String)\n}\n```\nEvery interface method should correspond to **@Callable(i)** function in your .ride smart contract. In this case the contract is pretty simple: \n```ts\n{-# STDLIB_VERSION 3 #-}\n{-# CONTENT_TYPE DAPP #-}\n{-# SCRIPT_TYPE ACCOUNT #-}\n\n@Callable(i)\nfunc foo(value: String) = {\n    WriteSet([\n        DataEntry(\"data\", value.size())\n    ])\n}\n```\n\nYou can use it to get invoke transaction builder:\n```ts\nimport { contract } from '@waves/ts-contract'\nconst { foo } = contract\u003cmyContract\u003e()('3MwGdE779Vhf4bkn8UbqQqEQwos38KtWhsn')\nfoo('hello').invoke('seed') // =\u003e IInvokeScriptTransaction\n```\nIn case your application use multiple contracts with the same code you can specify dApp address and when calling invoke itself\n```ts\nimport { contract } from '@waves/ts-contract'\nconst { foo } = contract\u003cmyContract\u003e()()\nfoo('hello')\n  .invoke('seed', { dApp: '3MwGdE779Vhf4bkn8UbqQqEQwos38KtWhsn' })\n  // =\u003e IInvokeScriptTransaction\n```\n\n## Generate code\nTo auto generate definitions run the following command in project folder terminal:\n```\nnpx @waves/ts-contract 3MwGdE779Vhf4bkn8UbqQqEQwos38KtWhsn ./myContract.ts\n```\nWhere **3MwGdE779Vhf4bkn8UbqQqEQwos38KtWhsn** is deployed dApp address.\n\nOr if you want to generate code from **.ride file** call:\n```\nnpx @waves/ts-contract ./src/myContract.ride ./myContract.ts\n```\nThe generated **myContract.ts** file will look like this:\n```ts\nimport { ByteVector, contract } from '@waves/ts-contract'\n\nexport interface myContract {\n  foo(value: String | Number | Boolean | ByteVector)\n}\nexport const { foo } = contract\u003cmyContract\u003e()('3MwGdE779Vhf4bkn8UbqQqEQwos38KtWhsn')\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesplatform%2Fts-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavesplatform%2Fts-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesplatform%2Fts-contract/lists"}