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



# Class: Utils

## Index

### Accessors

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


### Methods

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



---
## Accessors
<a id="NULL_ADDRESS"></a>

### «Static» NULL_ADDRESS


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

*Defined in [utils.ts:17](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L17)*





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



___

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

### «Static» NULL_HASH


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

*Defined in [utils.ts:18](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L18)*





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



___


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

### «Static» SHA3

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



*Defined in [utils.ts:178](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L178)*



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:123](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L123)*



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="getEthBalance"></a>

### «Static» getEthBalance

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



*Defined in [utils.ts:159](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L159)*



Return the current ETH balance for the given agent.


**Parameters:**

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





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





___

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

### «Static» getGenTokenAddress

► **getGenTokenAddress**(): `Promise`.<`string`>



*Defined in [utils.ts:271](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L271)*



Returns promise of the address of the global GEN token.




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





___

<a id="getGenTokenBalance"></a>

### «Static» getGenTokenBalance

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



*Defined in [utils.ts:283](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L283)*



Returns a promise of the given account's GEN token balance.


**Parameters:**

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





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





___

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

### «Static» getNetworkId

► **getNetworkId**(): `Promise`.<`string`>



*Defined in [utils.ts:261](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L261)*



Returns promise of the id of the current network




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





___

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

### «Static» getNetworkName

► **getNetworkName**(id?: *`string`*): `Promise`.<`string`>



*Defined in [utils.ts:233](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L233)*



Returns promise of the name of the current or given network


**Parameters:**

| Param | Type | Description |
| ------ | ------ | ------ |
| id | `string`   |  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:140](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L140)*



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


**Parameters:**

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





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





___

<a id="getTruffleArtifactForContract"></a>

### «Static» getTruffleArtifactForContract

► **getTruffleArtifactForContract**(contractName: *`string`*): `any`



*Defined in [utils.ts:292](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L292)*



Returns the truffle artifact json for the given contract


**Parameters:**

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





**Returns:** `any`





___

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

### «Static» getWeb3

► **getWeb3**(): `Promise`.<`Web3`>



*Defined in [utils.ts:51](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L51)*



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.




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





___

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

### «Static» keccak256

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



*Defined in [utils.ts:204](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L204)*



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:221](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L221)*



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:212](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L212)*



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:26](https://github.com/daostack/arc.js/blob/f343aa24/lib/utils.ts#L26)*



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`>





___


