# 3. Build Flash Loan

### Flash loan transaction manifest

A flash loan transaction typically interacts at least 3 times with components - to get, use and repay the loan. However, depending on the use case, the number of interactions might increase.

Therefore, on a high level, a flash loan transaction manifest can be broken down into:

1. Getting a loan
2. Using a loan
3. Repaying a loan

Below a transaction manifest for a flash loan on Gable is illustrated:

<pre data-full-width="false"><code># Gable flash loan transaction

# (1) get loan

# call get flashloan method
#    provide: loan amount
#    return: loan + transient token
CALL_METHOD 
Address("component_rdx1cpmh7lyg0hx6efv5q79lv6rqxdqpuh27y99nzm0jpwu2u44ne243ws") 
"get_flashloan" 
Decimal("&#x3C;loan_amountt>");

# (2) use loan

# take XRD loan from worktop
TAKE_FROM_WORKTOP 
Address("resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd") 
Bucket("xrd_bucket1");

# for instance call a method that takes some XRD ...
# ... and returns GAB
CALL_METHOD 
"swap"
Address("&#x3C;some_component_address>") 
Bucket("xrd_bucket1");

# take GAB loan from worktop
TAKE_FROM_WORKTOP 
Address("resource_rdx1tknu3dqlkysz9lt08s7spuvllz3kk2k2yccslfpdk73t4lnznl9jck") 
Bucket("gab_bucket");

# for instance call a method that takes some GAB ...
# ... and returns some XRD
CALL_METHOD 
"swap"
Address("&#x3C;some_component_address>") 
Bucket("gab_bucket");

# (3) return loan

# take XRD from worktop
TAKE_FROM_WORKTOP 
Address("&#x3C;resource_tdx_c_1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq40v2wv>") 
Bucket("xrd_bucket2");
<strong>
</strong><strong># take transient token from worktop
</strong><strong>TAKE_FROM_WORKTOP 
</strong><strong>Address("resource_tdx_c_1q2xltzyu94nesddh0yyq9h9vuzz5l904n2yt93ltfsssg3ygd5") 
</strong><strong>Bucket("transient_bucket");
</strong>
# call repay flashloan method
#    provide: XRD plus transient token
#    return: residual XRD
CALL_METHOD 
Address("component_tdx_c_1qwxltzyu94nesddh0yyq9h9vuzz5l904n2yt93ltfsssa7pd6s") 
"repay_flashloan" 
Bucket("xrd_bucket2") 
Bucket("transient_bucket");

# the residual XRD (your profit) will be returned to your wallet
CALL_METHOD 
Address("&#x3C;<a data-footnote-ref href="#user-content-fn-1">your_account_address</a>>") 
"deposit_batch" 
Expression("ENTIRE_WORKTOP");
</code></pre>

Tailoring this transaction to your use case will require you to (1) fill in open fields:

* \<loan\_amount>: the loan amount in XRD that you would like to receive.
* \<your\_account\_address>: the account address to which you would like to return the residual XRD of the transaction (you profit).

And (2) overwrite the 'use loan' section with your specific use case.

**Note:** no method call to “lock\_fee” is required – the wallet will add this automatically.

[^1]:
