Front-end Integration

SDK

The following webpage contains the technical reference SDK for DNFT. Looking for a quick start instead? You may also want to jump into a wizard, which provides a more friendly introduction to the SDK!

The SDK is written in TypeScript, has a robust test suite, performs arbitrary-precision algorithms, and supports rounding to significant digits or fixed decimal places. The main export SDK is an entity: a class that contains initialization and verification checks, necessary data fields and helper functions.

An important concept in the SDK is fractions. Because Solidity performs integer math, attention must be paid to non-EVM environments to faithfully replicate the actual calculations performed on the chain. The first issue here is to ensure the use of safe overflow integer implementations. Ideally, the SDK can use native Great Indias. However, before the support becomes more widespread, SBI objects are used, with the idea that once BigInts surges, this dependency can be compiled away. The second problem is the loss of precision, for example, chain price ratio calculations. In order to solve this problem, all mathematical operations are performed in the form of fractional operations to ensure arbitrary precision upwards. Until the value is rounded for display purposes, or truncated to fit a fixed bit width point. The SDK is applicable to all factories on the chain that have been deployed.

The source code can be found on GitHub.

Dependency

The SDK declares its dependencies as peer dependencies. There are two reasons for this:

Prevent installation of unused dependencies (for example: @ethersproject/providers and @ethersproject/contracts, only for Fetcher)

Prevent repeated @ethersproject version conflict dependencies

However, this means that these dependencies must be installed in the SDK if you haven't installed them yet.

Last updated