{"id":13710169,"url":"https://github.com/aeternity/aepp-calldata-js","last_synced_at":"2026-03-09T23:32:36.654Z","repository":{"id":38439742,"uuid":"226167906","full_name":"aeternity/aepp-calldata-js","owner":"aeternity","description":"Aeternity data serialization library","archived":false,"fork":false,"pushed_at":"2026-02-12T13:58:13.000Z","size":7885,"stargazers_count":3,"open_issues_count":28,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-12T22:37:03.094Z","etag":null,"topics":["aesophia","aeternity","calldata","encoder-decoder","fate","serialization"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aeternity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-12-05T18:49:46.000Z","updated_at":"2025-04-02T12:44:34.000Z","dependencies_parsed_at":"2023-02-17T05:15:40.157Z","dependency_job_id":"97b41624-b83b-4ec9-a440-b6998d193a66","html_url":"https://github.com/aeternity/aepp-calldata-js","commit_stats":{"total_commits":240,"total_committers":7,"mean_commits":"34.285714285714285","dds":0.3291666666666667,"last_synced_commit":"410effa3c6ded41baaf2ea18619c5af4a982cf6d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/aeternity/aepp-calldata-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeternity%2Faepp-calldata-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeternity%2Faepp-calldata-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeternity%2Faepp-calldata-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeternity%2Faepp-calldata-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aeternity","download_url":"https://codeload.github.com/aeternity/aepp-calldata-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeternity%2Faepp-calldata-js/sbom","scorecard":{"id":169275,"data":{"date":"2025-08-11","repo":{"name":"github.com/aeternity/aepp-calldata-js","commit":"7a2e022008bdf94f5c75c164776784980a7d165d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":7,"reason":"Found 17/23 approved changesets -- score normalized to 7","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-xq7p-g2vc-g82p","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T15:56:50.531Z","repository_id":38439742,"created_at":"2025-08-16T15:56:50.531Z","updated_at":"2025-08-16T15:56:50.531Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30316771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aesophia","aeternity","calldata","encoder-decoder","fate","serialization"],"created_at":"2024-08-02T23:00:52.658Z","updated_at":"2026-03-09T23:32:36.634Z","avatar_url":"https://github.com/aeternity.png","language":"JavaScript","funding_links":[],"categories":["Development"],"sub_categories":["CLIs, other Plugins \u0026 Libraries"],"readme":"# Aeternity data serialization\n\nAeternity contract calldata encoding and results decoding **standalone** library.\n\nThis is Javascript implementation of data serialization specified in [aeternity protocol](https://github.com/aeternity/protocol/blob/master/serializations.md#data).\n\nWhile the only purpose of the library at the moment of this writing is solely to provide encoding and decoding respectively of contracts calldata and return data it may evolve to full-fledged serialization library of the full protocol specification.\n\n## Installation\n\n```bash\nnpm install -P @aeternity/aepp-calldata\n```\n\n## Quick Start\n\nTo work with contract calls with type information provided by ACI the `AciContractCallEncoder` class should be used. The constructor takes a single argument - [Sophia ACI](https://github.com/aeternity/aesophia/blob/master/docs/aeso_aci.md) as string.\n\n\nNodeJS example:\n\n```javascript\nconst {AciContractCallEncoder} = require('@aeternity/aepp-calldata')\nconst ACI = require('./Test.json')\nconst CONTRACT = 'Test'\n\nconst encoder = new AciContractCallEncoder(ACI)\n```\n\n### Encoding calldata\n\nThe `encodeCall` method is used to encode calldata taking the contract name as first argument, then function name and list of contract call arguments as last argument.\n\nExample:\n```javascript\nconst encoded = encoder.encodeCall(CONTRACT, 'test_string', [\"whoolymoly\"])\nconsole.log(`Encoded data: ${encoded}`)\n```\n\nExpected output:\n```\nEncoded data: cb_KxHwzCuVGyl3aG9vbHltb2x5zwMSnw==\n```\n\n### Decoding call result\n\nThe `decodeResult` method is used to decode contract call result based on it's type. While the first two arguments are the same as the encoding method, the third one is the actual result to be decoded and last one is the result type which defaults to 'ok'.\n\nExample:\n```javascript\nconst decoded = encoder.decodeResult(CONTRACT, 'test_string', 'cb_KXdob29seW1vbHlGazSE')\nconsole.log(`Decoded data: ${decoded}`)\n```\n\nExpected output:\n```\nEncoded data: cb_KxHwzCuVGyl3aG9vbHltb2x5zwMSnw==\nDecoded data: whoolymoly\n```\n\n### Contract call errors\n\nFATE contract call error message is represented as encoded contract bytearray (`cb_` prefixed string).\nHowever, revert messages are FATE string encoded, so the `decodeResult` method accepts forth argument with the result type.\n\nExample:\n```javascript\n// error message\nconst error = encoder.decodeResult(\n    CONTRACT,\n    'test_string',\n    'cb_VHlwZSBlcnJvciBvbiBjYWxsOiBbe2J5dGVzLDw8MjQwLDIsLi4uPj59XSBpcyBub3Qgb2YgdHlwZSBbe2J5dGVzLDMyfV3EtJjU',\n    'error'\n)\nconsole.log('Error: ' + error)\n\n// revert message\nconst revert = encoder.decodeResult(CONTRACT, 'test_string', 'cb_OXJlcXVpcmUgZmFpbGVkarP9mg==', 'revert')\nconsole.log('Revert: ' + revert)\n```\n\nExpected output:\n```\nError: Type error on call: [{bytes,\u003c\u003c240,2,...\u003e\u003e}] is not of type [{bytes,32}]\nRevert: require failed\n```\n\n### Events\n\nExample:\n```javascript\nconst data = encoder.decodeEvent('Test', 'cb_dHJpZ2dlcmVk1FYuYA==', [\n    34853523142692495808479485503424878684430196596020091237715106250497712463899n,\n    17n\n])\nconsole.log(data)\n```\n\nExpected output:\n```\n{EventTwo: [17n, 'triggered']}\n```\n\n## Byte Arrays\n\nAny contract bytearray can be decocded using the `ContractByteArrayEncoder` class.\n\nNode that FATE does not carry some of the type informaton with the data:\n\n- Record keys are lost\n- Variant constructor names are lost\n- Any user type information is lost\n- STL type information is lost: i.e. Chain, AENS, Set, BLS12_381\n\nExample:\n```javascript\nconst {ContractByteArrayEncoder} = require('@aeternity/aepp-calldata')\n\nconst decodedString = encoder.decode('cb_KXdob29seW1vbHlGazSE')\nconsole.log(`Decoded string: ${decodedString}`)\n\nconst decodedMap = encoder.decode('cb_LwEOfzGit9U')\nconsole.log('Decoded map:', decodedMap)\n\n```\n\nExpected output:\n```\nDecoded string: whoolymoly\nDecoded map: Map(1) { 7n =\u003e false }\n```\n\nThe encoder could also work with explicit type information:\n\nExample:\n```javascript\nconst {ContractByteArrayEncoder, TypeResolver} = require('@aeternity/aepp-calldata')\n\nconst encoder = new ContractByteArrayEncoder()\nconst resolver = new TypeResolver()\n\nconst decodedString = encoder.decodeWithType('cb_KXdob29seW1vbHlGazSE', resolver.resolveType('string'))\nconsole.log(`Decoded string: ${decodedString}`)\n\nconst type = resolver.resolveType({map: ['int', 'bool']})\nconst encodedMap = encoder.encodeWithType(new Map([[7n, false]]), type)\nconsole.log('Encoded map:', encodedMap)\n\n```\n\nExpected output:\n```\nDecoded string: whoolymoly\nDecoded map: Map(1) { 7n =\u003e false }\n```\n\n## FATE API Encoder\n\nAny of the following FATE API data types can be encoded and decoded:\n- key_block_hash\n- micro_block_hash\n- block_pof_hash\n- block_tx_hash\n- block_state_hash\n- contract_bytearray\n- contract_pubkey\n- account_pubkey\n- account_seckey\n- channel\n- oracle_pubkey\n- oracle_query_id\n- peer_pubkey\n- name\n- tx_hash\n- signature\n- commitment\n- bytearray\n\nExample:\n```javascript\nconst {FateApiEncoder} = require('@aeternity/aepp-calldata')\nconst encoder = new FateApiEncoder()\n\nconst encoded = encoder.encode('contract_bytearray', new Uint8Array())\nconsole.log(`Encoded: ${encoded}`)\n\nconst decoded = encoder.decode('cb_Xfbg4g==')\nconsole.log('Decoded:', decoded)\n```\n\nExpected output:\n```\nEncoded: cb_Xfbg4g==\nDecoded: Uint8Array(0) []\n```\n\nNote that the encoder work with binary data, so that strings has to be encoded as `Uint8Array`.\n\nString Example:\n```javascript\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nconst encoded = encoder.encode('contract_bytearray', textEncoder.encode('whoolymoly'))\nconsole.log(`Encoded: ${encoded}`)\n\nconst decoded = textDecoder.decode(encoder.decode('cb_d2hvb2x5bW9seeO2SW0='))\nconsole.log('Decoded:', decoded)\n```\n\nExcepted output:\n```\nEncoded: cb_d2hvb2x5bW9seeO2SW0=\nDecoded: whoolymoly\n```\n\n## Contract Encoder\n\nDecodes contract metadata including bytecode.\n\nExample:\n```javascript\nconst {ContractEncoder} = require('@aeternity/aepp-calldata')\nconst encoder = new ContractEncoder()\n\nconst testContract = fs.readFileSync(path.resolve(__dirname, '../build/contracts/Test.aeb'))\nconst contract = encoder.decode(testContract.toString())\n\nconsole.log('Contract:', contract)\n```\n\nExpected output (trimmed):\n```\n{\n  tag: 70n,\n  vsn: 3n,\n  source_hash: 'e50758c624dcacd485db1f9e76208c5858dd968f6218637d055fd4a3b2850baa',\n  aevmTypeInfo: [],\n  compilerVersion: '6.1.0',\n  payable: false,\n  bytecode: {\n    functions: [\n      {\n        id: '077a0e02',\n        name: 'test_nested_list',\n        attributes: [],\n        args: {\n          name: 'tuple',\n          valueTypes: [\n            {\n              name: 'list',\n              valuesType: { name: 'list', valuesType: { name: 'int' } }\n            }\n          ]\n        },\n        returnType: {\n          name: 'list',\n          valuesType: { name: 'list', valuesType: { name: 'int' } }\n        },\n        instructions: [\n          [\n            { mnemonic: 'RETURNR', args: [ { mod: 'arg', arg: 0n } ] }\n          ]\n        ]\n      },\n      .....\n    ],\n    symbols: {\n      '67419061': 'test_unit',\n      ....\n    },\n    annotations: Map(0) {}\n  }\n}\n```\n\n**Please note that the bytecode is for debugging/print purposes and it's structure WON'T be kept backward compatible**\n\n## Data types\n\nUsing the library involves data types and their mappings from Sophia to JavaScript and vice versa.\n\n| Sophia Type | Sophia Example                                          | Javascript type    | Javascript Example                                      |\n|-------------|---------------------------------------------------------|--------------------|---------------------------------------------------------|\n| int         | `63`, `-63`                                             | BigInt             | `63n`, `-63n`                                           |\n| bool        | `true`, `false`                                         | Boolean            | `true`, `false`                                         |\n| string      | `\"whoolymoly\"`                                          | String             | `\"whoolymoly\"`                                          |\n| bytes       | `#beef`                                                 | BigInt             | `BigInt(\"0xbeef\")`                                      |\n| list        | `[1, 2, 3, 5, 8, 13, 21]`                               | Array              | `[1,2,3,5,8,13,21]`                                     |\n| tuple       | `(true, false)`                                         | Array              | `[true, false]`                                         |\n| map         | `{[7] = false}`                                         | Map, Object, Array | `new Map([[7, false]])`, `{7: false}`, `[[7, false]]`   |\n| record      | `{x = 0, y = 0}`                                        | Object (POJO)      | `{x: 0, y: 0}`                                          |\n| variant     | `Some(404)`, `None`                                     | Object (POJO)      | `{'Some': [404]}`, `{'None': []}`, `404`, `undefined`   |\n| bits        | `Bits.none`, `Bits.all`  `Bits.set(Bits.none, 0)`       | BigInt             | `0b0n`, `-1n`, `0b00000001n`                            |\n| hash        | `#001234d`                                              | BigInt             | `BigInt(\"0x001234d\")`                                   |\n| signature   | `#001234d`                                              | BigInt             | `BigInt(\"0x001234d\")`                                   |\n| address     | `ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt` | String             | `ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt` |\n| Set.set     | `Set.from_list([1, 2, 3])`                              | Set, Array         | `new Set([1,2,3])`,`[1,2,3]`                            |\n| BLS12_381.fr| `BLS12_381.int_to_fr(3735928559)`                       | BigInt             | `3735928559n`                                           |\n| BLS12_381.fp| `BLS12_381.int_to_fp(3735928559)`                       | BigInt             | `3735928559n`                                           |\n\n- note the fixed structure of variant object with a single key - the variant constructor (i.e. `Some`) and array of variant arguments as it's value.\n- while Javascript Number and primitive `int` types can be used as well when `BigInt` type is expected it's not recommended because of it's `Number.MAX_SAFE_INTEGER` limitation.\n\n## Versioning\n\nThis project follows the [semantic versioning](https://semver.org/spec/v2.0.0) guidelines.\nRefer to the [CHANGELOG](CHANGELOG.md) for more information about releases.\n\n## Public API\n\nThe backward compatibility promise signaled with semantic versioning [above](#versioning) is **only** applied to public API of this library,\nthat is only the module exports and [data types](#data-types) listed above.\n\nThe public API namely consist of below classes:\n\n- [AciContractCallEncoder](./api/AciContractCallEncoder.js)\n- [BytecodeContractCallEncoder](./api/BytecodeContractCallEncoder.js)\n- [ContractByteArrayEncoder](./api/ContractByteArrayEncoder.js)\n- [FateApiEncoder](./api/FateApiEncoder.js)\n- [ContractEncoder](./api/ContractEncoder.js)\n- [TypeResolver](./api/TypeResolver.js)\n\nThe public API is also defined in [TypeScript declation file](main.d.ts).\n\n### Errors\n\nError names are also part of the public API and it is guaranteed to get the same error name between compatible versions.\nSince error classes are not exported as public API, the library users should rely **only** on `Error.name` property to handle exceptions.\nPlease also note that **error messages are NOT part of the public API** and they may change any time between versions without notice.\n\n## Development\n\nPlease make sure you get familiar with [Contributing Guidelines](CONTRIBUTING.md) first.\n\n### Install\n\n```bash\nnpm install\n```\n\n### Tests\n\nUnit tests can be run with:\n\n```bash\nmake tests\n```\n\nIntegration tests:\n\n```bash\nmake integration-tests\n```\n\nOne can use the benchmarks to do relative comparison on performance for a given change:\n\n```bash\nmake benchmark-tests\n```\n\nVerify browser compatibility with:\n\n```bash\nmake browser-tests\n```\n\nTo see the test coverage run:\n\n```bash\nmake coverage\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faeternity%2Faepp-calldata-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faeternity%2Faepp-calldata-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faeternity%2Faepp-calldata-js/lists"}