# @mcintyre94/compat

> Helpers for converting from legacy web3js classes

Latest version **2.0.0-experimental.f9b30bb** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mcintyre94/compat
pnpm add @mcintyre94/compat
yarn add @mcintyre94/compat
bun add @mcintyre94/compat
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0-experimental.f9b30bb |
| Published | 2023-11-29 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 281.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2782 |
| Author | Solana Labs Maintainers |
| Maintainers | mcintyre94 |
| Keywords | blockchain, solana, web3 |

## Links

- npm: https://www.npmjs.com/package/@mcintyre94/compat
- Repository: https://github.com/solana-labs/solana-web3.js
- Homepage: https://github.com/solana-labs/solana-web3.js#readme
- Issues: http://github.com/solana-labs/solana-web3.js/issues
- npm.io page: https://npm.io/package/@mcintyre94/compat

## Dependencies (3)

- [@mcintyre94/functional](https://npm.io/package/@mcintyre94/functional.md) 2.0.0-experimental.f9b30bb
- [@mcintyre94/instructions](https://npm.io/package/@mcintyre94/instructions.md) 2.0.0-experimental.f9b30bb
- [@mcintyre94/transactions](https://npm.io/package/@mcintyre94/transactions.md) 2.0.0-experimental.f9b30bb

## Recent versions

- 2.0.0-experimental.f9b30bb (latest) — 2023-11-29
- 2.0.0-experimental.e807d29 (experimental) — 2023-12-01
- 2.0.0-experimental.a537d8d — 2023-12-01

## README

[![npm][npm-image]][npm-url]
[![npm-downloads][npm-downloads-image]][npm-url]
[![semantic-release][semantic-release-image]][semantic-release-url]
<br />
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]

[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
[code-style-prettier-url]: https://github.com/prettier/prettier
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/compat/experimental.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/@solana/compat/experimental.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@solana/compat/v/experimental
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]: https://github.com/semantic-release/semantic-release

# @solana/compat

This package contains utilities for converting from legacy web3js classes to the new data structures. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).

## Functions

### `fromLegacyPublicKey()`

This can be used to convert a legacy `PublicKey` object to an `Address` type

```ts
import { fromLegacyPublicKey } from '@solana/compat';
const address = fromLegacyPublicKey(new PublicKey('49XBVQsvSW44ULKL9qufS9YqQPbdcps1TQRijx4FQ9sH'));
```

### `fromLegacyKeypair()`

This can be used to convert a legacy `Keypair` object to a native Ed25519 `CryptoKeyPair` object

```ts
import { fromLegaycKeypair } from '@solana/compat';
const { privateKey, publicKey } = await fromLegacyKeypair(Keypair.generate());
```

### `fromVersionedTransactionWithBlockhash()`

This can be used to convert a legacy `VersionedTransaction` object that uses a blockhash lifetime to a `Transaction` object. The returned transaction fulfils both the `ITransactionWithFeePayer` and `ITransactionWithBlockhash` interfaces.

```ts
import { fromVersionedTransactionWithBlockhash } from '@solana/compat';

// imagine a function that returns a legacy `VersionedTransaction`
const legacyVersionedTransaction = getMyLegacyVersionedTransaction();
const transaction = fromVersionedTransactionWithBlockhash(legacyVersionedTransaction);
```

### `fromVersionedTransactionWithDurableNonce()`

This can be used to convert a legacy `VersionedTransaction` object that uses a durable nonce lifetime to a `Transaction` object. The returned transaction fulfils both the `ITransactionWithFeePayer` and `IDurableNonceTransaction` interfaces.

```ts
import { fromVersionedTransactionWithDurableNonce } from '@solana/compat';

// imagine a function that returns a legacy `VersionedTransaction`
const legacyVersionedTransaction = getMyLegacyVersionedTransaction();
const transaction = fromVersionedTransactionWithDurableNonce(legacyVersionedTransaction);
```

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