Transfer Native Token

Using ethers-io

Transferring native tokens like ETH is quite straightforward. One can use the token transfer methods provided by libraries like ethers.

import { Nectar } from "@wasd3rplay/nectar-sdk";
import { Wallet, ethers } from "ethers";

const provider = new ethers.providers.JsonRpcProvider("https://eth-sepolia-public.unifra.io");
const signer = new Wallet(process.env.NODE_NECTAR_WALLET_SECRET);

const nectar = new Nectar();
// market ETH_ETH:USDT_ETH
const market = (await nectar.getExchangeInfo())[3];

// Send ETH to the dex manager smart contract
const tx = signer.sendTransaction({
    to: market.chain.dex_manager_contract
    value: ethers.utils.parseEther("0.01")  // 0.01 ETH
});

For more detailed information about ethers, please refer to the link: ethers-io.

Using Nectar SDK

import { Nectar } from "@wasd3rplay/nectar-sdk";
import { ethers } from "ethers";

const nectar = new Nectar();
const transferResult = await nectar.transferTokenToTradingWallet({
  ticker: "ETH_ETH",
  requestAmount: "0.01", // 0.01 ETH
});

Properties

  • ticker

    • The ticker of the token to transfer

  • requestAmount

    • The amount to transfer in the base (human-readable) unit

  • symbol (optional)

    • Market symbol can be specified. If not specified, it will use the market information for the market that is first found with the ticker.

  • signer (optional)

    • It's possible to specify a wallet other than the default user wallet provided by the Nectar SDK.

  • market (optional)

    • Directly specifying the market can reduce the load caused by market queries.