Helios API/ API Reference/ Classes/
UplcProgram
Result of program.compile()
. Contains the Untyped Plutus-Core AST, along with a code-mapping to the original source.
Index
Constructors
constructor
• new UplcProgram(expr
, properties?
, version?
)
Parameters
Name | Type |
---|---|
expr | UplcTerm |
properties? | ProgramProperties |
version? | UplcInt [] |
Accessors
expr
• get
expr(): UplcTerm
Returns
mintingPolicyHash
• get
mintingPolicyHash(): MintingPolicyHash
Returns the MintingPolicyHash
of the script. Throws an error if this isn't a minting policy.
Returns
properties
• get
properties(): ProgramProperties
Returns
site
• get
site(): Site
Returns
src
• get
src(): string
Returns the IR source
Returns
string
stakingValidatorHash
• get
stakingValidatorHash(): StakingValidatorHash
Returns the StakingValidatorHash
of the script. Throws an error if this isn't a staking validator script.
Returns
validatorHash
• get
validatorHash(): ValidatorHash
Returns the ValidatorHash
of the script. Throws an error if this isn't a spending validator script.
Returns
versionString
• get
versionString(): string
Returns version of Plutus-core (!== Plutus script version!)
Returns
string
transferUplcAst
• Static
get
transferUplcAst(): TransferUplcAst
Returns
Methods
apply
▸ apply(args
): UplcProgram
Wrap the top-level term with consecutive UplcCall (not exported) terms.
Returns a new UplcProgram instance, leaving the original untouched.
Parameters
Name | Type |
---|---|
args | UplcValue [] |
Returns
- a new UplcProgram instance
calcSize
▸ calcSize(): number
Calculates the on chain size of the program (number of bytes).
Returns
number
hash
▸ hash(): number
[]
Returns
number
[]
- 28 byte hash
plutusScriptVersion
▸ plutusScriptVersion(): string
Returns
string
profile
▸ profile(args
, networkParams
): Promise
<Profile
>
Runs and profiles a UplcProgram
. Needs the NetworkParams
in order to calculate the execution budget.
Parameters
Name | Type |
---|---|
args | UplcValue [] |
networkParams | NetworkParams |
Returns
Promise
<Profile
>
The returned profile contains a breakdown of the execution cost per Uplc term type and per Uplc builtin function type.
run
▸ run(args
, callbacks?
, networkParams?
): Promise
<RuntimeError
| UplcValue
>
Parameters
Name | Type | Description |
---|---|---|
args | null | UplcValue [] | if null the top-level term is returned as a value |
callbacks? | UplcRTECallbacks | |
networkParams? | null | NetworkParams |
Returns
Promise
<RuntimeError
| UplcValue
>
runWithPrint
▸ runWithPrint(args
): Promise
<[RuntimeError
| UplcValue
, string
[]]>
Run a UplcProgram
. The printed messages are part of the return value.
Parameters
Name | Type |
---|---|
args | null | UplcValue [] |
Returns
Promise
<[RuntimeError
| UplcValue
, string
[]]>
serialize
▸ serialize(): string
Returns the JSON representation of the serialized program (needed by cardano-cli).
Returns
string
serializeBytes
▸ serializeBytes(): number
[]
Returns flat bytes of serialized script
Returns
number
[]
toCbor
▸ toCbor(): number
[]
Returns the Cbor encoding of a script (flat bytes wrapped twice in Cbor bytearray).
Returns
number
[]
toString
▸ toString(): string
Returns
string
transfer
▸ transfer<TInstance
>(other
): TInstance
Transfers a UplcProgram
from an old version of Helios to a new version of Helios, keeping the script hash the same.
The main benefit for calling this method instead of serializing/deserializing is that the code mapping is maintained.
Type parameters
Name |
---|
TInstance |
Parameters
Name | Type |
---|---|
other | TransferableUplcProgram <TInstance > |
Returns
TInstance
versionTag
▸ versionTag(): number
Returns 1 for PlutusScriptV1, 2 for PlutusScriptV2
Returns
number
fromCbor
▸ Static
fromCbor(bytes
, properties?
): UplcProgram
Parameters
Name | Type |
---|---|
bytes | string | number [] |
properties? | ProgramProperties |
Returns
fromFlat
▸ Static
fromFlat(bytes
, properties?
): UplcProgram
Parameters
Name | Type |
---|---|
bytes | number [] |
properties? | ProgramProperties |
Returns
transferUplcProgram
▸ Static
transferUplcProgram(expr
, properties
, version
): UplcProgram
Intended for transfer only
Parameters
Name | Type |
---|---|
expr | any |
properties | ProgramProperties |
version | any [] |