truffle unbox RhombusNetwork/lighthouse-local from your command line
What is a Rhombus Lighthouse?
Rhombus deploys oracles to main/test Etherium networks for you to use. These oracles (called Lighthouses) store verified values from outside the chain, such as New York City temperature, Amazon stock prices, or randomly generated numbers.
Why do I need Local Testing?
While useful, it is hard for projects under development to simulate interactions with a lighthouse. Developers must build the whole project, deploy on a test net, and then interact with the lighthouse to see if data reading works. This is tedious and would speed up development if data reading could be tested on a local testing chain as the project is under development
How does Local Testing work?
Using the Truffle and Ganache development environment, users are able to quickly create a local blockchain to experiment with. Projects will be deployed on this local chain that is under your control, and tests suites can be written to interact your smart contract under development.
Rhombus local testing utilizes Truffle tests. If you are unfamiliar with Truffle, first go through their testing documentation here.
Simulating a Rhombus Lighthouse
To set up a copy of the main/test net scenario, users will first deploy their own lighthouse on the local Ganache chain. Then they will need to write a hard coded value (say NYC temperature) into the lighthouse. This is all done by the Rhombus team on main/test nets! Users are only deploying this local lighthouse to simulate our setup.
Testing your Smart contract
Now that the lighthouse is deployed, users can deploy their smart contract and pass it the lighthouse address where it will go to obtain information, all in the same testing file. Now users have both the lighthouse and smart contract under development on one local chain, and can interact with each other!
The Gambling Game Scenario
Alice wants to start a casino where players can bet Ether on the outcome of a dice roll. Unfortunately, it is hard to generate truly random numbers on the Etherium blockchain. To help her, the Rhombus team have created a oracle which will periodically obtain a random number generated off-chain, and store it into a lighthouse. Now Alice is all set to start her gambling game!
Users will first deposit money into the smart contract, then they can place bets on the outcome of the next dice roll. Once the dice roll happens, users will either lose the ether they have bet, or win back returns on their bet. They can withdraw all their deposited and earned ether at any time.