General
The transaction call retrieved from the DLN API must be signed by a user who is willing to sell the asset, and then broadcasted to the source chain.EVM
Thetx
object has the following structure and is ready to be signed and broadcasted:
tx
object are self-explanatory:
to
field defines where the transaction should be sent to, and typically you should expect the address of one of the smart contracts responsible for forwarding;data
field defines the transaction content, containing instructions related to swaps planned on the source or (and) on the destination chains, bridging settings, etc;value
is the amount of native blockchain currency that must be sent along with the transaction.
value
is always positive, even if the input token is an ERC-20 token. This is because the underlying DLN protocol takes a fixed amount in
the native currency, so the API always includes it as the transaction value. In the above example, the value
equals the current fixed fee, which is
0.005 BNB on the BNB Chain.
Second, in case the input token is an ERC-20 token, a user needs to give approval to the smart contract address specified in the tx.to
field prior
to submitting this transaction so it can transfer them on the behalf of the sender. This can be typically done by calling either approve()
or
increaseAllowance()
methods of the smart contract which implements the token you are willing to swap. Approve at least the amount that has been
specified as the estimation.srcChainTokenIn.amount
response property.
Other than that, the transaction is ready to be signed by a user and broadcasted to the blockchain. It is also worth mentioning that the given
transaction data can be used as a part of another transaction: a dApp can bypass the given to, data and value to your smart contract, and make a
low-level call. There is even a possiblility to create multiple transactions for different orders, and perform several low-level calls.
The affiliate fee is paid only after the order gets fulfilled, and the taker requests order unlock during the unlock procedure.
Solana
For DLN trades coming from Solana thetx
object returned by DLN API has only one field - data
which is hex-encoded
VersionedTransaction
To convert the hex-encoded string into VersionedTransaction
decode hex to buffer using any library and call
VersionedTransaction.deserialize(decoded)
.
Resources
Make sure you properly set transaction priority fees based on the current load of the Solana network. Refer to one of these guides to learn more about
how to estimate tx fee parameters:More info about sending versioned transactions
here.