0

I'm using Chainlink VRF to get a random number, but I need to keep track of the msg.sender that calls requestRandomWords when the fulfillRandomWords is fired. In other words I need the same msg.sender inside the fulfillRandomWords and in my tests it changes. How can I achieve that?

2 Answers 2

1

After see the Chainlink docs, I ended up using a mapping to store the requestId for a specific address. This allowed me to keep track of the sender.

enter image description here

mapping(uint256 => address) private requestIdToRequester;
0

You can look into tx.origin global variable to achieve what you need. However, please understand that it has security issues.

2
  • Oh, thanks for the tip, will try it out. If you know any other way to do it, please, let me know.
    – 0xTheL
    Oct 2, 2022 at 14:18
  • just tried to use the tx.origin here. On requestRandomWords the msg.sender and tx.origin are the same, but different on fullfillRandomWords.
    – 0xTheL
    Oct 2, 2022 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.