Scratch space is a temporary place to store values for later use in your program. It is temporary because any changes to scratch space do not persist beyond the current tranasaction. Scratch space can be used in both Application and Signature mode.
Scratch space consists of 256 scratch slots, each capable of storing one integer or byte slice. When
ScratchVar class to work with scratch space, a slot is automatically assigned to
Writing and Reading¶
To write to scratch space, first create a
ScratchVar object and pass in the
of the values that you will store there. It is possible to create a
ScratchVar that can store
both integers and byte slices by passing no arguments to the
ScratchVar constructor, but note
that no type checking takes places in this situation.
myvar = ScratchVar(TealType.uint64) program = Seq([ myvar.store(Int(5)), Assert(myvar.load() == Int(5)) ])