Skip to content

Box

Algorand TypeScript


Algorand TypeScript / op / Box

const Box: object

Defined in: op.ts:614

Get or modify box state

create(a, b): boolean

create a box named A, of length B. Fail if the name A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1 Newly created boxes are filled with 0 bytes. box_create will fail if the referenced box already exists with a different size. Otherwise, existing boxes are unchanged by box_create.

bytes

uint64

boolean

Native TEAL opcode: box_create Min AVM version: 8

delete(a): boolean

delete box named A if it exists. Return 1 if A existed, 0 otherwise

bytes

boolean

Native TEAL opcode: box_del Min AVM version: 8

extract(a, b, c): bytes

read C bytes from box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.

bytes

uint64

uint64

bytes

Native TEAL opcode: box_extract Min AVM version: 8

get(a): readonly [bytes, boolean]

X is the contents of box A if A exists, else ”. Y is 1 if A exists, else 0. For boxes that exceed 4,096 bytes, consider box_create, box_extract, and box_replace

bytes

readonly [bytes, boolean]

Native TEAL opcode: box_get Min AVM version: 8

length(a): readonly [uint64, boolean]

X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.

bytes

readonly [uint64, boolean]

Native TEAL opcode: box_len Min AVM version: 8

put(a, b): void

replaces the contents of box A with byte-array B. Fails if A exists and len(B) != len(box A). Creates A if it does not exist For boxes that exceed 4,096 bytes, consider box_create, box_extract, and box_replace

bytes

bytes

void

Native TEAL opcode: box_put Min AVM version: 8

replace(a, b, c): void

write byte-array C into box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.

bytes

uint64

bytes

void

Native TEAL opcode: box_replace Min AVM version: 8

resize(a, b): void

change the size of box named A to be of length B, adding zero bytes to end or removing bytes from the end, as needed. Fail if the name A is empty, A is not an existing box, or B exceeds 32,768.

bytes

uint64

void

Native TEAL opcode: box_resize Min AVM version: 10

splice(a, b, c, d): void

set box A to contain its previous bytes up to index B, followed by D, followed by the original bytes of A that began at index B+C. Boxes are of constant length. If C < len(D), then len(D)-C bytes will be removed from the end. If C > len(D), zero bytes will be appended to the end to reach the box length.

bytes

uint64

uint64

bytes

void

Native TEAL opcode: box_splice Min AVM version: 10