โจ๏ธQuick Start
Last updated
Last updated
For the configuration items used in the following examples, please refer to:
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()
});
import { eTransferCore } from '@etransfer/core';
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' },
);
import { eTransferCore } from '@etransfer/core';
const result = await eTransferCore.services.checkEOARegistration(
{
address: 'your account address',
}
);
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'
});
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',
});
import { eTransferCore } from '@etransfer/core';
const result = await eTransferCore.services.getNetworkList({
type: 'Deposit', // or 'Withdraw'
chainId: 'AELF', // or 'tDVV'
symbol: 'USDT', // Get data from eTransferCore.services[getTokenOption|getTokenList]
});
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
});
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'
});
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,
});
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,
});
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,
});
import { eTransferCore } from '@etransfer/core';
const result = await eTransferCore.services.getRecordDetail('orderId');
import { eTransferCore } from '@etransfer/core';
const result = await eTransferCore.services.getRecordStatus();