1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[19],{74241(e,n,t){t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>s,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"reference/NoirJS/noir_wasm/functions/compile_contract","title":"Function: compile\\\\_contract()","description":"Compiles a Noir project","source":"@site/versioned_docs/version-v1.0.0-beta.26/reference/NoirJS/noir_wasm/functions/compile_contract.md","sourceDirName":"reference/NoirJS/noir_wasm/functions","slug":"/reference/NoirJS/noir_wasm/functions/compile_contract","permalink":"/docs/v1.0.0-beta.26/reference/NoirJS/noir_wasm/functions/compile_contract","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-beta.26/reference/NoirJS/noir_wasm/functions/compile_contract.md","tags":[],"version":"v1.0.0-beta.26","frontMatter":{},"sidebar":"sidebar","previous":{"title":"Function: compile()","permalink":"/docs/v1.0.0-beta.26/reference/NoirJS/noir_wasm/functions/compile"},"next":{"title":"Function: inflateDebugSymbols()","permalink":"/docs/v1.0.0-beta.26/reference/NoirJS/noir_wasm/functions/inflateDebugSymbols"}}');var o=t(74848),c=t(28453);const i={},s="Function: compile_contract()",a={},l=[{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Example",id:"example",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"function-compile_contract",children:"Function: compile_contract()"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-ts",children:"function compile_contract(\n fileManager, \n projectPath?, \n logFn?, \ndebugLogFn?): Promise<ContractCompilationArtifacts>;\n"})}),"\n",(0,o.jsx)(n.p,{children:"Compiles a Noir project"}),"\n",(0,o.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"})]})}),(0,o.jsxs)(n.tbody,{children:[(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"fileManager"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"FileManager"})}),(0,o.jsx)(n.td,{children:"The file manager to use"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"projectPath?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"string"})}),(0,o.jsx)(n.td,{children:"The path to the project inside the file manager. Defaults to the root of the file manager"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"logFn?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"LogFn"})}),(0,o.jsx)(n.td,{children:"A logging function. If not provided, console.log will be used"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"debugLogFn?"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"LogFn"})}),(0,o.jsx)(n.td,{children:"A debug logging function. If not provided, logFn will be used"})]})]})]}),"\n",(0,o.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"Promise"}),"<",(0,o.jsx)(n.a,{href:"/docs/v1.0.0-beta.26/reference/NoirJS/noir_wasm/#contractcompilationartifacts",children:(0,o.jsx)(n.code,{children:"ContractCompilationArtifacts"})}),">"]}),"\n",(0,o.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-typescript",children:"// Node.js\n\nimport { compile_contract, createFileManager } from '@noir-lang/noir_wasm';\n\nconst fm = createFileManager(myProjectPath);\nconst myCompiledCode = await compile_contract(fm);\n"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-typescript",children:"// Browser\n\nimport { compile_contract, createFileManager } from '@noir-lang/noir_wasm';\n\nconst fm = createFileManager('/');\nfor (const path of files) {\n await fm.writeFile(path, await getFileAsStream(path));\n}\nconst myCompiledCode = await compile_contract(fm);\n"})})]})}function h(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},28453(e,n,t){t.d(n,{R:()=>i,x:()=>s});var r=t(96540);const o={},c=r.createContext(o);function i(e){const n=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(c.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.