Algorand TypeScript
    Preparing search index...

    Variable BoxConst

    Box: {
        create(a: bytes, b: uint64): boolean;
        delete(a: bytes): boolean;
        extract(a: bytes, b: uint64, c: uint64): bytes;
        get(a: bytes): readonly [bytes, boolean];
        length(a: bytes): readonly [uint64, boolean];
        put(a: bytes, b: bytes): void;
        replace(a: bytes, b: uint64, c: bytes): void;
        resize(a: bytes, b: uint64): void;
        splice(a: bytes, b: uint64, c: uint64, d: bytes): void;
    } = ...

    Get or modify box state

    Type declaration

    • create: function
      • 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.

        Parameters

        Returns boolean

        Native TEAL opcode: box_create Min AVM version: 8

    • delete: function
    • extract: function
    • get: function
      • 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

        Parameters

        Returns readonly [bytes, boolean]

        Native TEAL opcode: box_get Min AVM version: 8

    • length: function
    • put: function
      • 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

        Parameters

        Returns void

        Native TEAL opcode: box_put Min AVM version: 8

    • replace: function
    • resize: function
      • 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.

        Parameters

        Returns void

        Native TEAL opcode: box_resize Min AVM version: 10

    • splice: function
      • 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.

        Parameters

        Returns void

        Native TEAL opcode: box_splice Min AVM version: 10