# casperlabs-contract-test

> Library for developing CasperLabs smart contracts.

Latest version **0.2.0** (published 2020-04-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install casperlabs-contract-test
pnpm add casperlabs-contract-test
yarn add casperlabs-contract-test
bun add casperlabs-contract-test
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-04-02 |
| First published | 2020-04-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 229.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michał Papierski |
| Maintainers | mpapierski |

## Links

- npm: https://www.npmjs.com/package/casperlabs-contract-test
- npm.io page: https://npm.io/package/casperlabs-contract-test

## Recent versions

- 0.2.0 (latest) — 2020-04-02

## README

# @casperlabs/contract

This package allows a distributed app developer to create smart contracts
for the open source [CasperLabs](https://github.com/CasperLabs/CasperLabs) project using [AssemblyScript](https://www.npmjs.com/package/assemblyscript).

## Installation
For each smart contract you create, make a project directory and initialize it.
``` 
mkdir project
cd project
npm init
```

npm init will prompt you for various details about your project; 
answer as you see fit but you may safely default everything except `name` which should follow the convention of
`your-contract-name`.

Then install assembly script and this package in the project directory.

```
npm install --save-dev assemblyscript@0.9.1
npm install --save @casperlabs/contract
```

## Usage
Add script entries for assembly script to your project's `package.json`; note that your contract name is used
for the name of the wasm file.
```
{
  "name": "your-contract-name",
  ...
  "scripts": {
    "asbuild:optimized": "asc assembly/index.ts -b dist/your-contract-name.wasm --validate --optimize --use abort=",
    "asbuild": "npm run asbuild:optimized",
    ...
  },
  ...
}
```
In your project root, create an `index.js` file with the following contents:
```js
const fs = require("fs");
​
const compiled = new WebAssembly.Module(fs.readFileSync(__dirname + "/dist/your-contract-name.wasm"));
​
const imports = {
    env: {
        abort(_msg, _file, line, column) {
            console.error("abort called at index.ts:" + line + ":" + column);
        }
    }
};
​
Object.defineProperty(module, "exports", {
    get: () => new WebAssembly.Instance(compiled, imports).exports
});
```

Create an `assembly/tsconfig.json` file in the following way:
```json
{
  "extends": "../node_modules/assemblyscript/std/assembly.json",
  "include": [
    "./**/*.ts"
  ]
}
```

### Sample smart contract
Create a `assembly/index.ts` file. This is where the code for your contract will go. 

You can use the following sample snippet which demonstrates a very simple smart contract that immediately returns an error, which will write a message to a block if executed on the CasperLabs platform. 

```typescript
//@ts-nocheck
import {Error, ErrorCode} from "@casperlabs/contract/error";

// simplest possible feedback loop
export function call(): void {
    Error.fromErrorCode(ErrorCode.None).revert(); // ErrorCode: 1
}
```
If you prefer a more complicated first contract, you can look at example contracts on the [CasperLabs](https://github.com/CasperLabs/CasperLabs/tree/master/execution-engine/contracts-as/examples) github repository for inspiration.

### Compile to wasm
To compile your contract to wasm, use npm to run the asbuild script from your project root.
```
npm run asbuild
```
If the build is successful, you should see a `dist` folder in your root folder and in it
should be `your-contract-name.wasm`

<a name="readmemd"></a>


# casperlabs-contract-test

## Index

### Modules

* ["account"](#modules_account_md)
* ["bignum"](#modules_bignum_md)
* ["bytesrepr"](#modules_bytesrepr_md)
* ["clvalue"](#modules_clvalue_md)
* ["constants"](#modules_constants_md)
* ["error"](#modules_error_md)
* ["externals"](#modules_externals_md)
* ["index"](#modules_index_md)
* ["key"](#modules_key_md)
* ["local"](#modules_local_md)
* ["option"](#modules_option_md)
* ["pair"](#modules_pair_md)
* ["purse"](#modules_purse_md)
* ["unit"](#modules_unit_md)
* ["uref"](#modules_uref_md)
* ["utils"](#modules_utils_md)

# Classes


<a name="classes_bignum_u512md"></a>


## Class: U512

An implementation of 512-bit unsigned integers.

### Hierarchy

* **U512**

### Index

#### Constructors

* [constructor](#constructor)

#### Accessors

* [width](#width)
* [MAX_VALUE](#static-max_value)
* [MIN_VALUE](#static-min_value)

#### Methods

* [add](#add)
* [bits](#bits)
* [clone](#clone)
* [cmp](#cmp)
* [div](#div)
* [divMod](#divmod)
* [eq](#eq)
* [gt](#gt)
* [gte](#gte)
* [isZero](#iszero)
* [lt](#lt)
* [lte](#lte)
* [mul](#mul)
* [neg](#neg)
* [neq](#neq)
* [postfixDec](#postfixdec)
* [postfixInc](#postfixinc)
* [prefixDec](#prefixdec)
* [prefixInc](#prefixinc)
* [rem](#rem)
* [setBytesLE](#setbytesle)
* [setHex](#sethex)
* [setU64](#setu64)
* [setValues](#setvalues)
* [shl](#shl)
* [shr](#shr)
* [sub](#sub)
* [toBytes](#tobytes)
* [toBytesLE](#tobytesle)
* [toString](#tostring)
* [fromBytes](#static-frombytes)
* [fromHex](#static-fromhex)
* [fromU64](#static-fromu64)

### Constructors

####  constructor

\+ **new U512**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:31](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L31)*

Constructs a new instance of U512.

**Returns:** *[U512](#classes_bignum_u512md)*

### Accessors

####  width

• **get width**(): *i32*

*Defined in [bignum.ts:79](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L79)*

Gets the width of the number in bytes.

**Returns:** *i32*

___

#### `Static` MAX_VALUE

• **get MAX_VALUE**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:43](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L43)*

**Returns:** *[U512](#classes_bignum_u512md)*

The maximum possible value of a U512.

___

#### `Static` MIN_VALUE

• **get MIN_VALUE**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:52](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L52)*

**Returns:** *[U512](#classes_bignum_u512md)*

The minimum possible value of a U512 (which is 0).

### Methods

####  add

▸ **add**(`other`: [U512](#classes_bignum_u512md)): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:146](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L146)*

The addition operator - adds two U512 numbers together.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  bits

▸ **bits**(): *u32*

*Defined in [bignum.ts:282](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L282)*

Returns length of the integer in bits (not counting the leading zero bits).

**Returns:** *u32*

___

####  clone

▸ **clone**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:273](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L273)*

Clones the U512.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  cmp

▸ **cmp**(`other`: [U512](#classes_bignum_u512md)): *i32*

*Defined in [bignum.ts:406](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L406)*

Compares `this` and `other`.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`other` | [U512](#classes_bignum_u512md) | The number to compare `this` to. |

**Returns:** *i32*

-1 if `this` is less than `other`, 1 if `this` is greater than `other`, 0 if `this`
    and `other` are equal.

___

####  div

▸ **div**(`other`: [U512](#classes_bignum_u512md)): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:339](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L339)*

The division operator - divides the arguments.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  divMod

▸ **divMod**(`other`: [U512](#classes_bignum_u512md)): *[Pair](#classes_pair_pairmd)‹[U512](#classes_bignum_u512md), [U512](#classes_bignum_u512md)› | null*

*Defined in [bignum.ts:298](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L298)*

Performs the integer division of `this/other`.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`other` | [U512](#classes_bignum_u512md) | The divisor. |

**Returns:** *[Pair](#classes_pair_pairmd)‹[U512](#classes_bignum_u512md), [U512](#classes_bignum_u512md)› | null*

A pair consisting of the quotient and the remainder, or null if the divisor was 0.

___

####  eq

▸ **eq**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:425](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L425)*

The equality operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

True if `this` and `other` are equal, false otherwise.

___

####  gt

▸ **gt**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:445](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L445)*

The greater-than operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

True if `this` is greater than `other`, false otherwise.

___

####  gte

▸ **gte**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:465](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L465)*

The greater-than-or-equal operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

True if `this` is greater than or equal to `other`, false otherwise.

___

####  isZero

▸ **isZero**(): *bool*

*Defined in [bignum.ts:133](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L133)*

Checks whether this U512 is equal to 0.

**Returns:** *bool*

True if this U512 is 0, false otherwise.

___

####  lt

▸ **lt**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:455](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L455)*

The less-than operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

True if `this` is less than `other`, false otherwise.

___

####  lte

▸ **lte**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:475](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L475)*

The less-than-or-equal operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

True if `this` is less than or equal to `other`, false otherwise.

___

####  mul

▸ **mul**(`other`: [U512](#classes_bignum_u512md)): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:185](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L185)*

The multiplication operator - calculates the product of the two arguments.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  neg

▸ **neg**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:164](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L164)*

The negation operator - returns the two's complement of the argument.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  neq

▸ **neq**(`other`: [U512](#classes_bignum_u512md)): *bool*

*Defined in [bignum.ts:435](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L435)*

The not-equal operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *bool*

False if `this` and `other` are equal, true otherwise.

___

####  postfixDec

▸ **postfixDec**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:253](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L253)*

Postfix operator `--` - decrements this U512.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  postfixInc

▸ **postfixInc**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:243](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L243)*

Postfix operator `++` - increments this U512.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  prefixDec

▸ **prefixDec**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:234](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L234)*

Prefix operator `--` - decrements this U512.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  prefixInc

▸ **prefixInc**(): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:225](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L225)*

Prefix operator `++` - increments this U512.

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  rem

▸ **rem**(`other`: [U512](#classes_bignum_u512md)): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:349](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L349)*

The 'modulo' operator - calculates the remainder from the division of the arguments.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  setBytesLE

▸ **setBytesLE**(`bytes`: Uint8Array): *void*

*Defined in [bignum.ts:496](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L496)*

Sets the value of this U512 to the value represented by `bytes` when treated as a
little-endian representation of a number.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *void*

___

####  setHex

▸ **setHex**(`value`: String): *void*

*Defined in [bignum.ts:100](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L100)*

Sets the value of this U512 to a value represented by the given string of hex digits.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`value` | String | The string of hex digits representing the desired value.  |

**Returns:** *void*

___

####  setU64

▸ **setU64**(`value`: u64): *void*

*Defined in [bignum.ts:88](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L88)*

Sets the value of this U512 to a given 64-bit value.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`value` | u64 | The desired new value of this U512.  |

**Returns:** *void*

___

####  setValues

▸ **setValues**(`pn`: Uint32Array): *void*

*Defined in [bignum.ts:264](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L264)*

Sets the values of the internally kept 32-bit "digits" (or "limbs") of the U512.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`pn` | Uint32Array | The array of unsigned 32-bit integers to be used as the "digits"/"limbs".  |

**Returns:** *void*

___

####  shl

▸ **shl**(`shift`: u32): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:359](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L359)*

The bitwise left-shift operator.

**Parameters:**

Name | Type |
------ | ------ |
`shift` | u32 |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  shr

▸ **shr**(`shift`: u32): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:381](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L381)*

The bitwise right-shift operator.

**Parameters:**

Name | Type |
------ | ------ |
`shift` | u32 |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  sub

▸ **sub**(`other`: [U512](#classes_bignum_u512md)): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:177](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L177)*

The subtraction operator - subtracts the two U512s.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [U512](#classes_bignum_u512md) |

**Returns:** *[U512](#classes_bignum_u512md)*

___

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [bignum.ts:573](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L573)*

Serializes the U512 into an array of bytes that represents it in the CasperLabs serialization
format.

**Returns:** *Array‹u8›*

___

####  toBytesLE

▸ **toBytesLE**(): *Uint8Array*

*Defined in [bignum.ts:483](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L483)*

Returns a little-endian byte-array representation of this U512 (i.e. `result[0]` is the least
significant byte.

**Returns:** *Uint8Array*

___

####  toString

▸ **toString**(): *String*

*Defined in [bignum.ts:539](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L539)*

An alias for [[toHex]].

**Returns:** *String*

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹[U512](#classes_bignum_u512md)›*

*Defined in [bignum.ts:550](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L550)*

Deserializes a U512 from an array of bytes. The array should represent a correct U512 in the
CasperLabs serialization format.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹[U512](#classes_bignum_u512md)›*

A [Result](#classes_bytesrepr_resultmd) that contains the deserialized U512 if the deserialization was
   successful, or an error otherwise.

___

#### `Static` fromHex

▸ **fromHex**(`hex`: String): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:59](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L59)*

Constructs a new U512 from a string of hex digits.

**Parameters:**

Name | Type |
------ | ------ |
`hex` | String |

**Returns:** *[U512](#classes_bignum_u512md)*

___

#### `Static` fromU64

▸ **fromU64**(`value`: u64): *[U512](#classes_bignum_u512md)*

*Defined in [bignum.ts:70](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bignum.ts#L70)*

Converts a 64-bit unsigned integer into a U512.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`value` | u64 | The value to be converted.  |

**Returns:** *[U512](#classes_bignum_u512md)*


<a name="classes_bytesrepr_refmd"></a>


## Class: Ref <**T**>

Boxes a value which could then be nullable in any context.

### Type parameters

▪ **T**

### Hierarchy

* **Ref**

### Index

#### Constructors

* [constructor](#constructor)

#### Properties

* [value](#value)

### Constructors

####  constructor

\+ **new Ref**(`value`: T): *[Ref](#classes_bytesrepr_refmd)*

*Defined in [bytesrepr.ts:8](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L8)*

**Parameters:**

Name | Type |
------ | ------ |
`value` | T |

**Returns:** *[Ref](#classes_bytesrepr_refmd)*

### Properties

####  value

• **value**: *T*

*Defined in [bytesrepr.ts:9](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L9)*


<a name="classes_bytesrepr_resultmd"></a>


## Class: Result <**T**>

Class representing a result of an operation that might have failed. Can contain either a value
resulting from a successful completion of a calculation, or an error. Similar to `Result` in Rust
or `Either` in Haskell.

### Type parameters

▪ **T**

### Hierarchy

* **Result**

### Index

#### Constructors

* [constructor](#constructor)

#### Properties

* [error](#error)
* [position](#position)
* [ref](#ref)

#### Accessors

* [value](#value)

#### Methods

* [hasError](#haserror)
* [hasValue](#hasvalue)
* [ok](#ok)
* [unwrap](#unwrap)

### Constructors

####  constructor

\+ **new Result**(`ref`: [Ref](#classes_bytesrepr_refmd)‹T› | null, `error`: [Error](#enums_bytesrepr_errormd), `position`: usize): *[Result](#classes_bytesrepr_resultmd)*

*Defined in [bytesrepr.ts:53](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L53)*

Creates new Result with wrapped value

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`ref` | [Ref](#classes_bytesrepr_refmd)‹T› &#124; null | - |
`error` | [Error](#enums_bytesrepr_errormd) | Error value |
`position` | usize | Position of input stream  |

**Returns:** *[Result](#classes_bytesrepr_resultmd)*

### Properties

####  error

• **error**: *[Error](#enums_bytesrepr_errormd)*

*Defined in [bytesrepr.ts:60](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L60)*

Error value

___

####  position

• **position**: *usize*

*Defined in [bytesrepr.ts:60](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L60)*

Position of input stream

___

####  ref

• **ref**: *[Ref](#classes_bytesrepr_refmd)‹T› | null*

*Defined in [bytesrepr.ts:60](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L60)*

### Accessors

####  value

• **get value**(): *T*

*Defined in [bytesrepr.ts:65](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L65)*

Assumes that reference wrapper contains a value and then returns it

**Returns:** *T*

### Methods

####  hasError

▸ **hasError**(): *bool*

*Defined in [bytesrepr.ts:83](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L83)*

Checks if error value is set.

Truth also implies !hasValue(), false value implies hasValue()

**Returns:** *bool*

___

####  hasValue

▸ **hasValue**(): *bool*

*Defined in [bytesrepr.ts:74](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L74)*

Checks if given Result contains a value

**Returns:** *bool*

___

####  ok

▸ **ok**(): *T | null*

*Defined in [bytesrepr.ts:90](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L90)*

For nullable types, this returns the value itself, or a null.

**Returns:** *T | null*

___

####  unwrap

▸ **unwrap**(): *T*

*Defined in [bytesrepr.ts:97](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L97)*

Returns success value, or reverts error value.

**Returns:** *T*


<a name="classes_clvalue_clvaluemd"></a>


## Class: CLValue

A CasperLabs value, i.e. a value which can be stored and manipulated by smart contracts.

It holds the underlying data as a type-erased, serialized array of bytes and also holds the
[[CLType]] of the underlying data as a separate member.

### Hierarchy

* **CLValue**

### Index

#### Constructors

* [constructor](#constructor)

#### Properties

* [bytes](#bytes)
* [tag](#tag)

#### Methods

* [toBytes](#tobytes)
* [fromI32](#static-fromi32)
* [fromKey](#static-fromkey)
* [fromOption](#static-fromoption)
* [fromString](#static-fromstring)
* [fromStringList](#static-fromstringlist)
* [fromU512](#static-fromu512)
* [fromU64](#static-fromu64)
* [fromURef](#static-fromuref)

### Constructors

####  constructor

\+ **new CLValue**(`bytes`: u8[], `tag`: u8[]): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:69](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L69)*

Constructs a new `CLValue` with given underlying data and type tag.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | u8[] |
`tag` | u8[] |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

### Properties

####  bytes

• **bytes**: *u8[]*

*Defined in [clvalue.ts:68](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L68)*

___

####  tag

• **tag**: *u8[]*

*Defined in [clvalue.ts:69](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L69)*

### Methods

####  toBytes

▸ **toBytes**(): *u8[]*

*Defined in [clvalue.ts:144](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L144)*

Serializes a `CLValue` into an array of bytes.

**Returns:** *u8[]*

___

#### `Static` fromI32

▸ **fromI32**(`value`: i32): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:96](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L96)*

Creates a `CLValue` holding a signed 32-bit integer.

**Parameters:**

Name | Type |
------ | ------ |
`value` | i32 |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromKey

▸ **fromKey**(`key`: [Key](#classes_key_keymd)): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:110](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L110)*

Creates a `CLValue` holding a [Key](#key).

**Parameters:**

Name | Type |
------ | ------ |
`key` | [Key](#classes_key_keymd) |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromOption

▸ **fromOption**(`value`: [Option](#classes_option_optionmd), `nestedT`: [CLTypeTag](#enums_clvalue_cltypetagmd)): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:134](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L134)*

Creates a `CLValue` holding an [Option](#classes_option_optionmd).

**Parameters:**

Name | Type |
------ | ------ |
`value` | [Option](#classes_option_optionmd) |
`nestedT` | [CLTypeTag](#enums_clvalue_cltypetagmd) |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromString

▸ **fromString**(`s`: String): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:82](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L82)*

Creates a `CLValue` holding a string.

**Parameters:**

Name | Type |
------ | ------ |
`s` | String |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromStringList

▸ **fromStringList**(`values`: String[]): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:124](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L124)*

Creates a `CLValue` holding a list of strings.

**Parameters:**

Name | Type |
------ | ------ |
`values` | String[] |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromU512

▸ **fromU512**(`value`: [U512](#classes_bignum_u512md)): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:89](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L89)*

Creates a `CLValue` holding an unsigned 512-bit integer.

**Parameters:**

Name | Type |
------ | ------ |
`value` | [U512](#classes_bignum_u512md) |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromU64

▸ **fromU64**(`value`: u64): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:103](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L103)*

Creates a `CLValue` holding an unsigned 64-bit integer.

**Parameters:**

Name | Type |
------ | ------ |
`value` | u64 |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*

___

#### `Static` fromURef

▸ **fromURef**(`uref`: [URef](#classes_uref_urefmd)): *[CLValue](#classes_clvalue_clvaluemd)*

*Defined in [clvalue.ts:117](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L117)*

Creates a `CLValue` holding a [URef](#classes_uref_urefmd).

**Parameters:**

Name | Type |
------ | ------ |
`uref` | [URef](#classes_uref_urefmd) |

**Returns:** *[CLValue](#classes_clvalue_clvaluemd)*


<a name="classes_error_errormd"></a>


## Class: Error

This class represents error condition and is constructed by passing an error value.

The variants are split into numeric ranges as follows:

| Inclusive range | Variant(s)                                   |
| ----------------| ---------------------------------------------|
| [1, 65023]      | all except `Mint`, `ProofOfStake` and `User`. Can be created with [Error.fromErrorCode](#static-fromerrorcode) |
| [65024, 65279]  | `Mint` - instantiation currently unsupported |
| [65280, 65535]  | `ProofOfStake` errors |
| [65536, 131071] | User error codes created with [Error.fromUserError](#static-fromusererror) |

### Example usage

```typescript
// Creating using user error which adds 65536 to the error value.
Error.fromUserError(1234).revert();

// Creating using standard error variant.
Error.fromErrorCode(ErrorCode.InvalidArguent).revert();
```

### Hierarchy

* **Error**

### Index

#### Constructors

* [constructor](#constructor)

#### Methods

* [isSystemContractError](#issystemcontracterror)
* [isUserError](#isusererror)
* [revert](#revert)
* [value](#value)
* [fromErrorCode](#static-fromerrorcode)
* [fromResult](#static-fromresult)
* [fromUserError](#static-fromusererror)

### Constructors

####  constructor

\+ **new Error**(`value`: u32): *[Error](#classes_error_errormd)*

*Defined in [error.ts:115](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L115)*

Creates an error object with given error value.

Recommended way to use this class is through its static members:

* [[Error.fromUserCode]]
* [Error.fromErrorCode](#static-fromerrorcode)

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`value` | u32 | Error value  |

**Returns:** *[Error](#classes_error_errormd)*

### Methods

####  isSystemContractError

▸ **isSystemContractError**(): *bool*

*Defined in [error.ts:183](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L183)*

Checks if error value is contained within system contract error range.

**Returns:** *bool*

___

####  isUserError

▸ **isUserError**(): *bool*

*Defined in [error.ts:176](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L176)*

Checks if error value is contained within user error range.

**Returns:** *bool*

___

####  revert

▸ **revert**(): *void*

*Defined in [error.ts:190](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L190)*

Reverts execution of current contract with an error value contained within this error instance.

**Returns:** *void*

___

####  value

▸ **value**(): *u32*

*Defined in [error.ts:169](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L169)*

Returns an error value.

**Returns:** *u32*

___

#### `Static` fromErrorCode

▸ **fromErrorCode**(`errorCode`: [ErrorCode](#enums_error_errorcodemd)): *[Error](#classes_error_errormd)*

*Defined in [error.ts:162](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L162)*

Creates new error object from an [ErrorCode](#enums_error_errorcodemd) value.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`errorCode` | [ErrorCode](#enums_error_errorcodemd) | Variant of a standarized error.  |

**Returns:** *[Error](#classes_error_errormd)*

___

#### `Static` fromResult

▸ **fromResult**(`result`: u32): *[Error](#classes_error_errormd) | null*

*Defined in [error.ts:139](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L139)*

Creates an error object from a result value.

Results in host interface contains 0 for a successful operation,
or a non-zero standardized error otherwise.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`result` | u32 | A result value obtained from host interface functions. |

**Returns:** *[Error](#classes_error_errormd) | null*

Error object with an error [ErrorCode](#enums_error_errorcodemd) variant.

___

#### `Static` fromUserError

▸ **fromUserError**(`userErrorCodeValue`: u16): *[Error](#classes_error_errormd)*

*Defined in [error.ts:153](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L153)*

Creates new error from user value.

Actual value held by returned [Error](#classes_error_errormd) object will be 65536 with added passed value.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`userErrorCodeValue` | u16 |   |

**Returns:** *[Error](#classes_error_errormd)*


<a name="classes_key_keymd"></a>


## Class: Key

The type under which data (e.g. [CLValue](#classes_clvalue_clvaluemd)s, smart contracts, user accounts)
are indexed on the network.

### Hierarchy

* **Key**

### Index

#### Properties

* [account](#account)
* [hash](#hash)
* [uref](#uref)
* [variant](#variant)

#### Methods

* [add](#add)
* [equalsTo](#equalsto)
* [isURef](#isuref)
* [notEqualsTo](#notequalsto)
* [read](#read)
* [toBytes](#tobytes)
* [toURef](#touref)
* [write](#write)
* [create](#static-create)
* [fromAccount](#static-fromaccount)
* [fromBytes](#static-frombytes)
* [fromHash](#static-fromhash)
* [fromURef](#static-fromuref)

### Properties

####  account

• **account**: *[PublicKey](#classes_key_publickeymd) | null*

*Defined in [key.ts:75](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L75)*

___

####  hash

• **hash**: *Uint8Array | null*

*Defined in [key.ts:73](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L73)*

___

####  uref

• **uref**: *[URef](#classes_uref_urefmd) | null*

*Defined in [key.ts:74](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L74)*

___

####  variant

• **variant**: *[KeyVariant](#enums_key_keyvariantmd)*

*Defined in [key.ts:72](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L72)*

### Methods

####  add

▸ **add**(`value`: [CLValue](#classes_clvalue_clvaluemd)): *void*

*Defined in [key.ts:235](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L235)*

Adds the given `CLValue` to a value already stored under this `Key`.

**Parameters:**

Name | Type |
------ | ------ |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *void*

___

####  equalsTo

▸ **equalsTo**(`other`: [Key](#classes_key_keymd)): *bool*

*Defined in [key.ts:249](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L249)*

Checks whether two `Key`s are equal.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [Key](#classes_key_keymd) |

**Returns:** *bool*

___

####  isURef

▸ **isURef**(): *bool*

*Defined in [key.ts:196](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L196)*

Checks whether the `Key` is of [KeyVariant](#enums_key_keyvariantmd).UREF_ID.

**Returns:** *bool*

___

####  notEqualsTo

▸ **notEqualsTo**(`other`: [Key](#classes_key_keymd)): *bool*

*Defined in [key.ts:282](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L282)*

Checks whether two keys are not equal.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [Key](#classes_key_keymd) |

**Returns:** *bool*

___

####  read

▸ **read**(): *Uint8Array | null*

*Defined in [key.ts:206](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L206)*

Reads the data stored under this `Key`.

**Returns:** *Uint8Array | null*

___

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [key.ts:168](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L168)*

Serializes a `Key` into an array of bytes.

**Returns:** *Array‹u8›*

___

####  toURef

▸ **toURef**(): *[URef](#classes_uref_urefmd)*

*Defined in [key.ts:201](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L201)*

Converts the `Key` into `URef`.

**Returns:** *[URef](#classes_uref_urefmd)*

___

####  write

▸ **write**(`value`: [CLValue](#classes_clvalue_clvaluemd)): *void*

*Defined in [key.ts:223](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L223)*

Stores a [CLValue](#classes_clvalue_clvaluemd) under this `Key`.

**Parameters:**

Name | Type |
------ | ------ |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *void*

___

#### `Static` create

▸ **create**(`value`: [CLValue](#classes_clvalue_clvaluemd)): *[Key](#classes_key_keymd) | null*

*Defined in [key.ts:106](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L106)*

Attempts to write `value` under a new Key::URef

If a key is returned it is always of [KeyVariant](#enums_key_keyvariantmd).UREF_ID

**Parameters:**

Name | Type |
------ | ------ |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *[Key](#classes_key_keymd) | null*

___

#### `Static` fromAccount

▸ **fromAccount**(`account`: [PublicKey](#classes_key_publickeymd)): *[Key](#classes_key_keymd)*

*Defined in [key.ts:94](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L94)*

Creates a `Key` from a [PublicKey](#classes_key_publickeymd) representing an account.

**Parameters:**

Name | Type |
------ | ------ |
`account` | [PublicKey](#classes_key_publickeymd) |

**Returns:** *[Key](#classes_key_keymd)*

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹[Key](#classes_key_keymd)›*

*Defined in [key.ts:126](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L126)*

Deserializes a `Key` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹[Key](#classes_key_keymd)›*

___

#### `Static` fromHash

▸ **fromHash**(`hash`: Uint8Array): *[Key](#classes_key_keymd)*

*Defined in [key.ts:86](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L86)*

Creates a `Key` from a given hash.

**Parameters:**

Name | Type |
------ | ------ |
`hash` | Uint8Array |

**Returns:** *[Key](#classes_key_keymd)*

___

#### `Static` fromURef

▸ **fromURef**(`uref`: [URef](#classes_uref_urefmd)): *[Key](#classes_key_keymd)*

*Defined in [key.ts:78](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L78)*

Creates a `Key` from a given [URef](#classes_uref_urefmd).

**Parameters:**

Name | Type |
------ | ------ |
`uref` | [URef](#classes_uref_urefmd) |

**Returns:** *[Key](#classes_key_keymd)*


<a name="classes_key_publickeymd"></a>


## Class: PublicKey

A cryptographic public key.

### Hierarchy

* **PublicKey**

### Index

#### Constructors

* [constructor](#constructor)

#### Properties

* [bytes](#bytes)
* [variant](#variant)

#### Methods

* [equalsTo](#equalsto)
* [notEqualsTo](#notequalsto)
* [toBytes](#tobytes)
* [fromBytes](#static-frombytes)

### Constructors

####  constructor

\+ **new PublicKey**(`variant`: u8, `bytes`: Uint8Array): *[PublicKey](#classes_key_publickeymd)*

*Defined in [key.ts:28](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L28)*

Constructs a new `PublicKey`.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`variant` | u8 | An ID of the used key variant. |
`bytes` | Uint8Array | The bytes constituting the public key.  |

**Returns:** *[PublicKey](#classes_key_publickeymd)*

### Properties

####  bytes

• **bytes**: *Uint8Array*

*Defined in [key.ts:35](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L35)*

The bytes constituting the public key.

___

####  variant

• **variant**: *u8*

*Defined in [key.ts:35](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L35)*

An ID of the used key variant.

### Methods

####  equalsTo

▸ **equalsTo**(`other`: [PublicKey](#classes_key_publickeymd)): *bool*

*Defined in [key.ts:39](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L39)*

Checks whether two `PublicKey`s are equal.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [PublicKey](#classes_key_publickeymd) |

**Returns:** *bool*

___

####  notEqualsTo

▸ **notEqualsTo**(`other`: [PublicKey](#classes_key_publickeymd)): *bool*

*Defined in [key.ts:45](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L45)*

Checks whether two `PublicKey`s are not equal.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [PublicKey](#classes_key_publickeymd) |

**Returns:** *bool*

___

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [key.ts:62](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L62)*

Serializes a `PublicKey` into an array of bytes.

**Returns:** *Array‹u8›*

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹[PublicKey](#classes_key_publickeymd)›*

*Defined in [key.ts:50](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L50)*

Deserializes a `PublicKey` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹[PublicKey](#classes_key_publickeymd)›*


<a name="classes_option_optionmd"></a>


## Class: Option

A class representing an optional value, i.e. it might contain either a value of some type or
no value at all. Similar to Rust's `Option` or Haskell's `Maybe`.

### Hierarchy

* **Option**

### Index

#### Constructors

* [constructor](#constructor)

#### Methods

* [isNone](#isnone)
* [isSome](#issome)
* [toBytes](#tobytes)
* [unwrap](#unwrap)
* [fromBytes](#static-frombytes)

### Constructors

####  constructor

\+ **new Option**(`bytes`: Uint8Array | null): *[Option](#classes_option_optionmd)*

*Defined in [option.ts:10](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L10)*

Constructs a new option containing the value of `bytes`. `bytes` can be `null`, which
indicates no value.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array &#124; null |

**Returns:** *[Option](#classes_option_optionmd)*

### Methods

####  isNone

▸ **isNone**(): *bool*

*Defined in [option.ts:25](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L25)*

Checks whether the `Option` contains no value.

**Returns:** *bool*

True if the `Option` has no value.

___

####  isSome

▸ **isSome**(): *bool*

*Defined in [option.ts:34](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L34)*

Checks whether the `Option` contains a value.

**Returns:** *bool*

True if the `Option` has some value.

___

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [option.ts:50](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L50)*

Serializes the `Option` into an array of bytes.

**Returns:** *Array‹u8›*

___

####  unwrap

▸ **unwrap**(): *Uint8Array | null*

*Defined in [option.ts:43](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L43)*

Unwraps the `Option`, returning the inner value (or `null` if there was none).

**Returns:** *Uint8Array | null*

The inner value, or `null` if there was none.

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Option](#classes_option_optionmd)*

*Defined in [option.ts:70](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/option.ts#L70)*

Deserializes an array of bytes into an `Option`.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Option](#classes_option_optionmd)*


<a name="classes_pair_pairmd"></a>


## Class: Pair <**T1, T2**>

A pair of values.

### Type parameters

▪ **T1**

The type of the first value.

▪ **T2**

The type of the second value.

### Hierarchy

* **Pair**

### Index

#### Constructors

* [constructor](#constructor)

#### Properties

* [first](#first)
* [second](#second)

#### Methods

* [equalsTo](#equalsto)
* [notEqualsTo](#notequalsto)

### Constructors

####  constructor

\+ **new Pair**(`first`: T1, `second`: T2): *[Pair](#classes_pair_pairmd)*

*Defined in [pair.ts:15](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/pair.ts#L15)*

Constructs the pair out of the two given values.

**Parameters:**

Name | Type |
------ | ------ |
`first` | T1 |
`second` | T2 |

**Returns:** *[Pair](#classes_pair_pairmd)*

### Properties

####  first

• **first**: *T1*

*Defined in [pair.ts:11](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/pair.ts#L11)*

The first value in the pair.

___

####  second

• **second**: *T2*

*Defined in [pair.ts:15](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/pair.ts#L15)*

The second value in the pair.

### Methods

####  equalsTo

▸ **equalsTo**(`other`: [Pair](#classes_pair_pairmd)‹T1, T2›): *bool*

*Defined in [pair.ts:30](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/pair.ts#L30)*

Checks whether two pairs are equal. The pairs are considered equal when both their first
and second values are equal.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [Pair](#classes_pair_pairmd)‹T1, T2› |

**Returns:** *bool*

___

####  notEqualsTo

▸ **notEqualsTo**(`other`: [Pair](#classes_pair_pairmd)‹T1, T2›): *bool*

*Defined in [pair.ts:38](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/pair.ts#L38)*

Checks whether two pairs are not equal (the opposite of [equalsTo](#equalsto)).

**Parameters:**

Name | Type |
------ | ------ |
`other` | [Pair](#classes_pair_pairmd)‹T1, T2› |

**Returns:** *bool*


<a name="classes_unit_unitmd"></a>


## Class: Unit

A class representing the unit type, i.e. a type that has no values (equivalent to eg. `void` in
C or `()` in Rust).

### Hierarchy

* **Unit**

### Index

#### Methods

* [toBytes](#tobytes)
* [fromBytes](#static-frombytes)

### Methods

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [unit.ts:9](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/unit.ts#L9)*

Serializes a [Unit](#classes_unit_unitmd) - returns an empty array.

**Returns:** *Array‹u8›*

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Unit](#classes_unit_unitmd)*

*Defined in [unit.ts:16](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/unit.ts#L16)*

Deserializes a [Unit](#classes_unit_unitmd) - returns a new [Unit](#classes_unit_unitmd).

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Unit](#classes_unit_unitmd)*


<a name="classes_uref_urefmd"></a>


## Class: URef

Represents an unforgeable reference, containing an address in the network's global storage and
the [AccessRights](#enums_uref_accessrightsmd) of the reference.

A [URef](#classes_uref_urefmd) can be used to index entities such as [CLValue](#classes_clvalue_clvaluemd)s, or smart contracts.

### Hierarchy

* **URef**

### Index

#### Constructors

* [constructor](#constructor)

#### Methods

* [equalsTo](#equalsto)
* [getAccessRights](#getaccessrights)
* [getBytes](#getbytes)
* [isValid](#isvalid)
* [notEqualsTo](#notequalsto)
* [toBytes](#tobytes)
* [fromBytes](#static-frombytes)

### Constructors

####  constructor

\+ **new URef**(`bytes`: Uint8Array, `accessRights`: [AccessRights](#enums_uref_accessrightsmd)): *[URef](#classes_uref_urefmd)*

*Defined in [uref.ts:55](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L55)*

Constructs new instance of URef.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`bytes` | Uint8Array | Bytes representing address of the URef. |
`accessRights` | [AccessRights](#enums_uref_accessrightsmd) | Access rights flag. Use [AccessRights.NONE](#none) to indicate no permissions.  |

**Returns:** *[URef](#classes_uref_urefmd)*

### Methods

####  equalsTo

▸ **equalsTo**(`other`: [URef](#classes_uref_urefmd)): *bool*

*Defined in [uref.ts:133](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L133)*

The equality operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [URef](#classes_uref_urefmd) |

**Returns:** *bool*

True if `this` and `other` are equal, false otherwise.

___

####  getAccessRights

▸ **getAccessRights**(): *[AccessRights](#enums_uref_accessrightsmd)*

*Defined in [uref.ts:79](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L79)*

Returns the access rights of this [URef](#classes_uref_urefmd).

**Returns:** *[AccessRights](#enums_uref_accessrightsmd)*

___

####  getBytes

▸ **getBytes**(): *Uint8Array*

*Defined in [uref.ts:72](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L72)*

Returns the address of this URef as an array of bytes.

**Returns:** *Uint8Array*

A byte array with a length of 32.

___

####  isValid

▸ **isValid**(): *boolean*

*Defined in [uref.ts:86](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L86)*

Validates uref against named keys.

**Returns:** *boolean*

___

####  notEqualsTo

▸ **notEqualsTo**(`other`: [URef](#classes_uref_urefmd)): *bool*

*Defined in [uref.ts:143](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L143)*

The not-equal operator.

**Parameters:**

Name | Type |
------ | ------ |
`other` | [URef](#classes_uref_urefmd) |

**Returns:** *bool*

False if `this` and `other` are equal, true otherwise.

___

####  toBytes

▸ **toBytes**(): *Array‹u8›*

*Defined in [uref.ts:117](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L117)*

Serializes the URef into an array of bytes that represents it in the CasperLabs serialization
format.

**Returns:** *Array‹u8›*

___

#### `Static` fromBytes

▸ **fromBytes**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹[URef](#classes_uref_urefmd)›*

*Defined in [uref.ts:99](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L99)*

Deserializes a new [URef](#classes_uref_urefmd) from bytes.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`bytes` | Uint8Array | Input bytes. Requires at least 33 bytes to properly deserialize an [URef](#classes_uref_urefmd).  |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹[URef](#classes_uref_urefmd)›*

# Enums


<a name="enums_account_actiontypemd"></a>


## Enumeration: ActionType

Enum representing an action for which a threshold is being set.

### Index

#### Enumeration members

* [Deployment](#deployment)
* [KeyManagement](#keymanagement)

### Enumeration members

####  Deployment

• **Deployment**: = 0

*Defined in [account.ts:106](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L106)*

Required by deploy execution.

___

####  KeyManagement

• **KeyManagement**: = 1

*Defined in [account.ts:110](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L110)*

Required when adding/removing associated keys, changing threshold levels.


<a name="enums_account_addkeyfailuremd"></a>


## Enumeration: AddKeyFailure

Enum representing the possible results of adding an associated key to an account.

### Index

#### Enumeration members

* [DuplicateKey](#duplicatekey)
* [MaxKeysLimit](#maxkeyslimit)
* [Ok](#ok)
* [PermissionDenied](#permissiondenied)

### Enumeration members

####  DuplicateKey

• **DuplicateKey**: = 2

*Defined in [account.ts:22](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L22)*

Unable to add new associated key because given key already exists

___

####  MaxKeysLimit

• **MaxKeysLimit**: = 1

*Defined in [account.ts:18](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L18)*

Unable to add new associated key because maximum amount of keys is reached

___

####  Ok

• **Ok**: = 0

*Defined in [account.ts:14](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L14)*

Success

___

####  PermissionDenied

• **PermissionDenied**: = 3

*Defined in [account.ts:26](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L26)*

Unable to add new associated key due to insufficient permissions


<a name="enums_account_removekeyfailuremd"></a>


## Enumeration: RemoveKeyFailure

Enum representing the possible results of removing an associated key from an account.

### Index

#### Enumeration members

* [MissingKey](#missingkey)
* [Ok](#ok)
* [PermissionDenied](#permissiondenied)
* [ThresholdViolation](#thresholdviolation)

### Enumeration members

####  MissingKey

• **MissingKey**: = 1

*Defined in [account.ts:62](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L62)*

Key does not exist in the list of associated keys.

___

####  Ok

• **Ok**: = 0

*Defined in [account.ts:58](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L58)*

Success

___

####  PermissionDenied

• **PermissionDenied**: = 2

*Defined in [account.ts:66](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L66)*

Unable to remove the associated key due to insufficient permissions

___

####  ThresholdViolation

• **ThresholdViolation**: = 3

*Defined in [account.ts:70](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L70)*

Unable to remove a key which would violate action threshold constraints


<a name="enums_account_setthresholdfailuremd"></a>


## Enumeration: SetThresholdFailure

Enum representing the possible results of setting the threshold of an account.

### Index

#### Enumeration members

* [DeploymentThreshold](#deploymentthreshold)
* [InsufficientTotalWeight](#insufficienttotalweight)
* [KeyManagementThreshold](#keymanagementthreshold)
* [Ok](#ok)
* [PermissionDeniedError](#permissiondeniederror)

### Enumeration members

####  DeploymentThreshold

• **DeploymentThreshold**: = 2

*Defined in [account.ts:88](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L88)*

New threshold should be lower or equal than key management threshold

___

####  InsufficientTotalWeight

• **InsufficientTotalWeight**: = 4

*Defined in [account.ts:96](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L96)*

New threshold should be lower or equal than total weight of associated keys

___

####  KeyManagementThreshold

• **KeyManagementThreshold**: = 1

*Defined in [account.ts:84](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L84)*

New threshold should be lower or equal than deployment threshold

___

####  Ok

• **Ok**: = 0

*Defined in [account.ts:80](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L80)*

Success

___

####  PermissionDeniedError

• **PermissionDeniedError**: = 3

*Defined in [account.ts:92](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L92)*

Unable to set action threshold due to insufficient permissions


<a name="enums_account_updatekeyfailuremd"></a>


## Enumeration: UpdateKeyFailure

Enum representing the possible results of updating an associated key of an account.

### Index

#### Enumeration members

* [MissingKey](#missingkey)
* [Ok](#ok)
* [PermissionDenied](#permissiondenied)
* [ThresholdViolation](#thresholdviolation)

### Enumeration members

####  MissingKey

• **MissingKey**: = 1

*Defined in [account.ts:40](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L40)*

Key does not exist in the list of associated keys.

___

####  Ok

• **Ok**: = 0

*Defined in [account.ts:36](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L36)*

Success

___

####  PermissionDenied

• **PermissionDenied**: = 2

*Defined in [account.ts:44](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L44)*

Unable to update the associated key due to insufficient permissions

___

####  ThresholdViolation

• **ThresholdViolation**: = 3

*Defined in [account.ts:48](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L48)*

Unable to update weight that would fall below any of action thresholds


<a name="enums_bytesrepr_errormd"></a>


## Enumeration: Error

Enum representing possible results of deserialization.

### Index

#### Enumeration members

* [EarlyEndOfStream](#earlyendofstream)
* [FormattingError](#formattingerror)
* [Ok](#ok)

### Enumeration members

####  EarlyEndOfStream

• **EarlyEndOfStream**: = 1

*Defined in [bytesrepr.ts:24](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L24)*

Early end of stream

___

####  FormattingError

• **FormattingError**: = 2

*Defined in [bytesrepr.ts:28](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L28)*

Unexpected data encountered while decoding byte stream

___

####  Ok

• **Ok**: = 0

*Defined in [bytesrepr.ts:20](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L20)*

Last operation was a success


<a name="enums_clvalue_cltypetagmd"></a>


## Enumeration: CLTypeTag

CasperLabs types, i.e. types which can be stored and manipulated by smart contracts.

Provides a description of the underlying data type of a [CLValue](#classes_clvalue_clvaluemd).

### Index

#### Enumeration members

* [Any](#any)
* [Bool](#bool)
* [Fixed_list](#fixed_list)
* [I32](#i32)
* [I64](#i64)
* [Key](#key)
* [List](#list)
* [Map](#map)
* [Option](#option)
* [Result](#result)
* [String](#string)
* [Tuple1](#tuple1)
* [Tuple2](#tuple2)
* [Tuple3](#tuple3)
* [U128](#u128)
* [U256](#u256)
* [U32](#u32)
* [U512](#u512)
* [U64](#u64)
* [U8](#u8)
* [Unit](#unit)
* [Uref](#uref)

### Enumeration members

####  Any

• **Any**: = 21

*Defined in [clvalue.ts:58](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L58)*

A value of any type.

___

####  Bool

• **Bool**: = 0

*Defined in [clvalue.ts:14](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L14)*

A boolean value

___

####  Fixed_list

• **Fixed_list**: = 15

*Defined in [clvalue.ts:44](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L44)*

A fixed-length list of values

___

####  I32

• **I32**: = 1

*Defined in [clvalue.ts:16](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L16)*

A 32-bit signed integer

___

####  I64

• **I64**: = 2

*Defined in [clvalue.ts:18](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L18)*

A 64-bit signed integer

___

####  Key

• **Key**: = 11

*Defined in [clvalue.ts:36](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L36)*

A key in the global state - URef/hash/etc.

___

####  List

• **List**: = 14

*Defined in [clvalue.ts:42](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L42)*

A list of values

___

####  Map

• **Map**: = 17

*Defined in [clvalue.ts:50](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L50)*

A key-value map.

___

####  Option

• **Option**: = 13

*Defined in [clvalue.ts:40](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L40)*

An [Option](#option), i.e. a type that can contain a value or nothing at all

___

####  Result

• **Result**: = 16

*Defined in [clvalue.ts:48](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L48)*

A [Result](#result), i.e. a type that can contain either a value representing success or one representing failure.

___

####  String

• **String**: = 10

*Defined in [clvalue.ts:34](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L34)*

A string of characters

___

####  Tuple1

• **Tuple1**: = 18

*Defined in [clvalue.ts:52](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L52)*

A 1-value tuple.

___

####  Tuple2

• **Tuple2**: = 19

*Defined in [clvalue.ts:54](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L54)*

A 2-value tuple, i.e. a pair of values.

___

####  Tuple3

• **Tuple3**: = 20

*Defined in [clvalue.ts:56](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L56)*

A 3-value tuple.

___

####  U128

• **U128**: = 6

*Defined in [clvalue.ts:26](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L26)*

A 128-bit unsigned integer

___

####  U256

• **U256**: = 7

*Defined in [clvalue.ts:28](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L28)*

A 256-bit unsigned integer

___

####  U32

• **U32**: = 4

*Defined in [clvalue.ts:22](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L22)*

A 32-bit unsigned integer

___

####  U512

• **U512**: = 8

*Defined in [clvalue.ts:30](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L30)*

A 512-bit unsigned integer

___

####  U64

• **U64**: = 5

*Defined in [clvalue.ts:24](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L24)*

A 64-bit unsigned integer

___

####  U8

• **U8**: = 3

*Defined in [clvalue.ts:20](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L20)*

An 8-bit unsigned integer (a byte)

___

####  Unit

• **Unit**: = 9

*Defined in [clvalue.ts:32](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L32)*

A unit type, i.e. type with no values (analogous to `void` in C and `()` in Rust)

___

####  Uref

• **Uref**: = 12

*Defined in [clvalue.ts:38](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/clvalue.ts#L38)*

An Unforgeable Reference (URef)


<a name="enums_error_errorcodemd"></a>


## Enumeration: ErrorCode

Standard error codes which can be encountered while running a smart contract.

An [ErrorCode](#enums_error_errorcodemd) can be passed to [Error.fromErrorCode](#static-fromerrorcode) function to create an error object.
This error object later can be used to stop execution by using [Error.revert](#revert) method.

### Index

#### Enumeration members

* [BufferTooSmall](#buffertoosmall)
* [CLTypeMismatch](#cltypemismatch)
* [ContractNotFound](#contractnotfound)
* [DeploymentThreshold](#deploymentthreshold)
* [Deserialize](#deserialize)
* [DuplicateKey](#duplicatekey)
* [EarlyEndOfStream](#earlyendofstream)
* [Formatting](#formatting)
* [GetKey](#getkey)
* [HostBufferEmpty](#hostbufferempty)
* [HostBufferFull](#hostbufferfull)
* [InsufficientTotalWeight](#insufficienttotalweight)
* [InvalidArgument](#invalidargument)
* [InvalidPurse](#invalidpurse)
* [InvalidPurseName](#invalidpursename)
* [InvalidSystemContract](#invalidsystemcontract)
* [KeyManagementThreshold](#keymanagementthreshold)
* [LeftOverBytes](#leftoverbytes)
* [MaxKeysLimit](#maxkeyslimit)
* [MissingArgument](#missingargument)
* [MissingKey](#missingkey)
* [NoAccessRights](#noaccessrights)
* [None](#none)
* [OutOfMemory](#outofmemory)
* [PermissionDenied](#permissiondenied)
* [PurseNotCreated](#pursenotcreated)
* [Read](#read)
* [ThresholdViolation](#thresholdviolation)
* [Transfer](#transfer)
* [UnexpectedContractRefVariant](#unexpectedcontractrefvariant)
* [UnexpectedKeyVariant](#unexpectedkeyvariant)
* [Unhandled](#unhandled)
* [UpgradeContractAtURef](#upgradecontractaturef)
* [ValueNotFound](#valuenotfound)

### Enumeration members

####  BufferTooSmall

• **BufferTooSmall**: = 32

*Defined in [error.ts:84](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L84)*

The provided buffer is too small to complete an operation.

___

####  CLTypeMismatch

• **CLTypeMismatch**: = 16

*Defined in [error.ts:52](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L52)*

A given type could not be constructed from a [CLValue](#classes_clvalue_clvaluemd).

___

####  ContractNotFound

• **ContractNotFound**: = 7

*Defined in [error.ts:34](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L34)*

Failed to find a specified contract.

___

####  DeploymentThreshold

• **DeploymentThreshold**: = 27

*Defined in [error.ts:74](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L74)*

Setting the deployment threshold to a value greater than any other threshold is disallowed.

___

####  Deserialize

• **Deserialize**: = 4

*Defined in [error.ts:28](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L28)*

Failed to deserialize a value.

___

####  DuplicateKey

• **DuplicateKey**: = 22

*Defined in [error.ts:64](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L64)*

The given public key is already associated with the given account.

___

####  EarlyEndOfStream

• **EarlyEndOfStream**: = 17

*Defined in [error.ts:54](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L54)*

Early end of stream while deserializing.

___

####  Formatting

• **Formatting**: = 18

*Defined in [error.ts:56](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L56)*

Formatting error while deserializing.

___

####  GetKey

• **GetKey**: = 8

*Defined in [error.ts:36](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L36)*

A call to [getKey](#getkey) returned a failure.

___

####  HostBufferEmpty

• **HostBufferEmpty**: = 33

*Defined in [error.ts:86](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L86)*

No data available in the host buffer.

___

####  HostBufferFull

• **HostBufferFull**: = 34

*Defined in [error.ts:88](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L88)*

The host buffer has been set to a value and should be consumed first by a read operation.

___

####  InsufficientTotalWeight

• **InsufficientTotalWeight**: = 28

*Defined in [error.ts:76](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L76)*

Setting a threshold to a value greater than the total weight of associated keys is disallowed.

___

####  InvalidArgument

• **InvalidArgument**: = 3

*Defined in [error.ts:26](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L26)*

Argument not of correct type.

___

####  InvalidPurse

• **InvalidPurse**: = 12

*Defined in [error.ts:44](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L44)*

Invalid purse retrieved.

___

####  InvalidPurseName

• **InvalidPurseName**: = 11

*Defined in [error.ts:42](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L42)*

Invalid purse name given.

___

####  InvalidSystemContract

• **InvalidSystemContract**: = 29

*Defined in [error.ts:78](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L78)*

The given `u32` doesn't map to a [[SystemContractType]].

___

####  KeyManagementThreshold

• **KeyManagementThreshold**: = 26

*Defined in [error.ts:72](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L72)*

Setting the key-management threshold to a value lower than the deployment threshold is disallowed.

___

####  LeftOverBytes

• **LeftOverBytes**: = 19

*Defined in [error.ts:58](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L58)*

Not all input bytes were consumed in deserializing operation

___

####  MaxKeysLimit

• **MaxKeysLimit**: = 21

*Defined in [error.ts:62](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L62)*

There are already maximum public keys associated with the given account.

___

####  MissingArgument

• **MissingArgument**: = 2

*Defined in [error.ts:24](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L24)*

Specified argument not provided.

___

####  MissingKey

• **MissingKey**: = 24

*Defined in [error.ts:68](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L68)*

The given public key is not associated with the given account.

___

####  NoAccessRights

• **NoAccessRights**: = 15

*Defined in [error.ts:50](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L50)*

The given [URef](#classes_uref_urefmd) has no access rights.

___

####  None

• **None**: = 1

*Defined in [error.ts:22](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L22)*

Optional data was unexpectedly `None`.

___

####  OutOfMemory

• **OutOfMemory**: = 20

*Defined in [error.ts:60](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L60)*

Out of memory error.

___

####  PermissionDenied

• **PermissionDenied**: = 23

*Defined in [error.ts:66](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L66)*

Caller doesn't have sufficient permissions to perform the given action.

___

####  PurseNotCreated

• **PurseNotCreated**: = 30

*Defined in [error.ts:80](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L80)*

Failed to create a new purse.

___

####  Read

• **Read**: = 5

*Defined in [error.ts:30](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L30)*

`casperlabs_contract::storage::read()` returned an error.

___

####  ThresholdViolation

• **ThresholdViolation**: = 25

*Defined in [error.ts:70](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L70)*

Removing/updating the given associated public key would cause the total weight of all remaining `PublicKey`s to fall below one of the action thresholds for the given account.

___

####  Transfer

• **Transfer**: = 14

*Defined in [error.ts:48](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L48)*

Failed to transfer motes.

___

####  UnexpectedContractRefVariant

• **UnexpectedContractRefVariant**: = 10

*Defined in [error.ts:40](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L40)*

The `Contract` variant was not as expected.

___

####  UnexpectedKeyVariant

• **UnexpectedKeyVariant**: = 9

*Defined in [error.ts:38](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L38)*

The [Key](#key) variant was not as expected.

___

####  Unhandled

• **Unhandled**: = 31

*Defined in [error.ts:82](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L82)*

An unhandled value, likely representing a bug in the code.

___

####  UpgradeContractAtURef

• **UpgradeContractAtURef**: = 13

*Defined in [error.ts:46](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L46)*

Failed to upgrade contract at [URef](#classes_uref_urefmd).

___

####  ValueNotFound

• **ValueNotFound**: = 6

*Defined in [error.ts:32](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/error.ts#L32)*

The given key returned a `None` value.


<a name="enums_index_phasemd"></a>


## Enumeration: Phase

The phase in which a given contract is executing.

### Index

#### Enumeration members

* [FinalizePayment](#finalizepayment)
* [Payment](#payment)
* [Session](#session)
* [System](#system)

### Enumeration members

####  FinalizePayment

• **FinalizePayment**: = 3

*Defined in [index.ts:345](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L345)*

Set while finalizing payment at the end of a deploy.

___

####  Payment

• **Payment**: = 1

*Defined in [index.ts:337](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L337)*

Set while executing the payment code of a deploy.

___

####  Session

• **Session**: = 2

*Defined in [index.ts:341](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L341)*

Set while executing the session code of a deploy.

___

####  System

• **System**: = 0

*Defined in [index.ts:333](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L333)*

Set while committing the genesis or upgrade configurations.


<a name="enums_index_systemcontractmd"></a>


## Enumeration: SystemContract

System contract types.

### Index

#### Enumeration members

* [Mint](#mint)
* [ProofOfStake](#proofofstake)
* [StandardPayment](#standardpayment)

### Enumeration members

####  Mint

• **Mint**: = 0

*Defined in [index.ts:32](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L32)*

Mint contract.

___

####  ProofOfStake

• **ProofOfStake**: = 1

*Defined in [index.ts:36](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L36)*

Proof of Stake contract.

___

####  StandardPayment

• **StandardPayment**: = 2

*Defined in [index.ts:40](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L40)*

Standard Payment contract.


<a name="enums_key_keyvariantmd"></a>


## Enumeration: KeyVariant

Enum representing a variant of a [Key](#classes_key_keymd) - Account, Hash or URef.

### Index

#### Enumeration members

* [ACCOUNT_ID](#account_id)
* [HASH_ID](#hash_id)
* [UREF_ID](#uref_id)

### Enumeration members

####  ACCOUNT_ID

• **ACCOUNT_ID**: = 0

*Defined in [key.ts:15](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L15)*

The Account variant

___

####  HASH_ID

• **HASH_ID**: = 1

*Defined in [key.ts:17](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L17)*

The Hash variant

___

####  UREF_ID

• **UREF_ID**: = 2

*Defined in [key.ts:19](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L19)*

The URef variant


<a name="enums_purse_transferredtomd"></a>


## Enumeration: TransferredTo

The result of a successful transfer between purses.

### Index

#### Enumeration members

* [ExistingAccount](#existingaccount)
* [NewAccount](#newaccount)
* [TransferError](#transfererror)

### Enumeration members

####  ExistingAccount

• **ExistingAccount**: = 0

*Defined in [purse.ts:19](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L19)*

The destination account already existed.

___

####  NewAccount

• **NewAccount**: = 1

*Defined in [purse.ts:23](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L23)*

The destination account was created.

___

####  TransferError

• **TransferError**: = -1

*Defined in [purse.ts:15](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L15)*

The transfer operation resulted in an error.


<a name="enums_uref_accessrightsmd"></a>


## Enumeration: AccessRights

A set of bitflags that defines access rights associated with a [URef](#classes_uref_urefmd).

### Index

#### Enumeration members

* [ADD](#add)
* [ADD_WRITE](#add_write)
* [NONE](#none)
* [READ](#read)
* [READ_ADD](#read_add)
* [READ_ADD_WRITE](#read_add_write)
* [READ_WRITE](#read_write)
* [WRITE](#write)

### Enumeration members

####  ADD

• **ADD**: = 4

*Defined in [uref.ts:29](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L29)*

Permission to add to the value under the associated [URef](#classes_uref_urefmd).

___

####  ADD_WRITE

• **ADD_WRITE**: = 6

*Defined in [uref.ts:37](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L37)*

Permission to add to, or write the value under the associated [URef](#classes_uref_urefmd).

___

####  NONE

• **NONE**: = 0

*Defined in [uref.ts:13](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L13)*

No permissions

___

####  READ

• **READ**: = 1

*Defined in [uref.ts:17](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L17)*

Permission to read the value under the associated [URef](#classes_uref_urefmd).

___

####  READ_ADD

• **READ_ADD**: = 5

*Defined in [uref.ts:33](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L33)*

Permission to read or add to the value under the associated [URef](#classes_uref_urefmd).

___

####  READ_ADD_WRITE

• **READ_ADD_WRITE**: = 7

*Defined in [uref.ts:41](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L41)*

Permission to read, add to, or write the value under the associated [URef](#classes_uref_urefmd).

___

####  READ_WRITE

• **READ_WRITE**: = 3

*Defined in [uref.ts:25](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L25)*

Permission to read or write the value under the associated [URef](#classes_uref_urefmd).

___

####  WRITE

• **WRITE**: = 2

*Defined in [uref.ts:21](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/uref.ts#L21)*

Permission to write a value under the associated [URef](#classes_uref_urefmd).

# Modules


<a name="modules_account_md"></a>


## Module: "account"

### Index

#### Enumerations

* [ActionType](#enums_account_actiontypemd)
* [AddKeyFailure](#enums_account_addkeyfailuremd)
* [RemoveKeyFailure](#enums_account_removekeyfailuremd)
* [SetThresholdFailure](#enums_account_setthresholdfailuremd)
* [UpdateKeyFailure](#enums_account_updatekeyfailuremd)

#### Functions

* [addAssociatedKey](#addassociatedkey)
* [getMainPurse](#getmainpurse)
* [removeAssociatedKey](#removeassociatedkey)
* [setActionThreshold](#setactionthreshold)
* [updateAssociatedKey](#updateassociatedkey)

### Functions

####  addAssociatedKey

▸ **addAssociatedKey**(`publicKey`: [PublicKey](#classes_key_publickeymd), `weight`: i32): *[AddKeyFailure](#enums_account_addkeyfailuremd)*

*Defined in [account.ts:122](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L122)*

Adds an associated key to the account. Associated keys are the keys allowed to sign actions performed
in the context of the account.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`publicKey` | [PublicKey](#classes_key_publickeymd) | The public key to be added as the associated key. |
`weight` | i32 | The weight that will be assigned to the new associated key. See [setActionThreshold](#setactionthreshold)    for more info about weights. |

**Returns:** *[AddKeyFailure](#enums_account_addkeyfailuremd)*

An instance of [AddKeyFailure](#enums_account_addkeyfailuremd) representing the result.

___

####  getMainPurse

▸ **getMainPurse**(): *[URef](#classes_uref_urefmd)*

*Defined in [account.ts:175](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L175)*

Gets the [URef](#classes_uref_urefmd) representing the main purse of the account.

**Returns:** *[URef](#classes_uref_urefmd)*

The [URef](#classes_uref_urefmd) that can be used to access the main purse.

___

####  removeAssociatedKey

▸ **removeAssociatedKey**(`publicKey`: [PublicKey](#classes_key_publickeymd)): *[RemoveKeyFailure](#enums_account_removekeyfailuremd)*

*Defined in [account.ts:164](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L164)*

Removes the associated key from the account. See [addAssociatedKey](#addassociatedkey) for more info about associated
keys.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`publicKey` | [PublicKey](#classes_key_publickeymd) | The associated key to be removed. |

**Returns:** *[RemoveKeyFailure](#enums_account_removekeyfailuremd)*

An instance of [RemoveKeyFailure](#enums_account_removekeyfailuremd) representing the result.

___

####  setActionThreshold

▸ **setActionThreshold**(`actionType`: [ActionType](#enums_account_actiontypemd), `thresholdValue`: u8): *[SetThresholdFailure](#enums_account_setthresholdfailuremd)*

*Defined in [account.ts:138](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L138)*

Sets a threshold for the action performed in the context of the account.

Each request has to be signed by one or more of the keys associated with the account. The action
is only successful if the total weights of the signing associated keys is greater than the threshold.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`actionType` | [ActionType](#enums_account_actiontypemd) | The type of the action for which the threshold is being set. |
`thresholdValue` | u8 | The minimum total weight of the keys of the action to be successful. |

**Returns:** *[SetThresholdFailure](#enums_account_setthresholdfailuremd)*

An instance of [SetThresholdFailure](#enums_account_setthresholdfailuremd) representing the result.

___

####  updateAssociatedKey

▸ **updateAssociatedKey**(`publicKey`: [PublicKey](#classes_key_publickeymd), `weight`: i32): *[UpdateKeyFailure](#enums_account_updatekeyfailuremd)*

*Defined in [account.ts:151](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/account.ts#L151)*

Changes the weight of an existing associated key. See [addAssociatedKey](#addassociatedkey) and [setActionThreshold](#setactionthreshold)
for info about associated keys and their weights.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`publicKey` | [PublicKey](#classes_key_publickeymd) | The associated key to be updated. |
`weight` | i32 | The new desired weight of the associated key. |

**Returns:** *[UpdateKeyFailure](#enums_account_updatekeyfailuremd)*

An instance of [UpdateKeyFailure](#enums_account_updatekeyfailuremd) representing the result.


<a name="modules_bignum_md"></a>


## Module: "bignum"

### Index

#### Classes

* [U512](#classes_bignum_u512md)


<a name="modules_bytesrepr_md"></a>


## Module: "bytesrepr"

### Index

#### Enumerations

* [Error](#enums_bytesrepr_errormd)

#### Classes

* [Ref](#classes_bytesrepr_refmd)
* [Result](#classes_bytesrepr_resultmd)

#### Functions

* [fromBytesArray](#frombytesarray)
* [fromBytesArrayU8](#frombytesarrayu8)
* [fromBytesI32](#frombytesi32)
* [fromBytesLoad](#frombytesload)
* [fromBytesMap](#frombytesmap)
* [fromBytesString](#frombytesstring)
* [fromBytesStringList](#frombytesstringlist)
* [fromBytesU32](#frombytesu32)
* [fromBytesU64](#frombytesu64)
* [fromBytesU8](#frombytesu8)
* [toBytesArrayU8](#tobytesarrayu8)
* [toBytesI32](#tobytesi32)
* [toBytesMap](#tobytesmap)
* [toBytesPair](#tobytespair)
* [toBytesString](#tobytesstring)
* [toBytesStringList](#tobytesstringlist)
* [toBytesU32](#tobytesu32)
* [toBytesU64](#tobytesu64)
* [toBytesU8](#tobytesu8)
* [toBytesVecT](#tobytesvect)

### Functions

####  fromBytesArray

▸ **fromBytesArray**<**T**>(`bytes`: Uint8Array, `decodeItem`: function): *[Result](#classes_bytesrepr_resultmd)‹Array‹T››*

*Defined in [bytesrepr.ts:360](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L360)*

Deserializes an array of bytes into an array of type `T`.

**Type parameters:**

▪ **T**

**Parameters:**

▪ **bytes**: *Uint8Array*

The array of bytes to be deserialized.

▪ **decodeItem**: *function*

A function deserializing a value of type `T`.

▸ (`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹T›*

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹Array‹T››*

___

####  fromBytesArrayU8

▸ **fromBytesArrayU8**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹Array‹u8››*

*Defined in [bytesrepr.ts:325](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L325)*

Deserializes an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹Array‹u8››*

___

####  fromBytesI32

▸ **fromBytesI32**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹i32›*

*Defined in [bytesrepr.ts:174](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L174)*

Deserializes an `i32` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹i32›*

___

####  fromBytesLoad

▸ **fromBytesLoad**<**T**>(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹T›*

*Defined in [bytesrepr.ts:122](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L122)*

Deserializes a [[T]] from an array of bytes.

**Type parameters:**

▪ **T**

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹T›*

A [Result](#classes_bytesrepr_resultmd) that contains the value of type `T`, or an error if deserialization failed.

___

####  fromBytesMap

▸ **fromBytesMap**<**K**, **V**>(`bytes`: Uint8Array, `decodeKey`: function, `decodeValue`: function): *[Result](#classes_bytesrepr_resultmd)‹Array‹[Pair](#classes_pair_pairmd)‹K, V›››*

*Defined in [bytesrepr.ts:230](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L230)*

Deserializes an array of bytes into a map.

**Type parameters:**

▪ **K**

▪ **V**

**Parameters:**

▪ **bytes**: *Uint8Array*

The array of bytes to be deserialized.

▪ **decodeKey**: *function*

A function deserializing the key type.

▸ (`bytes1`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹K›*

**Parameters:**

Name | Type |
------ | ------ |
`bytes1` | Uint8Array |

▪ **decodeValue**: *function*

A function deserializing the value type.

▸ (`bytes2`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹V›*

**Parameters:**

Name | Type |
------ | ------ |
`bytes2` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹Array‹[Pair](#classes_pair_pairmd)‹K, V›››*

An array of key-value pairs or an error in case of failure.

___

####  fromBytesString

▸ **fromBytesString**(`s`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹String›*

*Defined in [bytesrepr.ts:294](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L294)*

Deserializes a string from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`s` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹String›*

___

####  fromBytesStringList

▸ **fromBytesStringList**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹Array‹String››*

*Defined in [bytesrepr.ts:389](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L389)*

Deserializes a list of strings from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹Array‹String››*

___

####  fromBytesU32

▸ **fromBytesU32**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹u32›*

*Defined in [bytesrepr.ts:154](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L154)*

Deserializes a `u32` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹u32›*

___

####  fromBytesU64

▸ **fromBytesU64**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹u64›*

*Defined in [bytesrepr.ts:194](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L194)*

Deserializes a `u64` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹u64›*

___

####  fromBytesU8

▸ **fromBytesU8**(`bytes`: Uint8Array): *[Result](#classes_bytesrepr_resultmd)‹u8›*

*Defined in [bytesrepr.ts:134](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L134)*

Deserializes a `u8` from an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`bytes` | Uint8Array |

**Returns:** *[Result](#classes_bytesrepr_resultmd)‹u8›*

___

####  toBytesArrayU8

▸ **toBytesArrayU8**(`arr`: Array‹u8›): *u8[]*

*Defined in [bytesrepr.ts:317](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L317)*

Serializes an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`arr` | Array‹u8› |

**Returns:** *u8[]*

___

####  toBytesI32

▸ **toBytesI32**(`num`: i32): *u8[]*

*Defined in [bytesrepr.ts:161](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L161)*

Converts `i32` to little endian.

**Parameters:**

Name | Type |
------ | ------ |
`num` | i32 |

**Returns:** *u8[]*

___

####  toBytesMap

▸ **toBytesMap**(`pairs`: u8[][]): *u8[]*

*Defined in [bytesrepr.ts:210](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L210)*

Serializes a map into an array of bytes.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`pairs` | u8[][] | Array of serialized key-value pairs.  |

**Returns:** *u8[]*

___

####  toBytesPair

▸ **toBytesPair**(`key`: u8[], `value`: u8[]): *u8[]*

*Defined in [bytesrepr.ts:201](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L201)*

Joins a pair of byte arrays into a single array.

**Parameters:**

Name | Type |
------ | ------ |
`key` | u8[] |
`value` | u8[] |

**Returns:** *u8[]*

___

####  toBytesString

▸ **toBytesString**(`s`: String): *u8[]*

*Defined in [bytesrepr.ts:281](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L281)*

Serializes a string into an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`s` | String |

**Returns:** *u8[]*

___

####  toBytesStringList

▸ **toBytesStringList**(`arr`: String[]): *u8[]*

*Defined in [bytesrepr.ts:396](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L396)*

Serializes a list of strings into an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`arr` | String[] |

**Returns:** *u8[]*

___

####  toBytesU32

▸ **toBytesU32**(`num`: u32): *u8[]*

*Defined in [bytesrepr.ts:141](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L141)*

Converts `u32` to little endian.

**Parameters:**

Name | Type |
------ | ------ |
`num` | u32 |

**Returns:** *u8[]*

___

####  toBytesU64

▸ **toBytesU64**(`num`: u64): *u8[]*

*Defined in [bytesrepr.ts:181](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L181)*

Converts `u64` to little endian.

**Parameters:**

Name | Type |
------ | ------ |
`num` | u64 |

**Returns:** *u8[]*

___

####  toBytesU8

▸ **toBytesU8**(`num`: u8): *u8[]*

*Defined in [bytesrepr.ts:113](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L113)*

Serializes an `u8` as an array of bytes.

**Parameters:**

Name | Type |
------ | ------ |
`num` | u8 |

**Returns:** *u8[]*

An array containing a single byte: `num`.

___

####  toBytesVecT

▸ **toBytesVecT**<**T**>(`ts`: T[]): *Array‹u8›*

*Defined in [bytesrepr.ts:346](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/bytesrepr.ts#L346)*

Serializes a vector of values of type `T` into an array of bytes.

**Type parameters:**

▪ **T**

**Parameters:**

Name | Type |
------ | ------ |
`ts` | T[] |

**Returns:** *Array‹u8›*


<a name="modules_clvalue_md"></a>


## Module: "clvalue"

### Index

#### Enumerations

* [CLTypeTag](#enums_clvalue_cltypetagmd)

#### Classes

* [CLValue](#classes_clvalue_clvaluemd)


<a name="modules_constants_md"></a>


## Module: "constants"

### Index

#### Variables

* [ACCESS_RIGHTS_SERIALIZED_LENGTH](#const-access_rights_serialized_length)
* [KEY_ID_SERIALIZED_LENGTH](#const-key_id_serialized_length)
* [KEY_UREF_SERIALIZED_LENGTH](#const-key_uref_serialized_length)
* [UREF_ADDR_LENGTH](#const-uref_addr_length)
* [UREF_SERIALIZED_LENGTH](#const-uref_serialized_length)

### Variables

#### `Const` ACCESS_RIGHTS_SERIALIZED_LENGTH

• **ACCESS_RIGHTS_SERIALIZED_LENGTH**: *1* = 1

*Defined in [constants.ts:10](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/constants.ts#L10)*

Serialized length of [AccessRights](#enums_uref_accessrightsmd) field.

**`internal`** 

___

#### `Const` KEY_ID_SERIALIZED_LENGTH

• **KEY_ID_SERIALIZED_LENGTH**: *usize* = 1

*Defined in [constants.ts:22](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/constants.ts#L22)*

Serialized length of ID of key.

**`internal`** 

___

#### `Const` KEY_UREF_SERIALIZED_LENGTH

• **KEY_UREF_SERIALIZED_LENGTH**: *any* = KEY_ID_SERIALIZED_LENGTH + UREF_SERIALIZED_LENGTH

*Defined in [constants.ts:27](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/constants.ts#L27)*

Serialized length of [Key](#key) object.

___

#### `Const` UREF_ADDR_LENGTH

• **UREF_ADDR_LENGTH**: *32* = 32

*Defined in [constants.ts:5](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/constants.ts#L5)*

Length of [URef](#classes_uref_urefmd) address field.

**`internal`** 

___

#### `Const` UREF_SERIALIZED_LENGTH

• **UREF_SERIALIZED_LENGTH**: *number* = UREF_ADDR_LENGTH + ACCESS_RIGHTS_SERIALIZED_LENGTH

*Defined in [constants.ts:16](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/constants.ts#L16)*

Serialized length of [URef](#classes_uref_urefmd) object.

**`internal`**


<a name="modules_error_md"></a>


## Module: "error"

### Index

#### Enumerations

* [ErrorCode](#enums_error_errorcodemd)

#### Classes

* [Error](#classes_error_errormd)


<a name="modules_externals_md"></a>


## Module: "externals"




<a name="modules_index_md"></a>


## Module: "index"

### Index

#### Enumerations

* [Phase](#enums_index_phasemd)
* [SystemContract](#enums_index_systemcontractmd)

#### Other Functions

* [callContract](#callcontract)
* [getArg](#getarg)
* [getArgSize](#getargsize)
* [getBlockTime](#getblocktime)
* [getCaller](#getcaller)
* [getKey](#getkey)
* [getPhase](#getphase)
* [getSystemContract](#getsystemcontract)
* [hasKey](#haskey)
* [listNamedKeys](#listnamedkeys)
* [readHostBuffer](#readhostbuffer)
* [removeKey](#removekey)
* [ret](#ret)
* [storeFunction](#storefunction)
* [storeFunctionAtHash](#storefunctionathash)
* [upgradeContractAtURef](#upgradecontractaturef)

#### Runtime Functions

* [putKey](#putkey)

### Other Functions

####  callContract

▸ **callContract**(`key`: [Key](#classes_key_keymd), `args`: [CLValue](#classes_clvalue_clvaluemd)[]): *Uint8Array*

*Defined in [index.ts:186](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L186)*

Calls the given stored contract, passing the given arguments to it.

If the stored contract calls [ret](#ret), then that value is returned from [callContract](#callcontract).  If the
stored contract calls [Error.revert](#revert), then execution stops and [callContract](#callcontract) doesn't return.
Otherwise [callContract](#callcontract) returns null.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`key` | [Key](#classes_key_keymd) | A key under which a contract is stored |
`args` | [CLValue](#classes_clvalue_clvaluemd)[] | A list of values |

**Returns:** *Uint8Array*

Bytes of the contract's return value.

___

####  getArg

▸ **getArg**(`i`: u32): *Uint8Array | null*

*Defined in [index.ts:77](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L77)*

Returns the i-th argument passed to the host for the current module
invocation.

Note that this is only relevant to contracts stored on-chain since a
contract deployed directly is not invoked with any arguments.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`i` | u32 | I-th parameter |

**Returns:** *Uint8Array | null*

Array of bytes with ABI serialized argument. A null value if
given parameter is not present.

___

####  getArgSize

▸ **getArgSize**(`i`: u32): *[Ref](#classes_bytesrepr_refmd)‹[U32](#u32)› | null*

*Defined in [index.ts:49](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L49)*

Returns size in bytes of I-th parameter

**`internal`** 

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`i` | u32 | I-th parameter  |

**Returns:** *[Ref](#classes_bytesrepr_refmd)‹[U32](#u32)› | null*

___

####  getBlockTime

▸ **getBlockTime**(): *u64*

*Defined in [index.ts:299](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L299)*

Returns the current block time.

**Returns:** *u64*

___

####  getCaller

▸ **getCaller**(): *[PublicKey](#classes_key_publickeymd)*

*Defined in [index.ts:309](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L309)*

Returns the caller of the current context, i.e. the [PublicKey](#classes_key_publickeymd) of the
account which made the deploy request.

**Returns:** *[PublicKey](#classes_key_publickeymd)*

___

####  getKey

▸ **getKey**(`name`: String): *[Key](#classes_key_keymd) | null*

*Defined in [index.ts:242](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L242)*

Removes the [Key](#key) stored under `name` in the current context's named keys.

The current context is either the caller's account or a stored contract depending on whether the
currently-executing module is a direct call or a sub-call respectively.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`name` | String | Name of the key in current context's named keys |

**Returns:** *[Key](#classes_key_keymd) | null*

An instance of [Key](#key) if it exists, or a `null` otherwise.

___

####  getPhase

▸ **getPhase**(): *[Phase](#enums_index_phasemd)*

*Defined in [index.ts:351](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L351)*

Returns the current [Phase](#enums_index_phasemd).

**Returns:** *[Phase](#enums_index_phasemd)*

___

####  getSystemContract

▸ **getSystemContract**(`system_contract`: [SystemContract](#enums_index_systemcontractmd)): *[URef](#classes_uref_urefmd)*

*Defined in [index.ts:120](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L120)*

Returns an [URef](#classes_uref_urefmd) for a given system contract

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`system_contract` | [SystemContract](#enums_index_systemcontractmd) | System contract variant |

**Returns:** *[URef](#classes_uref_urefmd)*

A valid [URef](#classes_uref_urefmd) that points at system contract, otherwise null.

___

####  hasKey

▸ **hasKey**(`name`: String): *bool*

*Defined in [index.ts:290](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L290)*

Returns `true` if `name` exists in the current context's named keys.

The current context is either the caller's account or a stored contract depending on whether the
currently-executing module is a direct call or a sub-call respectively.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`name` | String | Name of the key  |

**Returns:** *bool*

___

####  listNamedKeys

▸ **listNamedKeys**(): *Array‹[Pair](#classes_pair_pairmd)‹String, [Key](#classes_key_keymd)››*

*Defined in [index.ts:377](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L377)*

Returns the named keys of the current context.

The current context is either the caller's account or a stored contract depending on whether the
currently-executing module is a direct call or a sub-call respectively.

**Returns:** *Array‹[Pair](#classes_pair_pairmd)‹String, [Key](#classes_key_keymd)››*

An array of String and [Key](#key) pairs

___

####  readHostBuffer

▸ **readHostBuffer**(`count`: u32): *Uint8Array*

*Defined in [index.ts:101](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L101)*

Reads a given amount of bytes from a host buffer

**`internal`** 

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`count` | u32 | Number of bytes |

**Returns:** *Uint8Array*

A byte array with bytes received, otherwise a null in case of
errors.

___

####  removeKey

▸ **removeKey**(`name`: String): *void*

*Defined in [index.ts:364](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L364)*

Removes the [Key](#key) stored under `name` in the current context's named keys.

The current context is either the caller's account or a stored contract depending on whether the
currently-executing module is a direct call or a sub-call respectively.

**Parameters:**

Name | Type |
------ | ------ |
`name` | String |

**Returns:** *void*

___

####  ret

▸ **ret**(`value`: [CLValue](#classes_clvalue_clvaluemd)): *void*

*Defined in [index.ts:273](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L273)*

Returns the given [CLValue](#classes_clvalue_clvaluemd) to the host, terminating the currently
running module.

Note this function is only relevant to contracts stored on chain which are
invoked via [callContract](#callcontract) and can thus return a value to their caller.
The return value of a directly deployed contract is never used.

**Parameters:**

Name | Type |
------ | ------ |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *void*

___

####  storeFunction

▸ **storeFunction**(`name`: String, `namedKeysBytes`: u8[]): *[Key](#classes_key_keymd)*

*Defined in [index.ts:140](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L140)*

Stores the serialized bytes of an exported function as a new contract under
a [URef](#classes_uref_urefmd) generated by the host.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`name` | String | Name of the exported function |
`namedKeysBytes` | u8[] | Serialized bytes of named keys. Use [toBytesMap](#tobytesmap) to serialize pairs.  |

**Returns:** *[Key](#classes_key_keymd)*

___

####  storeFunctionAtHash

▸ **storeFunctionAtHash**(`name`: String, `namedKeysBytes`: u8[]): *[Key](#classes_key_keymd)*

*Defined in [index.ts:162](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L162)*

Stores the serialized bytes of an exported function as a new contract at an
immutable address generated by the host.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`name` | String | Name of the exported function |
`namedKeysBytes` | u8[] | Serialized bytes of named keys. Use [toBytesMap](#tobytesmap) to serialize pairs.  |

**Returns:** *[Key](#classes_key_keymd)*

___

####  upgradeContractAtURef

▸ **upgradeContractAtURef**(`name`: String, `uref`: [URef](#classes_uref_urefmd)): *void*

*Defined in [index.ts:413](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L413)*

Takes the name of an exported function to store as a contract under the given
[URef](#classes_uref_urefmd) which should already reference a stored contract.

If successful, this overwrites the value under `uref` with a new contract instance containing
the original contract's named_keys, the current protocol version, and the newly created bytes of
the stored function.

**Parameters:**

Name | Type |
------ | ------ |
`name` | String |
`uref` | [URef](#classes_uref_urefmd) |

**Returns:** *void*

___

### Runtime Functions

####  putKey

▸ **putKey**(`name`: String, `key`: [Key](#classes_key_keymd)): *void*

*Defined in [index.ts:222](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/index.ts#L222)*

Stores the given [Key](#key) under a given name in the current context's named keys.

The current context is either the caller's account or a stored contract
depending on whether the currently-executing module is a direct call or a
sub-call respectively.

**Parameters:**

Name | Type |
------ | ------ |
`name` | String |
`key` | [Key](#classes_key_keymd) |

**Returns:** *void*


<a name="modules_key_md"></a>


## Module: "key"

### Index

#### Enumerations

* [KeyVariant](#enums_key_keyvariantmd)

#### Classes

* [Key](#classes_key_keymd)
* [PublicKey](#classes_key_publickeymd)

#### Variables

* [PUBLIC_KEY_ED25519_ID](#const-public_key_ed25519_id)

### Variables

#### `Const` PUBLIC_KEY_ED25519_ID

• **PUBLIC_KEY_ED25519_ID**: *u8* = 0

*Defined in [key.ts:25](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/key.ts#L25)*

The ID of an ED25519 public key.


<a name="modules_local_md"></a>


## Module: "local"

### Index

#### Storage Functions

* [addLocal](#addlocal)
* [readLocal](#readlocal)
* [writeLocal](#writelocal)

### Storage Functions

####  addLocal

▸ **addLocal**(`local`: Uint8Array, `value`: [CLValue](#classes_clvalue_clvaluemd)): *void*

*Defined in [local.ts:45](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/local.ts#L45)*

Adds `value` to the one currently under `key` in the context-local partition of global state.

**Parameters:**

Name | Type |
------ | ------ |
`local` | Uint8Array |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *void*

___

####  readLocal

▸ **readLocal**(`local`: Uint8Array): *Uint8Array | null*

*Defined in [local.ts:13](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/local.ts#L13)*

Reads the value under `key` in the context-local partition of global state.

**Parameters:**

Name | Type |
------ | ------ |
`local` | Uint8Array |

**Returns:** *Uint8Array | null*

Returns bytes of serialized value, otherwise a null if given local key does not exists.

___

####  writeLocal

▸ **writeLocal**(`local`: Uint8Array, `value`: [CLValue](#classes_clvalue_clvaluemd)): *void*

*Defined in [local.ts:31](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/local.ts#L31)*

Writes `value` under `key` in the context-local partition of global state.

**Parameters:**

Name | Type |
------ | ------ |
`local` | Uint8Array |
`value` | [CLValue](#classes_clvalue_clvaluemd) |

**Returns:** *void*


<a name="modules_option_md"></a>


## Module: "option"

### Index

#### Classes

* [Option](#classes_option_optionmd)


<a name="modules_pair_md"></a>


## Module: "pair"

### Index

#### Classes

* [Pair](#classes_pair_pairmd)


<a name="modules_purse_md"></a>


## Module: "purse"

### Index

#### Enumerations

* [TransferredTo](#enums_purse_transferredtomd)

#### Functions

* [createPurse](#createpurse)
* [getPurseBalance](#getpursebalance)
* [transferFromPurseToAccount](#transferfrompursetoaccount)
* [transferFromPurseToPurse](#transferfrompursetopurse)

### Functions

####  createPurse

▸ **createPurse**(): *[URef](#classes_uref_urefmd)*

*Defined in [purse.ts:30](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L30)*

Creates a new empty purse and returns its [URef](#classes_uref_urefmd), or a null in case a
purse couldn't be created.

**Returns:** *[URef](#classes_uref_urefmd)*

___

####  getPurseBalance

▸ **getPurseBalance**(`purse`: [URef](#classes_uref_urefmd)): *[U512](#classes_bignum_u512md) | null*

*Defined in [purse.ts:55](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L55)*

Returns the balance in motes of the given purse or a null if given purse
is invalid.

**Parameters:**

Name | Type |
------ | ------ |
`purse` | [URef](#classes_uref_urefmd) |

**Returns:** *[U512](#classes_bignum_u512md) | null*

___

####  transferFromPurseToAccount

▸ **transferFromPurseToAccount**(`sourcePurse`: [URef](#classes_uref_urefmd), `targetAccount`: Uint8Array, `amount`: [U512](#classes_bignum_u512md)): *[TransferredTo](#enums_purse_transferredtomd)*

*Defined in [purse.ts:89](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L89)*

Transfers `amount` of motes from `source` purse to `target` account.
If `target` does not exist it will be created.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`sourcePurse` | [URef](#classes_uref_urefmd) | - |
`targetAccount` | Uint8Array | - |
`amount` | [U512](#classes_bignum_u512md) | Amount is denominated in motes |

**Returns:** *[TransferredTo](#enums_purse_transferredtomd)*

This function will return a [TransferredTo.TransferError](#transfererror) in
case of transfer error, in case of any other variant the transfer itself
can be considered successful.

___

####  transferFromPurseToPurse

▸ **transferFromPurseToPurse**(`sourcePurse`: [URef](#classes_uref_urefmd), `targetPurse`: [URef](#classes_uref_urefmd), `amount`: [U512](#classes_bignum_u512md)): *i32*

*Defined in [purse.ts:120](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/purse.ts#L120)*

Transfers `amount` of motes from `source` purse to `target` purse.  If `target` does not exist
the transfer fails.

**Parameters:**

Name | Type |
------ | ------ |
`sourcePurse` | [URef](#classes_uref_urefmd) |
`targetPurse` | [URef](#classes_uref_urefmd) |
`amount` | [U512](#classes_bignum_u512md) |

**Returns:** *i32*

This function returns non-zero value on error.


<a name="modules_unit_md"></a>


## Module: "unit"

### Index

#### Classes

* [Unit](#classes_unit_unitmd)


<a name="modules_uref_md"></a>


## Module: "uref"

### Index

#### Enumerations

* [AccessRights](#enums_uref_accessrightsmd)

#### Classes

* [URef](#classes_uref_urefmd)


<a name="modules_utils_md"></a>


## Module: "utils"

### Index

#### Functions

* [arrayToTyped](#arraytotyped)
* [checkArraysEqual](#checkarraysequal)
* [checkItemsEqual](#checkitemsequal)
* [checkTypedArrayEqual](#checktypedarrayequal)
* [typedToArray](#typedtoarray)

### Functions

####  arrayToTyped

▸ **arrayToTyped**(`arr`: Array‹u8›): *Uint8Array*

*Defined in [utils.ts:11](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/utils.ts#L11)*

Converts array to typed array

**Parameters:**

Name | Type |
------ | ------ |
`arr` | Array‹u8› |

**Returns:** *Uint8Array*

___

####  checkArraysEqual

▸ **checkArraysEqual**<**T**>(`a`: Array‹T›, `b`: Array‹T›, `len`: i32): *bool*

*Defined in [utils.ts:32](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/utils.ts#L32)*

Checks if two ordered arrays are equal

**Type parameters:**

▪ **T**

**Parameters:**

Name | Type | Default |
------ | ------ | ------ |
`a` | Array‹T› | - |
`b` | Array‹T› | - |
`len` | i32 | 0 |

**Returns:** *bool*

___

####  checkItemsEqual

▸ **checkItemsEqual**<**T**>(`a`: Array‹T›, `b`: Array‹T›): *bool*

*Defined in [utils.ts:20](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/utils.ts#L20)*

Checks if items in two unordered arrays are equal

**Type parameters:**

▪ **T**

**Parameters:**

Name | Type |
------ | ------ |
`a` | Array‹T› |
`b` | Array‹T› |

**Returns:** *bool*

___

####  checkTypedArrayEqual

▸ **checkTypedArrayEqual**(`a`: Uint8Array, `b`: Uint8Array, `len`: i32): *bool*

*Defined in [utils.ts:49](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/utils.ts#L49)*

Checks if two ordered arrays are equal

**Parameters:**

Name | Type | Default |
------ | ------ | ------ |
`a` | Uint8Array | - |
`b` | Uint8Array | - |
`len` | i32 | 0 |

**Returns:** *bool*

___

####  typedToArray

▸ **typedToArray**(`arr`: Uint8Array): *Array‹u8›*

*Defined in [utils.ts:2](https://github.com/CasperLabs/CasperLabs/blob/b349c5266/execution-engine/contract-as/assembly/utils.ts#L2)*

Converts typed array to array

**Parameters:**

Name | Type |
------ | ------ |
`arr` | Uint8Array |

**Returns:** *Array‹u8›*

---
_Source: https://npm.io/package/casperlabs-contract-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
