documentation icon indicating copy to clipboard operation
documentation copied to clipboard

why ChainLink VRF Direct Funding Method doesnt work and Subscription Method does?

Open brunovjk opened this issue 2 years ago • 2 comments

Describe the bug

I'm creating a contract to generate random numbers using ChainLink.

I choose the Direct Funding Method because it fits my project better. But I can't make it work at all. I'm using the example contracts made by ChainLink itself. I use Remix, I also tried forked mainnet using Hardhat/Alchemy. I can deploy the contract, I can send LINK and even check the balance. However, it always returns an error when I do the requestRandomWords()

ProviderError: Error: Transaction reverted without a reason string

But when I use the Subscription Method example contract, everything works perfectly.

Does anyone have an idea of what might be happening???

I followed exactly the steps in the documentation: create contract, Fund the contract with LINK (I check the contract LINK balance, and has funds) and requestRandomWords()

To Reproduce

  1. Go to 'https://remix.ethereum.org/#url=https://docs.chain.link/samples/VRF/VRFv2DirectFundingConsumer.sol&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.7+commit.e28d00a7.js'
  2. Follow Direct Funding Method docs 'https://docs.chain.link/docs/vrf/v2/direct-funding/examples/get-a-random-number/'

URLs

https://docs.chain.link/docs/vrf/v2/direct-funding/examples/get-a-random-number/

Expected behavior

I should be able to request random numbers calling requestRandomWords()

Additional context

ProviderError: Error: Transaction reverted without a reason string

brunovjk avatar Oct 04 '22 15:10 brunovjk

Hi @brunovjk

thanks for raising the issue. Did you follow the note? (set up the gas limit to 400,000)

  1. Click the requestRandomWords() function to send the request for random values to Chainlink VRF. MetaMask opens and asks you to confirm the transaction. Note Remix IDE doesn't set the right gas limit. For this example to work, set a gas limit of 400,000 as explained here. After you approve the transaction, Chainlink VRF processes your request. Chainlink VRF fulfills the request and returns the random values to your contract in a callback to the fulfillRandomWords() function. At this point, a new key requestId is added to the mapping s_requests.

aelmanaa avatar Oct 05 '22 07:10 aelmanaa

Thanks for care. I also tested it using Hardhat, set the rate limit and all. I believe I'm doing something wrong, but I believe it`s exactly where you said, in handling the gas rate, and does Direct Funding Method work correctly, right? So there's a problem here, I'll solve it, I was afraid of a problem with the example contract code. Again, thanks for your time. Can I close the issue?

brunovjk avatar Oct 05 '22 18:10 brunovjk