# soltypes

> Typescript wrapped Solidity types w/ @ethersproject/bignumber

Latest version **2.0.0** (published 2022-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install soltypes
pnpm add soltypes
yarn add soltypes
bun add soltypes
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-03-14 |
| First published | 2020-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Wanseob Lim |
| Maintainers | wanseob |
| Keywords | solidity, uint256, bytes32 |

## Links

- npm: https://www.npmjs.com/package/soltypes
- Homepage: https://github.com/wanseob/soltypes
- npm.io page: https://npm.io/package/soltypes

## Dependencies (2)

- [js-sha3](https://npm.io/package/js-sha3.md) ^0.8.0
- [@ethersproject/bignumber](https://npm.io/package/@ethersproject/bignumber.md) ^5.6.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2022-03-14
- 1.3.5 — 2021-02-09
- 1.3.4 — 2021-01-26
- 1.3.3 — 2020-09-06
- 1.3.2 — 2020-09-06
- 1.3.1 — 2020-09-06
- 1.3.0 — 2020-09-06
- 1.2.2 — 2020-07-16
- 1.2.1 — 2020-07-16
- 1.2.0 — 2020-06-13
- 1.1.2 — 2020-06-03
- 1.1.1 — 2020-06-03
- 1.1.0 — 2020-06-03
- 1.0.3 — 2020-06-03
- 1.0.2 — 2020-06-03
- … 2 more at https://npm.io/package/soltypes/versions

## README

# Solidity Types in Typescript

This library types Ethereum strings strictly using Solidity types. With this library, you can explicitly prevent to convert uint256 types to address or bytes20.

```shell
yarn add soltypes
```

## Examples

```typescript
import { Bytes32, Uint256, Uint32, Address } from 'soltypes'

> new Bytes32('0x1111111111111111111111111111111111111111111111111111111111111111')
// OK

> Bytes32.from('0x1111111111111111111111111111111111111111111111111111111111111111')
// OK

> Bytes32.from('1111111111111111111111111111111111111111111111111111111111111111')
// ERROR - does not start with 0x

> Bytes32.from('0x111111111111111')
// ERROR - bytes length is not 32

> const hash = new Bytes32('0x1111111111111111111111111111111111111111111111111111111111111111')

> hash.toString()
'0x1111111111111111111111111111111111111111111111111111111111111111'
// returns 0x string

> const n: Uint256 = hash.toUint()
> n.toString()
'7719472615821079694904732333912527190217998977709370935963838933860875309329'
// returns Uint256 instance

> Uint32.from('11111')
// OK

> Uint32.from('0x1111111')
// ERROR - should not start with 0x

> Uint32.from('111111111111111111111111')
// ERROR - overflow

> const uintA = Uint256('1234')

> const b: Bytes32 = uintA.toBytes()
> b.toString()
'0x00000000000000000000000000000000000000000000000000000000000004d2'
// returns 0x string

> Address.from('0x1234343434343434343434343434343434343434')
// OK

> Address.from('0xabcd1234')
// FAILs
```

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