@depay/verify-payment
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

Installation

yarn add @depay/verify-payment

or

npm install --save @depay/verify-payment

Functionality

Decode payment

import { decodePayment } from '@depay/verify-payment'

const payment = decodePayment({
  blockchain: 'ethereum',
  address: '0xF491525C7655f362716335D526E57b387799d058',
  transaction: '0x422feecb000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000243cd890b58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000001c232f01118cb8b424793ae03f870aa7d0ac7f770000000000000000000000004ecaba5870353805a9f068101a40e0f32ed605c600000000000000000000000008b277154218ccf3380cae48d630da13462e395000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000002e00000000000000000000000000000000000000000000000000000000064f2fb0400000000000000000000000000000000000000000000000000000000000000e47ff36ab5000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000800000000000000000000000005ec3153bacebb5e49136cf2d457f26f5df1b67800000000000000000000000000000000000000000000000000000000064f2fb030000000000000000000000000000000000000000000000000000000000000002000000000000000000000000e91d153e0b41518a2ce8dd3d7944fa863463a97d0000000000000000000000004ecaba5870353805a9f068101a40e0f32ed605c60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000'
});

// payment = {
//   amount: BigInt('10200000000000000'),
//   token: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
//   receiver: '0x08b277154218ccf3380cae48d630da13462e3950'
// }

The decodePayment function will return a payment with the following attributes:

amount: Amount paid as BigInt

token: Address of the token used to perform the payment

receiver: Address of the payment receiver

Blockchain

You can pass blockchains in 3 different formats:

names: e.g. ethereum, bsc, polygon etc. check web3-blockchains for a list of names.

id: e.g. 1 (ethereum), 137 (polygon), 10 (optimism) etc.

hexId (lowercase): e.g. 0x1 (ethereum), 0x89 (polygon), 0xa (optimism) etc.

Address

Please make sure you pass addresses correctly checksum-formatted as it will be verified case-sensitive.

If the given address does not match the given blockchain, undefined is returned.

Transaction

The transaction needs

If the given transaction can't be decoded, undefined is returned.

Development

Get started

yarn install
yarn test

Package Sidebar

Install

npm i @depay/verify-payment

Homepage

depay.com

Weekly Downloads

31

Version

1.3.1

License

MIT

Unpacked Size

16.9 kB

Total Files

11

Last publish

Collaborators

  • 0xneo11
  • depay-sebastian