1

I am new to Blockchain development. I am developing a game that depends heavily in random numbers. My first naive implementation was flagged by the auditor as I was generating them on-chain. So I changed my code to use Chainlink instead.

So now instead of just doing something like:

const tx = await myContract.doAction()
const receipt = await tx.wait()
const whatIWant = getWhatIWantFromRecepit(receipt)

I must subscribe to an event or keep polling from the blockchain until my event with the results triggers:

await myContract.doAction()
myContract.on("WhatIWant", (params) => { // here I have what I want })

However, querying the blockchain seems to be a commodity. I am using BNB Chain and the official public RPCs available, event for testnet, have these features disabled. They don't even allow getLogs, so I cannot even poll. I do understand why the disable them though.

Some googling around brought to the fantastic world of blockchain infrastructure providers, which they offer "reliable RPC endpoints APIs", for a price. Usually they have a free tear which is nice.

As a blockchain dev noob I am a bit unsecured about my findings so my question is...Is this the only way to get proper event notifications without having to create and maintain your own full node? There is any other way to get the random number generated from Chainlink?

1 Answer 1

0

They don't even allow getLogs, so I cannot even poll. I do understand why the disable them though.

Querying logs consumes considerable resources and for public free RPC nodes, it can open a DOS vector. In the past, people might have exploited it by doing a lot of querying hence they had to disable it.

Is this the only way to get proper event notifications without having to create and maintain your own full node?

If I am honest, that's the idea with blockchain. Historically for sending and receiving Bitcoin, as a user you had to run a node, and similarly with Ethereum. To expand the user base, people did wallets with remote nodes where someone else ran the node for users. Some investors who bought a lot of coins, funded these node provider services so they could provide free nodes initially to bootstrap the ecosystem. But that can't stay for free since you see running a node consumes resources.

These days the app developers pay the infrastructure providers, however that is temporary too. Eventually (like in a decade or so ig), just like cell phone/internet plans, users would have to take an ethereum node plan (some sort of it that includes popular chains). However, it cannot happen anytime soon to speed up user onboarding.

Running a dedicated node could be costly if that would go underutilized, so using a shared node from the infrastructure providers saves the bill. But in some cases people want to do intensive queries, so running a self-node could be cheaper.

There is any other way to get the random number generated from Chainlink?

I am not aware of how you are using random numbers, but one might be able to use prevrandao (0x44) available in EVM it is not like blockhash which can be influenced by the block author.

Your Answer

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

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