ETransfer
  • About ETransfer
    • Introduction
    • Business process
      • Deposit process
      • Withdraw process
  • โš’๏ธSDK
    • SDK introduction
    • SDK change log
    • Get Started
      • ๐Ÿ“ฅInstallation
      • ๐Ÿ“ƒConfiguration
      • โŒจ๏ธQuick Start
      • ๐Ÿ”Auth
      • ๐Ÿ’ฐDeposit Digital Assets
      • ๐Ÿ’ฐWithdraw Digital Assets
      • โš’๏ธUI SDK
        • Configuration
        • Deposit Component
        • Withdraw Component
        • History Component
        • Transfer Detail Component
        • ETransfer Content Component
  • Install portkey wallet
  • FAQ
  • Contact us
  • MORE INFORMATION
    • Terms of Service
    • Privacy Policy
Powered by GitBook
On this page
  • Installation
  • Demo
  • How to use
  • Init the ETransferCore instance
  • Features
  1. SDK
  2. Get Started

Quick Start

PreviousConfigurationNextAuth

Last updated 4 months ago

Installation

Demo

How to use

For the configuration items used in the following examples, please refer to:

Init the ETransferCore instance

import { eTransferCore } from '@etransfer/core';
import { IStorageSuite } from '@etransfer/types';

class Store implements IStorageSuite {
  async getItem(key: string) {
    return localStorage.getItem(key);
  }
  async setItem(key: string, value: string) {
    return localStorage.setItem(key, value);
  }
  async removeItem(key: string) {
    return localStorage.removeItem(key);
  }
}

eTransferCore.init({
  etransferUrl: 'etransfer service url',
  etransferAuthUrl: 'etransfer authorization service url' , 
  storage: new Store()
});

Features

Acquire authorization token

import { eTransferCore } from '@etransfer/core';

// get aelf chain authorization token
const result = await eTransferCore.services.getAuthToken(
  {
    chain_id: 'AELF', // AELF or tDVV
    ca_hash: 'user ca hash',
    managerAddress: 'user manager address',
    pubkey: 'user account pubkey',
    plain_text: 'signed text',
    signature: 'user signature',
    version: PortkeyVersion.v2,
  },
  { baseURL: 'etransfer auth url' },
);


// get other chain authorization token
const result = await eTransferCore.services.getOtherChainAuthToken(
  {
    signature: 'user signature',
    plain_text: 'signed text',
    pubkey: 'user account pubkey',
    sourceType: AuthTokenSource.EVM,
    recaptchaToken: 'google recaptcha token',
  },
  { baseURL: 'etransfer auth url' },
);

Check the registration status of an address

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.checkRegistration(
  {
    address: 'your account address',
    sourceType: 'your wallet source type'; // eg: "EVM"
  }
);

Check the registration status of an EOA address

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.checkEOARegistration(
  {
    address: 'your account address',
  }
);

Acquire supported cryptos

import { eTransferCore } from '@etransfer/core';

// Acquire deposit cryptos
const result = await eTransferCore.services.getTokenOption({ type: 'Deposit' });

// Acquire withdraw cryptos
const result = await eTransferCore.services.getTokenList({
  type: 'Withdraw',
  chainId: 'AELF', // or 'tDVV'
});

// Acquire transfer cryptos
const result = await eTransferCore.services.getTokenList({
  type: 'Transfer',
});

Acquire token price

import { eTransferCore } from '@etransfer/core';

// Get the price of a token
const result = await eTransferCore.services.getTokenPrices({ symbols: 'USDT' });

// Get the prices of several tokens
const result = await eTransferCore.services.getTokenPrices({
  symbols: 'USDT,SGR-1,ELF',
});

Acquire supported networks

import { eTransferCore } from '@etransfer/core';

// Acquire deposit or withdrawal network list
const result = await eTransferCore.services.getNetworkList({
  type: 'Deposit', // or 'Withdraw'
  chainId: 'AELF', // or 'tDVV'
  symbol: 'USDT', // Get data from eTransferCore.services[getTokenOption|getTokenList]
});

// Acquire transfer network list
const result = await eTransferCore.services.getNetworkList({
  type: 'Transfer',
});

Acquire deposit information

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getDepositInfo({
  chainId: 'AELF', // or 'tDVV'
  network: 'ETH', // get data from eTransferCore.services.getNetworkList
  symbol: 'USDT', // get data from eTransferCore.services.getTokenOption
  toSymbol: 'USDT', // get data from eTransferCore.services.getTokenOption
});

Calculate crypto exchange rates

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getDepositCalculate({
  fromSymbol: 'USDT', // get data from eTransferCore.services.getTokenOption
  fromAmount: '100', // without decimals
  toSymbol: 'USDT', // get data from eTransferCore.services.getTokenOption
  toChainId: 'AELF', // or 'tDVV'
});

Acquire withdraw information

import { eTransferCore } from '@etransfer/core';
import { PortkeyVersion } from '@etransfer/types';

const result = await eTransferCore.services.getWithdrawInfo({
  chainId: 'AELF', // or 'tDVV'
  network: 'ETH', // get data from eTransferCore.services.getNetworkList
  symbol: 'USDT', // get data from eTransferCore.services.getTokenList
  amount: '100', // withdrawal amount, without decimals
  address: 'withdrawal address', // Please remove the prefix and suffix of the ELF-DID address
  version: PortkeyVersion.v2,
});

Create withdraw order

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.createWithdrawOrder({
  network: 'ETH', // get data from eTransferCore.services.getNetworkList
  symbol: 'USDT', // get data from eTransferCore.services.getTokenList
  amount: '100', // withdrawal amount, without decimals
  fromChainId: 'AELF', // or 'tDVV'
  toAddress: 'withdrawal address', // Please remove the prefix and suffix of the ELF-DID address
  rawTransaction: rawTransaction,
});

Acquire transaction records

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getRecordsList({
  type: 0, // ALL = 0, Deposits = 1, Withdraws = 2
  status: 0, // ALL = 0, Processing = 1, Succeed = 2, Failed = 3
  skipCount: 0,
  maxResultCount: 100,
});

Acquire transaction details

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getRecordDetail('orderId');

If there are any unread messages

import { eTransferCore } from '@etransfer/core';

// If authorization token is set in the request header, and you only want to get the unread order messages of the account corresponding to authorization token.
const result = await eTransferCore.services.getRecordStatus();

// If you want to get the unread message status of multiple addresses.
const result = await eTransferCore.services.getRecordStatus({
  addressList: ['address1', 'address2']
});

Get the matching relationship between token and network for 'Transfer'

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getTokenNetworkRelation({}, 'your authorization token');

Acquire transfer information

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.getTransferInfo({
 symbol: 'USDT', // get data from eTransferCore.services.getTokenNetworkRelation
 fromNetwork: 'ETH', // transfer source Network, get data from eTransferCore.services.getTokenNetworkRelation
 toNetwork: 'tDVV', // transfer target Network, get data from eTransferCore.services.getTokenNetworkRelation
 amount: '10', // transfer amount, without decimals
 fromAddress: 'source address', // Please remove the prefix and suffix of the ELF-DID address
 toAddress: 'transfer target address', // Please remove the prefix and suffix of the ELF-DID address
 memo: 'memo', // comment for Ton
 version: PortkeyVersion.v2,
 sourceType: WalletSourceType.EVM, // WalletSourceType is 'EVM' | 'Solana' | 'TRX' | 'Ton' | 'Portkey'
});

Create transfer order

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.createTransferOrder({
  amount: '10', // transfer amount, without decimals
  fromNetwork: 'ETH', // transfer source Network, get data from eTransferCore.services.getTokenNetworkRelation
  toNetwork: 'tDVV', // transfer target Network, get data from eTransferCore.services.getTokenNetworkRelation
  fromSymbol: 'USDT', // get data from eTransferCore.services.getTokenNetworkRelation
  toSymbol: 'USDT', // get data from eTransferCore.services.getTokenNetworkRelation
  fromAddress: 'source address', // Please remove the prefix and suffix of the ELF-DID address
  toAddress: 'transfer target address', // Please remove the prefix and suffix of the ELF-DID address
  memo: 'memo', // comment for Ton
  rawTransaction: 'transaction raw',
});

Update transfer order status

import { eTransferCore } from '@etransfer/core';

const result = await eTransferCore.services.updateTransferOrder({
  amount: '10', // transfer amount, without decimals
  fromNetwork: 'ETH', // transfer source Network, get data from eTransferCore.services.getTokenNetworkRelation
  toNetwork: 'tDVV', // transfer target Network, get data from eTransferCore.services.getTokenNetworkRelation
  fromSymbol: 'USDT', // get data from eTransferCore.services.getTokenNetworkRelation
  toSymbol: 'USDT', // get data from eTransferCore.services.getTokenNetworkRelation
  fromAddress: 'source address', // Please remove the prefix and suffix of the ELF-DID address
  toAddress: 'transfer target address', // Please remove the prefix and suffix of the ELF-DID address
  address: 'token pool address', // get data from eTransferCore.services.createTransferOrder
  memo: 'memo', // comment for Ton
  txId: 'transactin id', // get data from eTransferCore.services.createTransferOrder
  status: UpdateTransferOrderStatus.Rejected,
});
โš’๏ธ
โŒจ๏ธ
๐Ÿ“ƒConfiguration
๐Ÿ“ฅInstallation
etransfer-toolkit/packages/example at master ยท ETransferProject/etransfer-toolkitGitHub
Logo