API for DFX.swiss crypto exchange
- Contact support to register your wallet name
- Create an address on selected blockchain (e.g. DeFiChain), see example below
- Get the sign message from sign-message endpoint and sign it with the corresponding private key
- Register the user with the sign-up endpoint
- Use the
walletId
from step 1 - See below for more information on the referral program (
usedRef
)
- Use the
- Now you can get your JWT access token (with address & signature) with the sign-in endpoint
The following code snippet shows a way to generate login credentials for the DeFiChain blockchain.
import { MainNet, Network } from '@defichain/jellyfish-network';
import { JellyfishWallet } from '@defichain/jellyfish-wallet';
import { Bip32Options, MnemonicHdNodeProvider } from '@defichain/jellyfish-wallet-mnemonic';
import { WhaleWalletAccountProvider } from '@defichain/whale-api-wallet';
import { sign } from 'bitcoinjs-message';
export class DfxLoginHelper {
private readonly network = MainNet;
private readonly seed = [ /* PUT YOUR SEED HERE */ ]; // 24 word mnemonic seed phrase
async generateCredentials(uniqueUserId: number): Promise<{ address: string; signature: string }> {
const { address, privateKey } = await this.getAccount(uniqueUserId);
const signMessage = await this.getSignMessage(address);
const signature = this.signMessage(signMessage, privateKey);
return { address, signature };
}
// --- HELPER METHODS --- //
private async getAccount(id: number): Promise<{ address: string; privateKey: Buffer }> {
const wallet = new JellyfishWallet(
MnemonicHdNodeProvider.fromWords(this.seed, this.bip32OptionsBasedOn(this.network)),
new WhaleWalletAccountProvider(undefined, this.network),
JellyfishWallet.COIN_TYPE_DFI,
JellyfishWallet.PURPOSE_LIGHT_WALLET,
);
return {
address: await wallet.get(id).getAddress(),
privateKey: await wallet.get(id).privateKey(),
};
}
private bip32OptionsBasedOn(network: Network): Bip32Options {
return {
bip32: {
public: network.bip32.publicPrefix,
private: network.bip32.privatePrefix,
},
wif: network.wifPrefix,
};
}
private async getSignMessage(address: string): Promise<string> {
// GET DFX SIGN MESSAGE WITH API CALL
return 'TODO';
}
private signMessage(message: string, privateKey: Buffer): string {
return sign(message, privateKey, true, this.network.messagePrefix).toString('base64');
}
}
If a user wants to get notified about ongoing transactions, he can register his email address with the user endpoint
- Basic information about the referral program can be found in the FAQ on our homepage
- A referral code can only be set once during user registration (
usedRef
parameter) - Every user will receive his own referral code after the first successful transaction. It can be get from the user detail endpoint.
KYC is not required for a daily transaction volume up to 1000 EUR/CHF. To increase the transaction volume, the user needs to be verified with a KYC process, which can be done on the DFX KYC page.
- Get the user's KYC hash from user endpoint
- Open then link to the KYC page:
https://payment.dfx.swiss/kyc?code=<kyc-hash>
- Get all available assets with the asset endpoint
- This endpoint will return all assets compatible with the user's address, which might be assets on multiple blockchains. The query parameter (optional) can be used to filter for specific blockchains.
- Only assets with the
buyable
field set totrue
can be bought
- Get all available currencies with the fiat endpoint
- Only fiats with the
sellable
field set totrue
can be used to buy crypto
- Only fiats with the
- Get the payment information with the buy payment endpoint
- Do a bank transfer with the provided payment infos
- Ensure compliance with minimum deposit and KYC limits
- The crypto asset will be sent to the user's blockchain address as soon as the bank transfer is completed
- Get all available assets with the asset endpoint
- Only assets with the
sellable
field set totrue
can be sold
- Only assets with the
- Get all available currencies with the fiat endpoint
- Only fiats with the
buyable
field set totrue
can be used to sell crypto
- Only fiats with the
- Get the payment information with the sell payment endpoint
- Do a blockchain transaction to the provided deposit address
- Ensure compliance with minimum deposit and KYC limits
- The fiat will be sent to the specified bank account as soon as the blockchain transaction is completed
- All bank accounts of a user can be fetched with the bank account endpoint
- A call to the buy or sell payment info endpoints will automatically create a bank account for the provided IBAN
- This can be used to improve UX and show the previously used IBANs to the user
- Bank accounts (label, preferred currency) can be updated with the update endpoint
- Bank accounts can be created directly with the create endpoint
- DFX.swiss is integrated in the DFX.swiss exchange