For integrators looking to monetize through LI.FI, there are specific prerequisites and processes in place.
This article aims to provide a detailed walkthrough of the necessary steps to monetize requests and subsequently withdraw the accrued fees.
Prerequisites
Before any monetization can occur, certain prerequisites must be met:
- Whitelisting: The integrator string and associated wallet address must be whitelisted on our backend.
- Request Parameters: To monetize requests, the fee parameter and integrator string must be passed. Conversely, if certain requests are not meant to be monetized on your side, omit the fee parameter.
For a more comprehensive understanding, refer to the documentation on LI.FI Monetization: Setting Up.
Monetization Process
Once the prerequisites are in place, you can begin the monetization process. Here's a step-by-step guide:
1. Whitelist Registration
Ensure that your integrator string and wallet address are registered on our backend system.
2. API Requests
When making requests, ensure that:
- The integrator string is passed.
- The fee parameter is included for monetized requests.
Fee Collection and Withdrawal
The fees collected from monetized requests are managed by our FeeCollection sub-contract. Here's how you can withdraw the accumulated fees:
Fee Withdrawal Flow
Refer to the diagram available at the end of our documentation page: LI.FI Monetization: Fee Withdrawal Flow.
-
Retrieve Collected Fees: Use the endpoint provided to fetch all collected fees. Access the endpoint via Get Integrators.
-
Generate Withdrawal Transaction: For each specific chain and token, employ the designated endpoint to produce a withdrawal transaction. This can be executed using the endpoint available at Withdraw Chain and Token.
-
Execute Transaction: Once the withdrawal transaction is generated, proceed to execute it as per your requirements.
Code Snippet for Transaction Request
For developers looking to initiate a withdraw collected fees transaction, here's a code snippet for reference for step 3:
```
const sendTransactionRequest = async () => {
console.log('Sending Transaction Request');
const providerUrl = _NODE_PROVIDER_URL_;
const privateKey = _TOWalletPrivateKey_;
const provider = new ethers.JsonRpcProvider(providerUrl);
const signer = new ethers.Wallet(privateKey, provider);
const tx = await signer.sendTransaction({
//send the transactionRequest generated from step 2
to: '0xbD6C...........',
data: '0xe5......087d56'
});
console.log('Transaction Result:', tx);
}
```