Skip to main content

compile

Once we have our contract we need to transform it in something that the cardano node understands.

For that we have the compile function.

function compile(
term: Term<PType>,
version?: [number, number, number]
): Uint8Array;

compile takes any Term as input and returns an Uint8Array that are the flat serialization of the Term.

It optionally takes a tuple of 3 numbers (expected to be all positive integer) representing the contract version.

The version defaults to [ 1, 0, 0 ] and is unlikely you will ever need to specify it.

flat format

The flat format is how the contract is stored on chain.

However is not the format is not how it is include in a transaction (nor how it is used by cardano-cli)

To use the result of compile you should pass it to a Script constructor so that it can handle the format for you.