# decentraland-transactions

Latest version **3.3.0** (published 2026-09-14) · 3.0K weekly downloads

## Install

```sh
npm install decentraland-transactions
pnpm add decentraland-transactions
yarn add decentraland-transactions
bun add decentraland-transactions
```

## Health

**Score 90/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; growing popularity.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2026-09-14 |
| First published | 2021-02-22 |
| Weekly downloads | 3.0K |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Maintainers | decentralandbot |

## Links

- npm: https://www.npmjs.com/package/decentraland-transactions
- Repository: https://github.com/decentraland/decentraland-transactions
- Homepage: https://github.com/decentraland/decentraland-transactions#readme
- Issues: https://github.com/decentraland/decentraland-transactions/issues
- npm.io page: https://npm.io/package/decentraland-transactions

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.6.2

## Recent versions

- 3.3.0 (latest) — 2026-09-14
- 3.2.1-20260914193306.commit-0556256 (next) — 2026-09-14
- 1.29.2-20220210143834.commit-062f194 (tag-1.30) — 2022-02-10
- 3.2.0 — 2026-09-11
- 3.1.2-20260911164741.commit-e7d29ae — 2026-09-11
- 3.1.1 — 2026-08-20
- 3.1.1-20260820184130.commit-0117359 — 2026-08-20
- 3.1.0 — 2026-08-20
- 3.0.4-20260820142610.commit-70778fe — 2026-08-20
- 3.0.4-20260820141746.commit-7865e6a — 2026-08-20
- 3.0.4-20260518165324.commit-5e4d356 — 2026-05-18
- 3.0.3 — 2026-05-12
- 3.0.3-20260512084051.commit-e16049b — 2026-05-12
- 3.0.2 — 2026-02-23
- 3.0.2-20260223135644.commit-9c316b2 — 2026-02-23
- … 228 more at https://npm.io/package/decentraland-transactions/versions

## README

<img src="https://ui.decentraland.org/decentraland_256x256.png" height="128" width="128" />

# Decentraland Transactions

[![NPM version](https://badge.fury.io/js/decentraland-transactions.svg)](https://npmjs.org/package/decentraland-transactions@latest)
[![Install Size](https://packagephobia.now.sh/badge?p=decentraland-transactions@latest)](https://packagephobia.now.sh/result?p=decentraland-transactions@latest)

Send meta transactions

# Table of contents

- [API](#api)
  - [sendMetaTransaction](#sendMetaTransaction)
  - [getContract](#getContract)
  - [getCouponManager](#getCouponManager)
  - [Types](#types)
    - [Configuration](#Configuration)
    - [Provider](#Provider)
    - [ContractName](#ContractName)
    - [ContractData](#ContractData)
    - [DataToSign](#DataToSign)
    - [DomainData](#DomainData)
- [Example](#example)
- [Development](#development)
- [Scripts](#scripts)
  - [convert-abi](#convert-abi)
  - [extract-function-data](#extract-function-data)
  - [extract-tenderly-data](#extract-tenderly-data)
- [Copyright](#copyright)

### API

The API consists of `sendMetaTransaction`, which is all you need to send meta transactions, plus helpers to look up the [pre-loaded contract configurations](#getContract) it takes. You might also choose to import some [types](#types).

## sendMetaTransaction

Sends a meta transaction using a relay server. It's provider agnostic, so it'll take the providers it needs as parameters. The [Provider](#Provider) only has to conform to the required interface found on types. See the [Configuration](#Configuration) type for information on what values you can override.

The `provider` argument refers to which network you are connected to and therefore where the meta transaction will be signed. The `metaTransactionProvider` argument is where the meta transaction will be executed. E.g: If you want to send a meta transaction to a second layer like [Matic](https://polygon.technology/) by staying connected on Ethereum Mainnet, `provider` could be Metamask connected to the Ethereum Mainnet and `metaTransactionProvider` could be a provider instantiated with a Matic Mainnet RPC URL.

**Definition**

```typescript
async function sendMetaTransaction(
  provider: Provider,
  metaTransactionProvider: Provider,
  functionSignature: string,
  contractData: ContractData,
  partialConfiguration: Partial<Configuration> = {}
): Promise<string>
```

**Usage**

Using [ethers](https://github.com/ethers-io/ethers.js) for the providers

```typescript
import {
  sendMetaTransaction,
  getContract,
  ContractName,
  ChainId
} from 'decentraland-transactions'
import { ethers } from 'ethers'

const manaConfig = getContract(ContractName.MANAToken, ChainId.MATIC_MUMBAI)
const manaContract = new ethers.Contract(
  manaConfig.address,
  manaConfig.abi,
  provider
)

const txHash = await sendMetaTransaction(
  new ethers.providers.Web3Provider(window.ethereum),
  new ethers.providers.JsonRpcProvider('https://rpc-mumbai.matic.today'),
  manaContract.pupulateTransaction.transfer(to, value),
  manaConfig
  // ,{ serverURL: 'override.url' }
)
```

## getContract

Returns data for a collection of useful Decentraland [contracts](#ContractName) enum. for the different Ethereum [chains](#ChainId). It contains all the information necessary to call `sendMetaTransaction`.

**Definition**

```typescript
function getContract(contractName: ContractName, chainId: ChainId): ContractData
```

**Usage**

```typescript
getContract(ContractName.MANAToken, ChainId.ROPSTEN)
```

## getCouponManager

Returns the [ContractData](#ContractData) of the coupon manager an off-chain marketplace version trusts. Each marketplace version is wired to its own manager (`couponManager()` on the contract) and a coupon is only redeemable on the marketplace wired to the manager that signed it, so the manager follows the marketplace a trade targets, not the chain. While two versions are live on a chain, both managers are.

**Definition**

```typescript
function getCouponManager(
  marketplace: ContractName,
  chainId: ChainId
): ContractData
```

**Usage**

```typescript
getCouponManager(ContractName.OffChainMarketplaceV3, ChainId.MATIC_MAINNET)

// Or from the contract a trade targets
getCouponManager(getContractName(trade.contract), trade.chainId)
```

Throws for a version without a coupon manager (`OffChainMarketplace`, the first one) and when the version has no manager on that chain, whether because the marketplace is not deployed there or because it was deployed without one: V2 exists on Ethereum but its `couponManager()` is the zero address, so `getCouponManager(OffChainMarketplaceV2, ETHEREUM_MAINNET)` throws. The managers are also addressable directly as `ContractName.CouponManagerV2` and `ContractName.CouponManagerV3`.

`ContractName.CouponManager` is deprecated. It resolves the manager of V2 on Polygon mainnet but the one of V3 on the testnets, so do not pick a manager by chain alone while V2 and V3 overlap.

## Types

### Configuration

```typescript
type Configuration = {
  serverURL: string
}
```

Check [configuration.ts](https://github.com/decentraland/decentraland-transactions/blob/master/src/configuration.ts) to get an up to date snapshot of the current configuration values.

### Provider

Defines the minimun required interface for a Provider. It tries to accomodate for different lib implementations

```typescript
export interface EIPProvider {
  request: (reqArgs: { method: string; params?: any[] }) => Promise<any>
  send?: (method: string, params?: any[]) => Promise<any>
}
export interface LegacyProvider {
  send: (method: string, params: any[]) => Promise<any>
}
export type Provider = EIPProvider | LegacyProvider
```

### ContractName

Supported contract names

```typescript
enum ContractName {
  MANAToken = 'MANAToken'
}
```

### ContractData

Represents all the information necessary to interact with a contract. If the contract is a proxy and doesn't need the address, you can leave it empty.

```typescript
type ContractData = {
  abi: object[]
  address: string
  name: string
  version: string
  chainId: ChainId
}
```

### DataToSign

```typescript
type DataToSign = {
  types: {
    EIP712Domain: DomainType[]
    MetaTransaction: MetaTransactionType[]
  }
  domain: DomainData
  primaryType: 'MetaTransaction'
  message: {
    nonce: number
    from: string
    functionSignature: FunctionSignature
  }
}
```

### DomainData

```typescript
type DomainData = {
  name: string
  version: string
  verifyingContract: string
  salt: string
}
```

# Example

# Example use

Example using [decentraland-connect](https://github.com/decentraland/decentraland-connect) and [ethers](https://github.com/ethers-io/ethers.js) to get the providers

```typescript
import { connection, ProviderType } from 'decentraland-connect'
import {
  sendMetaTransaction,
  getContract,
  ContractName,
  ChainId
} from 'decentraland-transactions'

async function transferMana() {
  try {
    const { provider } = await connection.connect(ProviderType.INJECTED)

    const txHash = await sendMetaTransaction(
      // Connected wallet provider
      provider,
      // L2 matic provider
      new ethers.providers.JsonRpcProvider('https://rpc-mumbai.matic.today'),
      // Function signature
      '0xa9059cbb000000000000000000000000a8d82b0bf686eee78eb5ec882cac98fdd1335ef50000000000000000000000000000000000000000000000000000000000000001',
      // Mana contract for MATIC_MUMBAI
      getContract(ContractName.MANAToken, ChainId.MATIC_MUMBAI)
    )

    console.log('Result tx hash', txHash)
  } catch (error) {
    console.error('An error occurred sending the meta tx', error)
  }
}
```

# Development

To run the project you need to

```bash
npm i
npm run test
npm run build
```

# Scripts

This package includes several utility scripts to help with development and debugging:

## convert-abi

Converts TypeScript ABI files to JSON format for easier use with other tools.

**Usage:**

```bash
npm run convert-abi <input-file> [output-file]
npm run convert-abi --all <input-directory> [output-directory]
```

**Examples:**

```bash
# Convert a single ABI file
npm run convert-abi src/abis/ERC20.ts

# Convert a single ABI file with custom output
npm run convert-abi src/abis/ERC20.ts src/abis/ERC20.json

# Convert all ABI files in a directory
npm run convert-abi --all src/abis/

# Convert all ABI files to a different output directory
npm run convert-abi --all src/abis/ output/abis/
```

## extract-function-data

Extracts and decodes function data from meta-transaction data. This is useful for debugging and understanding what function calls are being made.

**Usage:**

```bash
npm run extract-function-data <transaction_data> [abi_file_path]
```

**Arguments:**

- `transaction_data`: The hex transaction data from `getOffchainExecuteMetaTransactionData`
- `abi_file_path` (optional): Path to a JSON file containing the contract ABI for decoding

**Examples:**

```bash
# Extract function data without decoding
npm run extract-function-data 0xd8ed1acc0000000000000000000000001234567890abcdef...

# Extract and decode function data with ABI
npm run extract-function-data 0xd8ed1acc0000000000000000000000001234567890abcdef... ./contract-abi.json
```

## extract-tenderly-data

Extracts function data from meta-transaction data and formats it for Tenderly transaction simulation.

**Usage:**

```bash
npm run extract-tenderly-data <transaction_data>
```

**Arguments:**

- `transaction_data`: The hex transaction data from `getOffchainExecuteMetaTransactionData`

**Examples:**

```bash
# Extract data for Tenderly simulation
npm run extract-tenderly-data 0xd8ed1acc0000000000000000000000001234567890abcdef...
```

The script outputs JSON data with `data` and `from` fields that can be used in Tenderly's transaction simulation interface.

# Copyright

This repository is protected with a standard Apache 2 license. See the terms and conditions in the [LICENSE](https://github.com/decentraland/decentraland-transactions/blob/master/LICENSE) file.

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