# @daohaus/utils

> A set of helper tools and utilities that are used throughout our libraries and apps. This includes things like our constants, types, and various utilities and helper functions.

Latest version **0.5.5** (published 2025-03-03) · 0 weekly downloads

## Install

```sh
npm install @daohaus/utils
pnpm add @daohaus/utils
yarn add @daohaus/utils
bun add @daohaus/utils
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: has types; no vulnerabilities.

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

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2025-03-03 |
| First published | 2022-11-01 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 96.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Maintainers | daohaus-protocol |

## Links

- npm: https://www.npmjs.com/package/@daohaus/utils
- Repository: https://github.com/HausDAO/monorepo
- Homepage: https://github.com/HausDAO/monorepo#readme
- Issues: https://github.com/HausDAO/monorepo/issues
- npm.io page: https://npm.io/package/@daohaus/utils

## Dependencies (9)

- [viem](https://npm.io/package/viem.md) 1.6.0
- [react](https://npm.io/package/react.md) 18.2.0
- [tslib](https://npm.io/package/tslib.md) 2.6.1
- [wagmi](https://npm.io/package/wagmi.md) 1.3.10
- [numbro](https://npm.io/package/numbro.md) 2.3.6
- [date-fns](https://npm.io/package/date-fns.md) 2.30.0
- [localforage](https://npm.io/package/localforage.md) 1.10.0
- [react-hook-form](https://npm.io/package/react-hook-form.md) 7.45.4
- [@daohaus/keychain-utils](https://npm.io/package/@daohaus/keychain-utils.md) 0.5.5

## Recent versions

- 0.5.5 (latest) — 2025-03-03
- 0.2.0-alpha.6 (alpha) — 2023-08-18
- 0.0.6 (@daohaus/utils@latest) — 2022-11-01
- 0.0.5 (@daohaus/utils) — 2022-11-01
- 0.5.4 — 2024-10-29
- 0.5.3 — 2024-09-06
- 0.5.2 — 2024-06-14
- 0.5.1 — 2024-05-09
- 0.5.0 — 2024-05-03
- 0.4.5 — 2024-05-02
- 0.4.4 — 2024-03-29
- 0.4.3 — 2024-03-21
- 0.4.2 — 2024-01-26
- 0.4.1 — 2024-01-18
- 0.4.0 — 2024-01-17
- … 49 more at https://npm.io/package/@daohaus/utils/versions

## README

# @daohaus/utils

A set of helper tools and utilities that are used throughout our libraries and apps. This includes things like our constants, types, and various utilities and helper functions.

### [View on NPM](https://www.npmjs.com/package/@daohaus/utils)

## Usage

### Installation

```bash
yarn add @daohaus/utils
```

### Examples

**How to create a viem client**

```ts
import { createViemClient } from '@daohaus/utils';

const client = createViemClient({
  chainId: '0x1',
  rpcs: {
    '0x1': 'https://some-rpc-url.com',
  },
});
```

**How to format time and date from a timestamp in dao data**

```ts
import { formatDateTimeFromSeconds } from '@daohaus/utils';

const timeProposalWasCreated = formatDateTimeFromSeconds(proposal.createdAt);

console.log(timeProposalWasCreated);
('4:42 pm June 15th 2023');
```

**How to format an address into a shorter string**

```ts
import { truncateAddress } from '@daohaus/utils';

const shortAddr = truncateAddress('0xf844b98df9ccdfbe5d460d0d7bdca232cf9da923');

console.log(shortAddr);
('0xf844...a923');
```

**How to get the labels for proposal status used in the admin app**

```ts
import { PROPOSAL_STATUS } from '@daohaus/utils';

const needProcessingLabel = PROPOSAL_STATUS.needsProcessing;

console.log(needProcessingLabel);
('Ready for Execution');
```

**How to get some info copy for dao settings**

```ts
import { INFO_COPY } from '@daohaus/utils';

const votingPeriodInfoText = INFO_COPY.VOTING_PERIOD;

console.log(votingPeriodInfoText);
('How long should proposals remain open for voting?');
```

**How to type a token info object return in dao data**

```ts
import { TokenInfo } from '@daohaus/utils'


const someToken: TokenInfo  = {
  decimals: 18,
  symbol: 'HAUS',
  name: 'HAUS'
  logoUri: null,
};

```

## Building

Run `nx utils:build` to build the library.

---
_Source: https://npm.io/package/@daohaus/utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
