1.0.26 • Published 1 year ago

quontral v1.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Features:

  • Dex API endpoints for Web3 transactions
  • Web3 wallet configurations/authentications (login/sign)
  • Token allowances for web3 wallets and sending transactions
  • Handling big numbers and floating points
  • utility functions to help you build your dex

... and much more. Check the official Quontral docs for more details.

🚀 Quick start

If you're new to Quontral, check the quickstart guide in the official docs on how to get started.

1. Install Quontral

The easiest way to integrate the Quontral SDK into your JavaScript project is through the npm module.

Install the package via npm:

npm install quontral

Adding Quontral to the frontend project is by the following

import Quontral from 'quontral';

2. Initialize Quontral

After your dependency is added, you simply need to initialize quontral with class initialization:

⚠️ Warning: Make sure to keep your api key private

const service = new Quontral({ apiKey: 'YOUR_API_KEY' });

3. Using Dex API endpoints

After that we can use service functions to interact with the Dex API and Web3 wallet.

// ...

const priceResponse = await service.getPrice({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});

const quoteResponse = await service.getQuote({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});

4. Using services and utils

There are some utility functions which can help you build your dex even more quicker,

// ...

// This will initialize and configure the current Web3 wallet.
service.utils.connectWallet({ chainId: 56 });

// This will create an allowance based on your params on your web3 wallet for the desired token.
service.setAllowance({
  ownerAddress: '0x123', // your web3 wallet address
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1', // token address to create allowance for
});

5. Sending transaction using api data

// ...

const { data } = await service.getQuote({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});

// Send the transaction request on the current web3 wallet provider with the given api data of quontral
const receipt = await service.sendTransaction(data);

Or you can use the web3 library itself

import Web3 from 'web3';

// Initialize new web3 instance with the given provider
const web3 = new Web3(Web3.givenProvider);

// Our endpoint data for the transaction
const { data } = await service.getQuote({
  buyTokenAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
  sellTokenAddress: '0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1',
  sellTokenAmount: '1000000000000000000',
});

// Finally do the transaction on current wallet
const receipt = await web3.eth.sendTransaction(res.data);

6. Signin current Web3 wallet

// ...

// You can use these data pieces to save the users wallet credentials when signed
const { message, signature } = await service.sign({ address: '0x66E5869be1309a543A752aA24CfA251E86234fcc', domain: 'quontral.com', uri: 'https://app.quontral.com' });
1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago