What's the use of getId and setId?
setId
and getId
will help you share data/value from one spell to another. You can get a value from a specific Id
that had been stored before.
Example where getId and setId can be used
Let's say I want to sell USDC to buy ETH on 1Inch and then deposit bought ETH into Compound.
- So I sell USDC on 1Inch, and I store the bought ETH amount at
setId
(let's say it's482
as setId for now) onsell()
function of 1inch. - Then I will use
482
as getId on compound deposit() function and deposit the bought ETH in Compound. In deposit function, I don't need to mention the amount specifically to deposit. It will get the deposit amount fromgetId
that is passed.
Code Snippet:
spells.add({ connector: "1INCH-A", method: "sell", args: [eth_address, usdc_address, sellAmount, unitAmt, 0, "482"] // setting bought ETH amount at id 482});spells.add({ connector: "COMPOUND-A", method: "deposit", args: ["ETH-A", 0, "482", 0] // getting deposit amount from id 482});
Note:
- For
getId
, if the id is0
then it won't get the stored amount but it will use the amount that's passed in the function. - For
setId
, if the id is0
then it won't stored amount.
If you still can't find something you're looking for or have any questions, ask them at our developers community on Discord or simply send an Email.
Our team is excited about assisting you to build an application using Instadapp Developer Platform. Your questions and feedback help us make a better development environment for future developers.