Replies: 3 comments 2 replies
-
Hello @Jaqck
The cheapest way to it, is just generate a pseudo random number using the encode Solidity provides, however is not recommendable at all as is easily predictable. The best way (but you have to pay for) is to use VRFCoordinator from Chainlink and get truly random verifiable numbers. About the amount of random numbers you want, 5 on this case I would suggest to take a look to this thread which I think is the best answer to this.
Using the same data feed to get the eth price could be used to get the link token price, you can refer the docs here.
You can do this on a contract which then transfers the ERC20 token to another contract, but this would be more expensive than just funding the contract you are working on, as each transaction on ETH cost a lot (depending on the context), creating a function to fund other contracts is not desirable. I hope this info might help. |
Beta Was this translation helpful? Give feedback.
-
I think for the random number I would want to request a random number using the VRFCoorindator which obviously costs link. So rather than requesting 5 my idea was to request 3 and use different math equations to generate more unique random numbers. This would allow around7/8 different random numbers to be generated E.G. 7/8 different attributes/characteristics/traits just for the cost of 3 random numbers. Also, The link question was more in terms of could I include a function in my NFT contract that only I the owner could use and it would allow me to fund the NFT contract with link E.G. 10 Link to be used for random number generation rather than charging the person minting an NFT. so it would use this pot of link I invest instead of the minters Link. Hope this clears this up :) |
Beta Was this translation helpful? Give feedback.
-
Okay I will take a look at chain link keepers thanks! So in terms of the random vs pseudo random topic I understand that in a case where we are using the whole number this value is not completely random. Randomnumber1 + randomnumber2 can never equal 1 so it therefore is never random. However the use of this when we are dividing this number to find the remainder surely counters this. Because whether the final value is 10,006 or 1,000,000,006 and I have 5 possible outcomes both answer to 1. so all numbers and therefore all possibilities are still theoretically possible and achievable. Something that isn't possible in the first example. However, if I decided to go the safe route and use the chain link vrfcoordinator for all 6 random numbers how would I gather an estimated cost for these transactions? How much does each transaction cost in link? |
Beta Was this translation helpful? Give feedback.
-
I have loved this course so far but have been left with a few questions when it comes to creating NFTs and some of the processes behind it. For example if you need to randomly generate 5 different variables what is the most cost effective method to do this? I would not assume it is to request 5 random numbers. The solution I arrived at was requesting two random numbers and using different mathematical methods to find unique numbers. This can be increased by requesting 3 random numbers. E.G RandomNumber1 + RandomNumber2, RandomNumber1 - RandomNumber2, RandomNumber1 x RandomNumber2 etc.
The other question I was considering involves the idea of funding a contract to retrieve this information. Is there a way to get the current price in LINK to retrieve this information? Could I code a function to fund a large amount of link (lets say 10) onto the contract and that amount would be used for the future funding of contracts?
I hope these dialogue threads help people further their learning!
Beta Was this translation helpful? Give feedback.
All reactions