Skip to main content

Ramp

Provide the Ramp functionality, including on-ramp and off-ramp, enabling buying and selling operations for ELF with fiat currencies.

Before using this component, please make sure you are logged-in.

Before using this component, we assume that you are already familiar with the basic configuration of Portkey.

Feature

Ramp's functions and UIs are as follows:

  • Buy

    • Select the type and quantity of fiat currency for payment.
    • Select the type of token to be received.
      • Currently only supports ELF
      • We will assist you in estimating the quantity to be received
      • Exchange rates is renewed every 15 seconds with the estimated asset to be received also updated
    • Provide limit amount prompts, allowing payment only in the specified range of fiat currency for token exchange.
  • Sell

    • Select the type and quantity of tokens for payment.
      • Currently only supports ELF.
    • Select the type of fiat currency to be received
      • We will assist you in estimating the quantity to be received
      • Exchange rates is renewed every 15 seconds with the estimated asset to be received also updated
    • Provide manage information synchronization prompt, transactions can only occur when manage information is present.
    • Verify wallet security and transfer limits when users sell tokens
buying
fiat currency selecting
token selecting
limit amount
selling
manage information synchronization
wallet security notice
transfer limit notice

Usage

import { Ramp } from "@portkey/did-ui-react";

const App: React.FC = () => (
<Ramp
tokenInfo={{
decimals: 8,
chainId: "AELF",
symbol: "ELF",
tokenContractAddress: "JRmBduh4nXWi1aXgdUsj5gJrzeZb2LxmrAbf7W99faZSvoAaE",
}}
portkeyWebSocketUrl={"http://192.168.66.240:5577/ca"}
isMainnet={true}
onBack={function (): void {
// do something to show the last page
}}
onShowPreview={function ({ initState, chainId }): void {
// do something to show the preview transaction details page
}}
/>
);
export default App;

API

PropertyDescriptionTypeRequiredDefaultVersion
classNameClass name of the top level containerstringfalse
initStateData that controls the initial page displayIRampInitStatefalse
isBuySectionShowControl if on-ramp is enabledbooleanfalsetrue
isSellSectionShowControl if off-ramp is enabledbooleanfalsetrue
isMainnetIs it Mainnetbooleanfalse
tokenInfoToken informationITokenInfofalse
portkeyWebSocketUrlWebSocket service address, requiring IP formatstringfalse
isErrorTipIs error tip set as defaultbooleanfalsetrueV2.0.0
onBackControl the event to go back to the previous route() => voidtrue
onShowPreviewControl the event to navigate to the preview({ initState, chainId }: { initState: IRampPreviewInitState; chainId: ChainId }) => void;true

Detailed explanation

IRampInitState

Page initialization data, you can define the default fiat currency and token information from here.

InterfacePropertyDescriptionTypeRequired
IRampInitState
cryptoCrypto name, eg: ELFstringtrue
networkCrypto network eg: AELFstringtrue
fiatFait code, eg: USDstringtrue
countryCountry code, eg: USstringtrue
amountAccount numberstringfalse
sideBusiness typestrRampTypeEnum: "BUY" | "SELL"true

ITokenInfo

Current chain information for the operation, defaulting to aelf

InterfacePropertyDescriptionTypeRequired
ITokenInfo
decimalsDecimals, eg: 8number | stringtrue
chainIdChain ID code, eg: 'AELF'ChainIdtrue
symbolSymbol code, eg: 'ELF'stringtrue
tokenContractAddressToken contract addressstringtrue

IRampPreviewInitState

Parameters required to navigate to the Ramp preview page. Refer to RampPreview for details.

ChainId

Enumeration range: 'AELF' | 'tDVV' | 'tDVW';