[API Reference](../README.md) > [Utils](../classes/Utils.md)

# Class: Utils

## Hierarchy

**Utils**

## Index

### Accessors

* [NULL_ADDRESS](Utils.md#NULL_ADDRESS)
* [NULL_HASH](Utils.md#NULL_HASH)

### Methods

* [SHA3](Utils.md#SHA3)
* [getDefaultAccount](Utils.md#getDefaultAccount)
* [getDeployedAddress](Utils.md#getDeployedAddress)
* [getEthBalance](Utils.md#getEthBalance)
* [getGenTokenAddress](Utils.md#getGenTokenAddress)
* [getNetworkId](Utils.md#getNetworkId)
* [getNetworkName](Utils.md#getNetworkName)
* [getTokenBalance](Utils.md#getTokenBalance)
* [getUserApprovalForAccounts](Utils.md#getUserApprovalForAccounts)
* [getWeb3](Utils.md#getWeb3)
* [keccak256](Utils.md#keccak256)
* [numberToPermissionsString](Utils.md#numberToPermissionsString)
* [permissionsStringToNumber](Utils.md#permissionsStringToNumber)
* [requireContract](Utils.md#requireContract)
* [setDeployedAddresses](Utils.md#setDeployedAddresses)

---

## Accessors

<a id="NULL_ADDRESS"></a>

### `<Static>` NULL_ADDRESS

getNULL_ADDRESS(): [Address](../#Address)

*Defined in [utils.ts:12](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L12)*

**Returns:** [Address](../#Address)

___
<a id="NULL_HASH"></a>

### `<Static>` NULL_HASH

getNULL_HASH(): [Hash](../#Hash)

*Defined in [utils.ts:13](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L13)*

**Returns:** [Hash](../#Hash)

___

## Methods

<a id="SHA3"></a>

### `<Static>` SHA3

▸ **SHA3**(str: *`string`*): `string`

*Defined in [utils.ts:273](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L273)*

Return the hash of a string the same way solidity would, and to a format that will be properly translated into a bytes32 that solidity expects

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| str | `string` |  a string |

**Returns:** `string`

___
<a id="getDefaultAccount"></a>

### `<Static>` getDefaultAccount

▸ **getDefaultAccount**(): `Promise`<`string`>

*Defined in [utils.ts:187](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L187)*

Returns the address of the default user account.

Has the side-effect of setting web3.eth.defaultAccount.

Throws an exception on failure.

**Returns:** `Promise`<`string`>

___
<a id="getDeployedAddress"></a>

### `<Static>` getDeployedAddress

▸ **getDeployedAddress**(contractName: *`string`*):  [Address](../#Address) &#124; `undefined`

*Defined in [utils.ts:23](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L23)*

**Parameters:**

| Param | Type |
| ------ | ------ |
| contractName | `string` |

**Returns:**  [Address](../#Address) &#124; `undefined`

___
<a id="getEthBalance"></a>

### `<Static>` getEthBalance

▸ **getEthBalance**(agentAddress: *[Address](../#Address)*): `Promise`<`BigNumber`>

*Defined in [utils.ts:254](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L254)*

Return the current ETH balance for the given agent.

**Parameters:**

| Param | Type |
| ------ | ------ |
| agentAddress | [Address](../#Address) |

**Returns:** `Promise`<`BigNumber`>

___
<a id="getGenTokenAddress"></a>

### `<Static>` getGenTokenAddress

▸ **getGenTokenAddress**(): `string`

*Defined in [utils.ts:327](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L327)*

Returns address of the global GEN token.

**Returns:** `string`

___
<a id="getNetworkId"></a>

### `<Static>` getNetworkId

▸ **getNetworkId**(): `Promise`<`number`>

*Defined in [utils.ts:365](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L365)*

Returns promise of the id of the current network

**Returns:** `Promise`<`number`>

___
<a id="getNetworkName"></a>

### `<Static>` getNetworkName

▸ **getNetworkName**(id?: *`number`*): `Promise`<`string`>

*Defined in [utils.ts:335](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L335)*

Returns promise of the name of the current or given network

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| `Optional` id | `number` |  Optional id of the network |

**Returns:** `Promise`<`string`>

___
<a id="getTokenBalance"></a>

### `<Static>` getTokenBalance

▸ **getTokenBalance**(agentAddress: *[Address](../#Address)*, tokenAddress: *[Address](../#Address)*): `Promise`<`BigNumber`>

*Defined in [utils.ts:235](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L235)*

Return the current token balance for the given token and agent.

**Parameters:**

| Param | Type |
| ------ | ------ |
| agentAddress | [Address](../#Address) |
| tokenAddress | [Address](../#Address) |

**Returns:** `Promise`<`BigNumber`>

___
<a id="getUserApprovalForAccounts"></a>

### `<Static>` getUserApprovalForAccounts

▸ **getUserApprovalForAccounts**(): `Promise`<`boolean`>

*Defined in [utils.ts:213](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L213)*

Ask MetaMask to prompt the user for permission to access their wallet. MetaMask will insert the user's accounts into the existing Web3 object. If you are watching for account changes then you will receive a notification (see [AccountService.initiateAccountWatch](/arc.js/api/classes/AccountService#initiateAccountWatch)).

Note that this won't work if you have passed `false` for `InitializeArcOptions.useMetamaskEthereumWeb3Provider` when you called `InitializeArcJs`.

**Returns:** `Promise`<`boolean`>
true or false depending on whether the user approves of account sharing.

___
<a id="getWeb3"></a>

### `<Static>` getWeb3

▸ **getWeb3**(refetch?: *`boolean`*): `Promise`<`Web3`>

*Defined in [utils.ts:81](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L81)*

Returns the web3 object. When called for the first time, web3 is initialized from the Arc.js configuration. Throws an exception when web3 cannot be initialized.

**Parameters:**

| Param | Type | Default value |
| ------ | ------ | ------ |
| `Default value` refetch | `boolean` | false |

**Returns:** `Promise`<`Web3`>

___
<a id="keccak256"></a>

### `<Static>` keccak256

▸ **keccak256**(types: *`Array`<`string`>*, values: *`Array`<`any`>*): `string`

*Defined in [utils.ts:299](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L299)*

Return the tightly-packed hash of any arbitrary array of objects just as Solidity's `keccak256` function would do.

Items in the `types` array must appear in the same order in which the values would be passed to Solidity's `keccak256` function.

Type names can be:

*   `bytes[N]` - fails if (N < 1 || N > 32)
*   `string`
*   `bool`
*   `address`
*   `uint[N]` - fails if ((N % 8) || (N < 8) || (N > 256))
*   `int[N]` - fails if ((N % 8) || (N < 8) || (N > 256))

Use `bytes32` for a Hash value

See: [https://github.com/ethereumjs/ethereumjs-abi](https://github.com/ethereumjs/ethereumjs-abi)

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| types | `Array`<`string`> |  array of type names. |
| values | `Array`<`any`> |  the values to pack and hash. These must appear in the same order in which the types are ordered. |

**Returns:** `string`

___
<a id="numberToPermissionsString"></a>

### `<Static>` numberToPermissionsString

▸ **numberToPermissionsString**(permissions: *[SchemePermissions](../enums/SchemePermissions.md)*): `string`

*Defined in [utils.ts:316](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L316)*

Convert SchemePermissions | DefaultSchemePermissions to a scheme permissions string

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| permissions | [SchemePermissions](../enums/SchemePermissions.md) |   |

**Returns:** `string`

___
<a id="permissionsStringToNumber"></a>

### `<Static>` permissionsStringToNumber

▸ **permissionsStringToNumber**(permissions: *`string`*): [SchemePermissions](../enums/SchemePermissions.md)

*Defined in [utils.ts:307](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L307)*

Convert scheme permissions string to a number

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| permissions | `string` |   |

**Returns:** [SchemePermissions](../enums/SchemePermissions.md)

___
<a id="requireContract"></a>

### `<Static>` requireContract

▸ **requireContract**(contractName: *`string`*): `Promise`<`any`>

*Defined in [utils.ts:34](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L34)*

Returns Truffle contract wrapper given the name of the contract (like "SchemeRegistrar"). Optimized for synchronicity issues encountered with MetaMask. Throws an exception if it can't load the contract. Uses the asynchronous web.eth.getAccounts to obtain the default account (good with MetaMask).

**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| contractName | `string` |  like "SchemeRegistrar" |

**Returns:** `Promise`<`any`>

___
<a id="setDeployedAddresses"></a>

### `<Static>` setDeployedAddresses

▸ **setDeployedAddresses**(addresses: *`any`*): `void`

*Defined in [utils.ts:15](https://github.com/daostack/arc.js/blob/6f704389/lib/utils.ts#L15)*

**Parameters:**

| Param | Type |
| ------ | ------ |
| addresses | `any` |

**Returns:** `void`

___

