Skip to main content
Docs
›
element.var

element.var

Element

Reads a named value from an element.

Signature

element.var(ref: ElementRef, name: HostValue, sticky?: AbiValue): HostValue

Parameters

NameTypeRequiredDescription
refElementRefRequiredThe element it works on, usually self.
nameHostValueRequiredThe name of the value to read.
stickyAbiValueOptionalMarks the read so your result recalculates when this value changes.

Returns

HostValue The value. Cast it to the type you expect.

Example

const hp: number = element.var(self, "hp") as number;