{"id":14984974,"url":"https://github.com/spacebudz/lucid","last_synced_at":"2025-05-14T17:05:18.800Z","repository":{"id":37015848,"uuid":"481758172","full_name":"spacebudz/lucid","owner":"spacebudz","description":"Lucid is a library designed to simplify creating Cardano transactions and writing off-chain code for Plutus contracts.","archived":false,"fork":false,"pushed_at":"2025-03-24T15:23:55.000Z","size":108501,"stargazers_count":358,"open_issues_count":48,"forks_count":145,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-14T17:03:56.116Z","etag":null,"topics":["cardano","deno","typescript"],"latest_commit_sha":null,"homepage":"https://lucid.spacebudz.io","language":"Rust","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/spacebudz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"alessandrokonrad"}},"created_at":"2022-04-14T21:46:12.000Z","updated_at":"2025-04-22T08:30:54.000Z","dependencies_parsed_at":"2024-06-18T13:34:47.723Z","dependency_job_id":"a2a5b474-7f29-4763-9f29-f7746e5c9f7c","html_url":"https://github.com/spacebudz/lucid","commit_stats":{"total_commits":558,"total_committers":22,"mean_commits":"25.363636363636363","dds":"0.12724014336917566","last_synced_commit":"4a36e103248f4b44d1d0755c8959b95ad97db366"},"previous_names":["berry-pool/lucid"],"tags_count":98,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacebudz%2Flucid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacebudz%2Flucid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacebudz%2Flucid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacebudz%2Flucid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spacebudz","download_url":"https://codeload.github.com/spacebudz/lucid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190396,"owners_count":22029632,"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":["cardano","deno","typescript"],"created_at":"2024-09-24T14:10:00.763Z","updated_at":"2025-05-14T17:05:18.771Z","avatar_url":"https://github.com/spacebudz.png","language":"Rust","funding_links":["https://github.com/sponsors/alessandrokonrad"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"100px\" src=\"./assets/lucid.svg\" align=\"center\"/\u003e\n  \u003ch1 align=\"center\"\u003eLucid\u003c/h1\u003e\n  \u003cp align=\"center\"\u003eLucid is a library designed to simplify creating Cardano transactions and writing off-chain code for Plutus contracts.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/jsr/v/@spacebudz/lucid?style=for-the-badge\" /\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/lucid-cardano?style=for-the-badge\" /\u003e\n    \u003ca href=\"https://twitter.com/spacebudznft\"\u003e\n      \u003cimg src=\"https://img.shields.io/twitter/follow/spacebudznft?style=for-the-badge\u0026logo=twitter\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\n\u003c/p\u003e\n\n### Get started\n\n#### Deno 🦕\n\n```js\nimport { Lucid } from \"jsr:@spacebudz/lucid\";\n```\nor\n```js\nimport { Lucid } from \"https://deno.land/x/lucid/mod.ts\";\n```\n\n#### Node.js\n\n```\nnpx jsr add @spacebudz/lucid\n```\nor\n```\nnpm install lucid-cardano (legacy, will likely be obsolete)\n```\n\n`--experimental-wasm-modules` flag needs to be set in Node.js as well as `{ \"type\": \"module\" }` in package.json\n\n### Build from source\n\nBuild for NPM\n\n```\ndeno task build\n```\n\nOutputs a `dist` folder\n\n### Examples\n\n- [Basic examples](./examples/)\n\n### Basic usage\n\n```js\nimport { Blockfrost, Lucid } from \"https://deno.land/x/lucid/mod.ts\";\n\nconst lucid = new Lucid({\n  provider: new Blockfrost(\n    \"https://cardano-preview.blockfrost.io/api/v0\",\n    \"\u003cprojectId\u003e\",\n  ),\n});\n\n// Assumes you are in a browser environment\nconst api = await window.cardano.nami.enable();\nlucid.selectWalletFromApi(api);\n\nconst tx = await lucid.newTx()\n  .payTo(\"addr...\", { lovelace: 5000000n })\n  .commit();\n\nconst signedTx = await tx.sign().commit();\n\nconst txHash = await signedTx.submit();\n\nconsole.log(txHash);\n```\n\n### Blueprint\n\nLucid supports [CIP-0057](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0057) blueprints.\n\nRun the following command in a directory with a `plutus.json` file.\n\n```\ndeno run -A https://deno.land/x/lucid/blueprint.ts\n```\n\nYou can import the example Aiken validator...\n\n```\npub type MyData {\n  a: Int,\n  b: ByteArray,\n}\n\nvalidator validate(my_data: MyData) {\n  mint(redeemer: MyData, _policy_id: PolicyId, _transaction: Transaction) {\n    my_data == redeemer\n  } \n}\n```\n\n...into Lucid using the generated `plutus.ts` file created with the blueprint command, as shown below:\n\n```ts\nimport { ValidateMint } from \"./plutus.ts\";\n\nconst validator = new ValidateMint({ a: 123n, b: \"0000\" });\n\nconst policyId = lucid.newScript(validator).toHash();\n\nconst tx = await lucid\n  .newTx()\n  .mint(\n    { [policyId]: 1n },\n    Data.to({ a: 123n, b: \"0000\" }, ValidateMint.redeemer),\n  )\n  .attachScript(validator)\n  .commit();\n```\n\nSee [more examples](./tests/data.test.ts)\n\n### Instructions\n\nLucid transactions can be converted into instructions, which are JSON, making them highly portable.\n\n```js\nconst instructions = await lucid.newTx()\n  .delegateTo(\"{{own}}\", { Pool: \"pool...\" })\n  .payTo(\"addr_test1...\", { lovelace: 1000000n })\n  .toInstructions();\n```\n\nThe above transaction can be converted into the following object:\n\n```js\n[\n  {\n    \"type\": \"DelegateTo\",\n    \"delegation\": {\n      \"rewardAddress\": \"stake...\",\n      \"variant\": {\n        \"Pool\": \"pool...\",\n      },\n    },\n    \"redeemer\": undefined,\n  },\n  {\n    \"type\": \"PayTo\",\n    \"address\": \"addr_test1...\",\n    \"assets\": { \"lovelace\": 1000000n },\n  },\n]\n```\n\nConsume the instructions in Lucid:\n\n```js\nconst tx = await lucid.fromInstructions([\n  {\n    \"type\": \"DelegateTo\",\n    \"delegation\": {\n      \"rewardAddress\": \"stake...\",\n      \"variant\": {\n        \"Pool\": \"pool...\",\n      },\n    },\n    \"redeemer\": undefined,\n  },\n  {\n    \"type\": \"PayTo\",\n    \"address\": \"addr_test1...\",\n    \"assets\": { \"lovelace\": 1000000n },\n  },\n]);\n```\n\nYou can avoid address resolution if you use `.toPartialInstructions()` instead of `.toInstructions()`.\\\nThen Lucid will resolve `{{own}}` fields with the addresses of the selected wallet during consumption of instructions.\n\n### Test\n\n```\ndeno task test\n```\n\n### Build Core\n\nThe [core library](./src/core/libs/lucid_core/) (instruction builder, crypto, hashing etc.) is written in Rust and compiled to WASM.\n\n```\ndeno task build:core\n```\n\n### Test Core\n\n```\ndeno task test:core\n```\n\n### Docs\nYou can generate documentation with:\n\n```\ndeno doc\n```\n\n### Compatibility\n\nLucid is an ES Module, and to use it in the browser, a bundler that supports top-level await and WebAssembly is recommended. If you use Webpack 5 enable in\nthe `webpack.config.js`:\n\n```\nexperiments: {\n    asyncWebAssembly: true,\n  }\n```\n\n### Contributing\n\nContributions and PRs are welcome\\\nThe [contribution instructions](./CONTRIBUTING.md).\n\nJoin us on [Discord](https://discord.gg/82MWs63Tdm)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacebudz%2Flucid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspacebudz%2Flucid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacebudz%2Flucid/lists"}