Ethereum Oracle with Apache Camel and Web3j
Compile the contract.
truffle compile
Start a local Ganache instance first. Then deploy the contract.
truffle migrate --reset
And leave it to listen for CallbackGetBTCCap events to update btc price with a random value.
mvn spring-boot:run
On a separate terminal check the current btc value in the contract (will be 0)
mvn test -Dtest=CamelOracleRouteTest#getBTCCap
CallbackGetBTCCap event will be picket by the Camel route running above. Then the route will update the btc price with a random value.
mvn test -Dtest=CamelOracleRouteTest#updateBTCCap
Then check btc price again to see it set in the contract with random value:
mvn test -Dtest=CamelOracleRouteTest#getBTCCap
Rather than using the oracle, you can also set the btc price directly to 100:
mvn test -Dtest=CamelOracleRouteTest#setBTCCap
The complete Javascript based example are from here
node oracle.js
On a separate terminal
node client.js