Native Coin

JavaScript Native Coin Functions

Get balance

Description

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

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Return type

Promise<{
   [blockchainId: string]: {
      value: string
      coinMetadata: {
          coinName: string
          coinSymbol: string
          coinDecimals: string
        }
   }
}>

Usage Example

const balance = await sdk.coin.getBalance()
// or
const balance = await sdk.coin.getBalance({ blockchainIds: ['ethereum', 'polygon'] })

Response Example

{
  "tezosGhost": {
    "value": "8.092449",
    "coinMetadata": {
      "coinName": "Tezos",
      "coinSymbol": "XTZ",
      "coinDecimals": "6"
    }
  },
  "ethereumSepolia": {
    "value": "0.099638562787420425",
    "coinMetadata": {
      "coinName": "Sepolia Ether",
      "coinSymbol": "ETH",
      "coinDecimals": "18"
    }
  }
}

Get transactions

Description

Returns a list of blockchain native coin transactions for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Return type

Promise<{
  [blockchainId: string] : {
    createdAt: string
    id: string
    fromAddress: string
    toAddress: string
    value: string
    gasUsed: string
    gasPrice: string
    status: string
    direction: string
    type: "buy" | "fund" | "receive" | "sell" | "send"
    coinMetadata?: {
      coinName: string
      coinSymbol: string
      coinDecimals: string
    }
  }[]
}>

Usage Example

const transactions = await sdk.coin.getTransactions()
// or
const transactions = await sdk.coin.getTransactions({ blockchainIds: ['ethereum', 'polygon'] })

Response Example

{
  "ethereum": [
    {
      "fromAddress": "0x7f8e0b31dd7e8c12cf907225e25ed83c649bcc62",
      "toAddress": "0x3a27c671c01be1b8ba8fd0be94e8cfe5f77fc67b",
      "value": "0.1",
      "gasUsed": "21000",
      "gasPrice": "1761138757",
      "direction": "incoming",
      "createdAt": "2023-06-26T18:02:12Z",
      "nonce": "7",
      "id": "0x2354c9859d56c4ba2f0183661c03752f2b6e5d2d2f8198072c6773e5d285d830",
      "coinMetadata": {
        "coinName": "Sepolia Ether",
        "coinSymbol": "ETH",
        "coinDecimals": "18"
      },
      "status": "completed",
      "type": "receive"
    }
  ]
}

Send to user

Description

Sends native currency to another user on the platform by its user ID. The user will get a Sign Transaction widget to approve the transaction.

Parameters

NameTypeRequiredDefaultDescription

blockchainId

String

✔️

Blockchain

value

String

✔️

value of crypto

userId

String

✔️

Id of user to send crypto to

Return type

Promise<string>

Usage Example

await sdk.coin.sendToUser({
  blockchainId: 'ethereum',
  value: '1.2',
  userId: '1',
})

Send to wallet

Description

Sends native currency to another wallet by its wallet address. The user will get a Sign Transaction widget to approve the transaction.

Parameters

NameTypeRequiredDefaultDescription

blockchainId

String

✔️

Blockchain

value

String

✔️

value of crypto

walletAddress

String

✔️

Address of wallet to send crypto to

Return type

Promise<string>

Usage Example

await sdk.coin.sendToWallet({
  blockchainId: 'ethereum',
  value: '1.2',
  walletAddress: '0x15b895d74582daea01be8e5be264243d8c9d7bb1',
})

Last updated