{"name":"@taquito/michel-codec","version":"24.3.0-beta.5","keywords":["taquito","tezos","typescript","blockchain","michelson","parser","codec"],"author":{"name":"ECAD Labs Inc","email":"info@ecadlabs.com"},"license":"Apache-2.0","_id":"@taquito/michel-codec@24.3.0-beta.5","maintainers":[{"name":"jevonearth","email":"jev@ecadlabs.com"},{"name":"roxaneletourneau","email":"roxane@ecadlabs.com"},{"name":"hui-an.yang","email":"hui-an.yang@ecadlabs.com"},{"name":"gimbrailo.ecad","email":"gino@ecadlabs.com"}],"contributors":[{"name":"Eugene Zagidullin","email":"eugene@ecadlabs.com"},{"url":"jevonearth","name":"Jev Björsell"},{"name":"Davis Sawali","email":"davis.sawali@ecadlabs.com"},{"name":"Roxane Letourneau","email":"roxane@ecadlabs.com"}],"homepage":"https://taquito.io/","bugs":{"url":"https://github.com/ecadlabs/taquito/issues"},"dist":{"shasum":"829a9607fa5897c2e9f3e79455934809149ab178","tarball":"http://registry-npm.ywwl.com/@taquito/michel-codec/download/@taquito/michel-codec-24.3.0-beta.5.tgz","fileCount":40,"integrity":"sha512-zLDJqIc7K+uaWFF3i98SeT2ISfjTRTRBXkZmZX0WM8A+4GD5L7SfJpt7Jn8CyDEyex4kI+D8x/WIzpjqcyllxQ==","signatures":[{"sig":"MEUCIEPC6XdkiiViIsbOulXxCVlINJtVaeC29+TSbp1lEtVXAiEA8V+u1SagCi46Qyj7Ye52xAEGPfOQoB3i1ShiwgcFYQs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@taquito%2fmichel-codec@24.3.0-beta.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":707118,"size":119816,"noattachment":false,"key":"/@taquito/michel-codec/-/@taquito/michel-codec-24.3.0-beta.5.tgz"},"main":"./dist/taquito-michel-codec.umd.js","module":"./dist/taquito-michel-codec.es6.js","engines":{"node":">=22"},"gitHead":"551e35aeff7d6dcde1c72284238c0ed3c3aae77e","scripts":{"lint":"eslint --ext .js,.ts .","test":"vitest run --config ./vitest.config.ts","build":"tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts --bundleConfigAsCjs","start":"rollup -c rollup.config.ts --bundleConfigAsCjs -w","prebuild":"rimraf dist","precommit":"lint-staged","test:prod":"npm run lint && npm run test","test:watch":"vitest --config ./vitest.config.ts","version-stamp":"node ../taquito/version-stamping.js"},"typings":"./dist/types/taquito-michel-codec.d.ts","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:d040bb5e-065c-4755-a6d8-a4fd2b0350d5"}},"repository":{"url":"git+https://github.com/ecadlabs/taquito.git","type":"git"},"_npmVersion":"11.11.0","description":"Michelson parser, validator, and formatter for Taquito.","directories":{},"lint-staged":{"{src,test}/**/*.ts":["prettier --write","eslint --fix"]},"_nodeVersion":"24.14.1","dependencies":{"@taquito/core":"^24.3.0-beta.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"eslint":"^8.57.0","rimraf":"^6.0.1","rollup":"^4.60.1","ts-node":"^10.9.2","prettier":"^3.3.3","typescript":"^5.9.3","@types/node":"^22.0.0","lint-staged":"^15.2.7","ts-toolbelt":"^9.6.0","@types/bluebird":"^3.5.42","lodash.camelcase":"^4.3.0","rollup-plugin-json":"^4.0.0","@typescript-eslint/parser":"^6.21.0","rollup-plugin-typescript2":"^0.37.0","@typescript-eslint/eslint-plugin":"^6.21.0"},"_npmOperationalInternal":{"tmp":"tmp/michel-codec_24.3.0-beta.5_1775930430069_0.4136648119716275","host":"s3://npm-registry-packages-npm-production"},"readme":"# Taquito michel-codec package\n\n`@taquito/michel-codec` Converts and validates Michelson expressions between JSON based Michelson and Micheline.\n\nThis package can:\n\n- Retrieve Michelson in JSON form from the Tezos Node RPC and convert it to plain Michelson.\n- Parse plain Michelson (including Macros) and expand/convert it to JSON Michelson suitable for injection into the Tezo Blockchain.\n- Validate Michelson to ensure correctness\n\nSee the top-level project [https://github.com/ecadlabs/taquito](https://github.com/ecadlabs/taquito) for details on reporting issues, contributing and versioning.\n\n## Examples\n\n### Michelson expression to JSON\n\n```js\nconst code = `(Pair\n                     (Pair { Elt 1 (Pair (Pair \"tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN\" \"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx\") 0x0501000000026869)}\n                           10000000)\n                     (Pair 2 333)\n                  )`;\n\nconst p = new Parser();\n\nconst result = p.parseMichelineExpression(code);\nconsole.log(JSON.stringify(result));\n```\n\nOutput:\n\n```json\n{\n  \"prim\": \"Pair\",\n  \"args\": [\n    {\n      \"prim\": \"Pair\",\n      \"args\": [\n        [\n          {\n            \"prim\": \"Elt\",\n            \"args\": [\n              { \"int\": \"1\" },\n              {\n                \"prim\": \"Pair\",\n                \"args\": [\n                  {\n                    \"prim\": \"Pair\",\n                    \"args\": [\n                      { \"string\": \"tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN\" },\n                      { \"string\": \"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx\" }\n                    ]\n                  },\n                  { \"bytes\": \"0501000000026869\" }\n                ]\n              }\n            ]\n          }\n        ],\n        { \"int\": \"10000000\" }\n      ]\n    },\n    { \"prim\": \"Pair\", \"args\": [{ \"int\": \"2\" }, { \"int\": \"333\" }] }\n  ]\n}\n```\n\n### Pretty Print a Michelson contract\n\n```js\n    const contract = await Tezos.contract.at('KT1EctCuorV2NfVb1XTQgvzJ88MQtWP8cMMv')\n    const p = new Parser()\n\n    const michelsonCode = p.parseJSON(contract.script.code as JSON[])\n    console.log(emitMicheline(michelsonCode, {indent:\"    \", newline: \"\\n\",}))\n```\n\n### Pack Michelson data\n\nSerializes any value of packable type to its optimized binary representation identical to the one used by PACK and UNPACK Michelson instructions.\nWithout a type definition (not recommended) the data will be encoded as a binary form of a generic Michelson expression.\nType definition allows some types like `timestamp` and `address` and other base58 representable types to be encoded to corresponding optimized binary forms borrowed from the Tezos protocol.\n\n```js\nconst data: MichelsonData = {\n  string: 'KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main',\n};\n\nconst typ: MichelsonType = {\n  prim: 'address',\n};\n\nconst packed = packData(data, typ);\n// 050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e\n\n// alternatively\nconst packedBytes = packDataBytes(data, typ);\n// { bytes: \"050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e\" }\n```\n\nWithout a type definition the base58 encoded address will be treated as a string\n\n```js\nconst data: MichelsonData = {\n  string: 'KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main',\n};\n\nconst packed = packData(data);\n// 0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e\n\n// alternatively\nconst packedBytes = packDataBytes(data);\n// {\n//     bytes: \"0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e\"\n// }\n```\n\n### Unpack Michelson data\n\nDeserialize a byte array into the corresponding Michelson value.\nWithout a type definition (not recommended) the binary data will be treated as a binary form of a generic Michelson expression and returned as is.\nType definition allows some types like `timestamp` and `address` and other types usually encoded in optimized binary forms to be transformed back to their string representations like base58 and ISO timestamps.\n\n```js\nconst src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];\n\nconst typ: MichelsonType = {\n  prim: 'timestamp',\n};\n\nconst data = unpackData(src, typ);\n// { string: \"2019-09-26T10:59:51Z\" }\n```\n\nAlternatively\n\n```js\nconst src = { bytes: '0500a7e8e4d80b' };\n\nconst typ: MichelsonType = {\n  prim: 'timestamp',\n};\n\nconst data = unpackDataBytes(src, typ);\n// { string: \"2019-09-26T10:59:51Z\" }\n```\n\nSame binary data without a type definition\n\n```js\nconst src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];\n\nconst data = unpackData(src);\n// { int: \"1569495591\" }\n```\n\nAlternatively\n\n```js\nconst src = { bytes: '0500a7e8e4d80b' };\n\nconst data = unpackDataBytes(src);\n// { int: \"1569495591\" }\n```\n\n## API Documentation\n\nTypeDoc style documentation is available on-line [here](https://taquito.io/typedoc/modules/_taquito_michel_codec.html)\n\n## Disclaimer\n\nTHIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","publish_time":1775930430219,"_cnpm_publish_time":1775930430219,"dist-tags":{"latest":"25.1.1","next":"25.2.0-beta1"}}