CRYPTO NEWS
6 Questions for Annabelle Huang of Amber Group
I’m trying to use chainlink VRF to handle different logic. In essence, I want the fulfill random words to do something depending on the function that made the request. E.g uint256 public A; uint256 public B; function doLogicA() public{ //Makes a request for a random number } function doLogicB() public{ //Also makes a request for::Listen
I’m trying to use chainlink VRF to handle different logic. In essence, I want the fulfill random words to do something depending on the function that made the request.
E.g
uint256 public A; uint256 public B; function doLogicA() public{ //Makes a request for a random number } function doLogicB() public{ //Also makes a request for a random number } function fulfillRandomWords() internal override(requestId, randomWords){ // If dologicB made the request update storage variable B // If dologicA made the request update storage variable A } '
My thoughts on this is probably to use a mapping to keep track of which function made the request with a functionId(a hash or uint256) with the request Id given to us from the request E.g
mapping(uint256 => uint256) public requestIdToFunctionId;
Then in the fulfillRandomWords we could have some if logics E.g Let’s take doLogicB function Id to be 1 and dologicA 2.(Hashing their names would probably be better). Our fulfillRandomWords function could look like this?
function fulfillRandomWords (requestId, randomWords ) internal override { If(requestIdToFunctionId [requestId] == 1){ //Do logic B } If(requestIdToFunctionId [requestId] == 2){ //Do logic A } }
It’s a bit tedious especially if we’re gonna keep track of individual users or tokenId’s but I think it’s doable with a nonce. Then we’d have mappings of requestId to FunctionId to user to nonce. Lol! Awesome! But I wanted to know if there was a better way of doing this. P.s I apologize if I wasn’t so clear on the question, I’m on the road. It popped in my head. Didn’t want it to leave!
Showing 1–8 of 312 results
-
Electroneum ETN Unisex Twill Crypto Hat
USD$25.30 Select options -
Pearl Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Insight Chain INB Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
DASH Unisex Twill Crypto Hat
USD$25.30 Select options -
Naga NGC Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Paypex PAYX Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Poet POE Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Cardano ADA Unisex Twill Crypto Hat
USD$25.30 Select options
