getId/setId
How to use getID and setID to create transactions
What’s the use of getId and setId?
setId and getId can be used to input data correctly across spells. Values stored in specific IDs can be stored in one spell and used in another spell.
Example of using getId and setId
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:
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.
Last updated