sigmastate-interpreter icon indicating copy to clipboard operation
sigmastate-interpreter copied to clipboard

Add placeholder[T](index) primitive to ErgoScript frontend

Open aslesarenko opened this issue 7 years ago • 0 comments

Problem

It is necessary to be able to write templates using ErgoScript. Any ErgoTree can contain segregated constants (see ErgoTree.constants), such that ConstantPlaceholder nodes are stored in the expression and refer to the constants by index. Every constant can be replaced in the array, without changing the tree, thus ErgoTree with constants can be used as a template, where each constant serves as a parameter.

Currently placeholders can only be created using IR nodes directly in Scala Values.ConstantPlaceholder(0, SByteArray) this should be possible to write in ErgoScript like placeholder[Coll[Byte]](0)

This will allow to create ergoTrees in which some constant can be refered by more than one placeholder. This is not possible to achieve using automatic constant segregation (withSegregation method)

This is used in particular in rewardOutputScript template.

aslesarenko avatar Jan 31 '19 11:01 aslesarenko