1. Prepare unsigned transaction
Obtain the unsigned transaction object either in theencoded or json format provided by the Craft Transaction Step endpoint.
2. Sign transaction
Since the DeFi API flow is determined by the individual schema depending on the action type, protocol, and strategy, construction of multiple transactions may be required. As a result, there are two types of unsigned transaction objects provided by the DeFi API — intermediate and final.- Intermediate transactions are typically required to grant permissions to smart contracts involved in the integration process. These objects need a signature, as they must be included in the payload of the final transaction, but there is no need to broadcast such transactions to the network.
- Final transactions, on the other hand, require both signing and broadcasting. The steps at which these transactions are constructed have the word “final” in their name and are executed last according to the schema’s order. Such objects must contain the data of all intermediate transactions in the payload.
For intermediate transactions
NB: signing only, no broadcasting.Use any of the code examples for the
base network below.
For final transactions
NB: contain the word “final” in the step name; require signing and broadcasting.Use any of the code examples for the
base network below.
3. Broadcast signed final transaction
NB: required for final transaction type only.To submit the final transaction to the network, send a POST request to /api/defi/v1/transactions/steps/broadcast. Example request:
signedTransaction— signed final transaction in the hexadecimal format which needs to be broadcasted to the network.
transactionHash— hash of the final transaction.time— request execution time in ms.requestId— unique identifier of the request.