[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)
* [getValueFromLogs](Utils.md#getValueFromLogs)
* [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/77005d4/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/77005d4/lib/utils.ts#L18)*





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



___


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

### «Static» SHA3

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



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



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:185](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L185)*



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

### «Static» getValueFromLogs

► **getValueFromLogs**(tx: *[TransactionReceiptTruffle](../interfaces/TransactionReceiptTruffle.md)*, arg: *`string`*, eventName?: *`string`*, index?: *`number`*): `any`⎮`undefined`



*Defined in [utils.ts:121](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L121)*



Returns a value from the given transaction log. Undefined if not found for any reason.


**Parameters:**

| Param | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| tx | [TransactionReceiptTruffle](../interfaces/TransactionReceiptTruffle.md)  | - |   The transaction |
| arg | `string`  | - |   The name of the property whose value we wish to return from the args object: tx.logs[index].args[argName] |
| eventName | `string`  |  null |   Overrides index, identifies which log, where tx.logs[n].event === eventName |
| index | `number`  | 0 |   Identifies which log when eventName is not given |





**Returns:** `any`⎮`undefined`





___

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

### «Static» getWeb3

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



*Defined in [utils.ts:51](https://github.com/daostack/arc.js/blob/77005d4/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:230](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L230)*



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)⎮[DefaultSchemePermissions](../enums/DefaultSchemePermissions.md)*): `string`



*Defined in [utils.ts:247](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L247)*



Convert number to a scheme permissions string


**Parameters:**

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





**Returns:** `string`





___

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

### «Static» permissionsStringToNumber

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



*Defined in [utils.ts:238](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L238)*



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:27](https://github.com/daostack/arc.js/blob/77005d4/lib/utils.ts#L27)*



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





___


