axiomzen/eth-random

Why does RPG.sol example use Random at another address rather than inheriting it?

Closed this issue · 1 comments

Hi,

Just wondering about the RPG.sol example:
https://github.com/axiomzen/eth-random/blob/master/example/contracts/RPG.sol#L18

Would it be just as good if RPG inherited from Random so you wouldn't have to pay the extra gas for calling another contract? CALL costs 700 gas whereas JUMP only costs 1 gas. If you're doing this (and/or the network gets overloaded and gas prices), seems like you'd make a good saving by inheriting from Random rather than calling it from an external contract.

Is the above accurate?

Not too accurate in my view, still you are right that it would be cheaper for a SC to pack Random and just use it yes.

Making a contract to call another contract still counts as 1 tx, do network congestion is only slightly smaller.

The theoretical strength of eth-random comes from multiple people calling it, on what would be each other's view, randomly. So packing your own random makes it weaker to some extent.

Still, worth reinforcing the disclaimer, eth-random is not meant for lotteries or any other significant prize. The right approach is a commit-reveal mechanism