{"id":29955252,"url":"https://github.com/nathanfirmo/formance-numscript-generator","last_synced_at":"2025-10-10T08:36:35.350Z","repository":{"id":262324921,"uuid":"886773827","full_name":"NathanFirmo/formance-numscript-generator","owner":"NathanFirmo","description":"Numscript generator for Formance open source ledger","archived":false,"fork":false,"pushed_at":"2024-11-27T15:30:26.000Z","size":527,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-12T02:09:33.298Z","etag":null,"topics":["currency","formance","ledger","numscript","script","script-generator"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/formance-numscript-generator","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/NathanFirmo.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":"2024-11-11T15:23:40.000Z","updated_at":"2025-05-25T14:02:46.000Z","dependencies_parsed_at":"2024-11-11T20:43:38.088Z","dependency_job_id":null,"html_url":"https://github.com/NathanFirmo/formance-numscript-generator","commit_stats":null,"previous_names":["nathanfirmo/formance-numscript-generator"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/NathanFirmo/formance-numscript-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanFirmo%2Fformance-numscript-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanFirmo%2Fformance-numscript-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanFirmo%2Fformance-numscript-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanFirmo%2Fformance-numscript-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NathanFirmo","download_url":"https://codeload.github.com/NathanFirmo/formance-numscript-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanFirmo%2Fformance-numscript-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003276,"owners_count":26083555,"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-10T02:00:06.843Z","response_time":62,"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":["currency","formance","ledger","numscript","script","script-generator"],"created_at":"2025-08-03T17:11:52.603Z","updated_at":"2025-10-10T08:36:35.344Z","avatar_url":"https://github.com/NathanFirmo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# formance-numscript-generator\n\n## Motivation\n\nSince handling [Formance Numscript](https://docs.formance.com/numscript/reference/send) over the codebase can be anoying, I've created this simple library to convert JSON to corresponding NumScripts.\n\n## Examples\n\n### Simple transfer\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'COIN',\n      amount: 100,\n      sources: [{ account: 'world' }],\n      destinations: [{ account: 'users:001' }],\n    },\n  ],\n  txMeta: {\n    reference: 'TX001',\n    purpose: 'reward',\n    test: 'Simple transfer',\n  },\n  accountMeta: { 'users:001': { status: 'active', tier: 'gold' } },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [COIN 100] (\n  source = @world\n  destination = @users:001\n)\n\nset_tx_meta(\"reference\", \"TX001\")\nset_tx_meta(\"purpose\", \"reward\")\nset_tx_meta(\"test\", \"Simple transfer\")\n\nset_account_meta(@users:001, \"status\", \"active\")\nset_account_meta(@users:001, \"tier\", \"gold\")\n~~~\n\n### Multiple send\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'USD/2',\n      amount: 100,\n      sources: [{ account: 'foo' }],\n      destinations: [{ account: 'bar' }],\n    },\n    {\n      asset: 'USD/2',\n      amount: 100,\n      sources: [{ account: 'bar' }],\n      destinations: [{ account: 'baz' }],\n    },\n  ],\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [USD/2 100] (\n  source = @foo\n  destination = @bar\n)\n\nsend [USD/2 100] (\n  source = @bar\n  destination = @baz\n)\n~~~\n\n### Transfer with multiple source accounts\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'COIN',\n      amount: 100,\n      sources: [\n        { account: 'users:001:wallet' },\n        { account: 'payments:001' },\n      ],\n      destinations: [{ account: 'orders:001' }],\n    },\n  ],\n  txMeta: { test: 'Transfer with multiple source accounts' },\n  accountMeta: { 'users:001:wallet': { limit: 'high' } },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [COIN 100] (\n  source = {\n    @users:001:wallet\n    @payments:001\n  }\n  destination = @orders:001\n)\n\nset_tx_meta(\"test\", \"Transfer with multiple source accounts\")\n\nset_account_meta(@users:001:wallet, \"limit\", \"high\")\n~~~\n\n### Transfer with max allocation from specific source\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'COIN',\n      amount: 100,\n      sources: [\n        { account: 'users:001:wallet', maxValue: 10 },\n        { account: 'payments:001' },\n      ],\n      destinations: [{ account: 'orders:001' }],\n    },\n  ],\n  txMeta: { test: 'Transfer with max allocation from specific source' },\n  accountMeta: { 'users:001:wallet': { limit: 'low' } },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [COIN 100] (\n  source = {\n    max [COIN 10] from @users:001:wallet\n    @payments:001\n  }\n  destination = orders:001\n)\n\nset_tx_meta(\"test\", \"Transfer with max allocation from specific source\")\n\nset_account_meta(@users:001:wallet, \"limit\", \"low\")\n~~~\n\n\n### Transfer with limited overdraft\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'USD/2',\n      amount: 100,\n      sources: [{ account: 'foo', overdraftLimit: 50 }],\n      destinations: [{ account: 'bar' }],\n    },\n  ],\n  txMeta: { test: 'Transfer with limited overdraft' },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [USD/2 100] (\n  source = @foo allowing overdraft up to [USD/2 50]\n  destination = @bar\n)\n\nset_tx_meta(\"test\", \"Transfer with limited overdraft\")\n~~~\n\n### Transfer with unbounded overdraft\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'USD/2',\n      amount: 100,\n      sources: [{ account: 'foo', overdraftLimit: 'UNBOUNDED' }],\n      destinations: [{ account: 'bar' }],\n    },\n  ],\n  txMeta: { test: 'Transfer with unbounded overdraft' },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [USD/2 100] (\n  source = @foo allowing unbounded overdraft\n  destination = @bar\n)\n\nset_tx_meta(\"test\", \"Transfer with unbounded overdraft\")\n~~~\n\n### Transfer to multiple destinations with equal fractions\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'COIN',\n      amount: 99,\n      sources: [{ account: 'world' }],\n      destinations: [\n        { account: 'a', fraction: '1/5' },\n        { account: 'b', fraction: '1/5' },\n        { account: 'c', fraction: '1/5' },\n        { account: 'd', fraction: '1/5' },\n        { account: 'e', fraction: '1/5' },\n      ],\n    },\n  ],\n  txMeta: {\n    test: 'Transfer to multiple destinations with equal fractions',\n  },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [COIN 99] (\n  source = @world\n  destination = {\n    1/5 to @a\n    1/5 to @b\n    1/5 to @c\n    1/5 to @d\n    1/5 to @e\n  }\n)\n\nset_tx_meta(\"test\", \"Transfer to multiple destinations with equal fractions\")\n~~~\n\n### Split transfer with percentage and remainder\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'USD/2',\n      amount: 'ALL_AVAILABLE',\n      sources: [{ account: 'order:1234' }],\n      destinations: [\n        { account: 'platform:fees', fraction: '10%' },\n        { account: 'merchant:5678', remainder: true },\n      ],\n    },\n  ],\n  txMeta: {\n    reference: 'TX002',\n    purpose: 'orderPayment',\n    test: 'Split transfer with percentage and remainder',\n  },\n  accountMeta: { 'merchant:5678': { region: 'NA' } },\n})\n~~~\n\n#### Output\n\n~~~kt\nsend [USD/2 *] (\n  source = @order:1234\n  destination = {\n    10% to @platform:fees\n    remaining to @merchant:5678\n  }\n)\n\nset_tx_meta(\"reference\", \"TX002\")\nset_tx_meta(\"purpose\", \"orderPayment\")\nset_tx_meta(\"test\", \"Split transfer with percentage and remainder\")\n\nset_account_meta(@merchant:5678, \"region\", \"NA\")\n~~~\n\n### Save statement\n\n#### Input\n\n~~~js\nimport { generateNumscript } from 'formance-numscript-generator'\nconst script = generateNumscript({\n  send: [\n    {\n      asset: 'USD/2',\n      amount: 100,\n      sources: [{ account: 'merchants:1234' }],\n      destinations: [{ account: 'payouts:T1891G' }],\n    },\n  ],\n  save: [{ asset: 'USD/2', amount: 100, account: 'merchants:1234' }],\n  txMeta: { test: 'Save operation' },\n})\n~~~\n\n#### Output\n\n~~~kt\nsave [USD/2 100] from @merchants:1234\n\nsend [USD/2 100] (\n  source = @merchants:1234\n  destination = @payouts:T1891G\n)\n\nset_tx_meta(\"test\", \"Save operation\")\n~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfirmo%2Fformance-numscript-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanfirmo%2Fformance-numscript-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfirmo%2Fformance-numscript-generator/lists"}