Native Coin

Native Coin React & React Native Hooks

Import hooks

In order to use the function below, you need to import the hooks for React or React native.

Import React Hooks

import { hooks } from '@paytweed/frontend-sdk-react'

Get balance

Description

Returns the current balance of blockchain native currency in the user's wallet for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Data type

{ [blockchainId: string]: string }

Usage Example

const { data, error, loading } = await hooks.useCoinBalance()
// or
const { data, error, loading } = await hooks.useCoinBalance({ blockchainIds: ['ethereum', 'polygon'] })

Data Example

{
  "ethereum": "0.12",
  "polygon": "0.34"
}

Get transactions

Description

Returns a list of blockchain native coin transactions for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Data type

{
  [blockchainId: string] : {
    createdAt: string
    value: string
    cryptoCurrencyId: string
    direction: string
    fiatCurrencyAmount?: string
    fiatCurrencyId?: string
    fromAddress: string
    gasLimit?: string
    gasPrice?: string
    id: string
    status: string
    toAddress: string,
    type: "buy" | "fund" | "receive" | "sell" | "send"
  }[]
}

Usage Example

const { data, error, loading } = hooks.useCoinTransactions()
// or
const { data, error, loading } = await hooks.useCoinTransactions({ blockchainIds: ['ethereum', 'polygon'] })

Data Example

{
  "ethereum": [
    {
      "createdAt": "2022-11-15T21:01:47.000Z",
      "value": "0.005",
      "cryptoCurrencyId": "ETH",
      "direction": "incoming",
      "fromAddress": "0xc1af9c48fb30fa29b0d4b1332c63c5e71e636f62",
      "id": "0xe0eebdcb1e585e4680c1d1c1d95afbbff8977140adca291f6ca33bbccf830899",
      "status": "complete",
      "toAddress": "0x15b895d74582daea01be8e5be264243d8c9d7bb1",
      "type": "receive"
    }
  ]
}

Last updated