Transaction

The SDK cannot perform transactions or send transactions on your behalf. Instead, it provides utility classes and functions that make it easy to calculate the data needed to safely interact with DNFT. Almost all the secure processing you need with DNFT is done by trading entities. However, you are responsible for using this data to send transactions in any context that makes sense to your application.

This guide will specifically focus on sending transactions to the currently recommended DNFT.

So, we have built a transaction entity, but how do we use it to send transactions? We still have a few things to do.

Before continuing, we should explore how ETH works in a trading environment. In fact, the SDK uses WETH because all DNFT V2 subs use WE TH under the hood. However, as an end user, it is entirely possible for you to use ETH and rely on the router to handle the conversion to WETH. So, let's use ETH.

The first step is to select the appropriate router function. The name of the router function is self-explanatory; in this example, we want to exchange execution tokens because we need to exchange a certain amount of ETH for tokens.

Sliding tolerance coding How much price fluctuations we are willing to tolerate before our transaction fails. Since Ethereum transactions are broadcast and confirmed in a confrontational environment, this tolerance is the best we can do to protect ourselves from prices The impact of volatility. We use this sliding tolerance to calculate the amount of Minum we must receive before our trade resumes, thanks to the smallest mountain. Note that this code calculates the worst case result assuming the current price, which is the middle of the route The price is fair (usually a good assumption because of arbitrage).

The path is just an ordered list of token addresses that we are trading, in our case, Weth and DAI (note that we use Weth addresses, even though we use ETH). The recipient address is the address that will receive DAI.

The deadline is a Unix timestamp, after which the transaction will fail to protect our case, our transaction takes a long time to confirm, and we wish to cancel our trade. This value must be used as msg.value in our transaction.

Last updated