> For the complete documentation index, see [llms.txt](https://docs.aeternity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aeternity.com/developer-documentation/aesophia/docs/aeso_compiler.md).

# aeso\_compiler

### Module

### aeso\_compiler

The Sophia compiler

### Description

This module provides the interface to the standard Sophia compiler. It\
returns the compiled module in a map which can then be loaded.

### Types

```erlang
contract_string() = string() | binary()
contract_map() = #{bytecode => binary(),
                   compiler_version => binary(),
                   contract_souce => string(),
                   type_info => type_info()}
type_info()
errorstring() = binary()
```

### Exports

#### file(File)

#### file(File, Options) -> CompRet

#### from\_string(ContractString, Options) -> CompRet

Types

```erlang
ContractString = contract_string()
Options = [Option]
CompRet = {ok,ContractMap} | {error,ErrorString}
ContractMap = contract_map()
ErrorString = errorstring()
```

Compile a contract defined in a file or in a string.

The **pp\_** options all print to standard output the following:

`pp_sophia_code` - print the input Sophia code.

`pp_ast` - print the AST of the code

`pp_types` - print information about the types

`pp_typed_ast` - print the AST with type information at each node

`pp_assembler` - print the generated assembler code

The option `include_child_contract_symbols` includes the symbols of child contracts functions in the generated fate code. It is turned off by default to avoid making contracts bigger on chain.

#### Options to control which compiler optimizations should run:

By default all optimizations are turned on, to disable an optimization, it should be\
explicitly set to false and passed as a compiler option.

List of optimizations:

* optimize\_inliner
* optimize\_inline\_local\_functions
* optimize\_bind\_subexpressions
* optimize\_let\_floating
* optimize\_simplifier
* optimize\_drop\_unused\_lets
* optimize\_push\_consume
* optimize\_one\_shot\_var
* optimize\_write\_to\_dead\_var
* optimize\_inline\_switch\_target
* optimize\_swap\_push
* optimize\_swap\_pop
* optimize\_swap\_write
* optimize\_constant\_propagation
* optimize\_prune\_impossible\_branches
* optimize\_single\_successful\_branch
* optimize\_inline\_store
* optimize\_float\_switch\_bod

#### check\_call(ContractString, Options) -> CheckRet

Types

```
ContractString = string() | binary()
CheckRet = {ok,string(),{Types,Type | any()},Terms} | {error,Term}
Types = [Type]
Type = term()
```

Check a call in contract through the `__call` function.

#### version() -> {ok, Version} | {error, term()}

Types

```erlang
Version = binary()
```

Get the current version of the Sophia compiler.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aeternity.com/developer-documentation/aesophia/docs/aeso_compiler.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
