API
Guides
Data decoder

Transaction data decoder

This guide shows how to use the Safe Transaction Service API to decode transaction data for contract interactions.

The different steps are implemented using Curl (opens in a new tab) requests and the Safe{Core} SDK (opens in a new tab) TypeScript library.

Prerequisites

  1. Node.js and npm (opens in a new tab) when using the Safe{Core} SDK.
  2. Have a Safe account.

Steps

Install dependencies


_10
yarn add @safe-global/api-kit

Imports


_10
import SafeApiKit from '@safe-global/api-kit'

Decode transaction data


_11
// Initialize the API Kit
_11
// How to get an Api key => http://docs.safe.global/core-api/how-to-use-api-keys
_11
const apiKit = new SafeApiKit({
_11
chainId: 11155111n,
_11
apiKey: 'YOUR_API_KEY'
_11
})
_11
_11
const data = "0x095ea7b3000000000000000000000000e6fc577e87f7c977c4393300417dcc592d90acf8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
_11
const dataDecoded = await apiKit.decodeData(data)
_11
_11
// This decoded data is also included as dataDecoded in the response of the apiKit's getMultisigTransactions, getModuleTransactions, and getAllTransactions methods.

Was this page helpful?