An open API service indexing awesome lists of open source software.

https://github.com/lorransutter/stock-oracle

Web app that retrieves stock data and write in a smart contract
https://github.com/lorransutter/stock-oracle

blockchain oracle reactjs smart-contracts solidity stocks truffle web3js

Last synced: 6 months ago
JSON representation

Web app that retrieves stock data and write in a smart contract

Awesome Lists containing this project

README

          

# Stock Oracle

Oracle implementation using Solidity, Truffle and API of stock market info presented as lab assingment for BCDV1011 - Design Patterns for Blockchain from Blockchain Development program from George Brown College.



## :runner: How to run

Open your terminal in the folder you want to clone the project

```sh
# Clone this repo
git clone https://github.com/LorranSutter/Stock-Oracle.git

# Go to the project folder
cd Stock-Oracle

# Install dependencies
yarn
```

Now you will need two opened terminals to run the project. One for truffle to simulate the EVM and another one for the frontend.

Truffle will run on http://127.0.0.1:9545/

Frontend will run on http://localhost:3000/

```sh
## In the first terminal ##

# Go to smart contract folder
cd src/StockSmartContract

# Init truffle
truffle develop

# Run migrations
migrate
```

The last command above will generate a new ABI and write contract address in a JSON file. You do not have to worry about importing these info in the frontend though. Also you may change the smart contract and run migrations again to see your changes.

```sh
## In the another terminal ##

# Go to frontend application
cd ..

# Run the project
yarn start
```

## :book: References

- [Alpha Vantage](https://www.alphavantage.co/) - stock API
- [Web3 calls](https://bitsofco.de/calling-smart-contract-functions-using-web3-js-call-vs-send/) - understanding web3.js calls

## :computer: Technologies

- [Solidity](https://solidity.readthedocs.io/) - smart contract programming language
- [Truffle](https://www.trufflesuite.com/) - dApp environment
- [React](https://reactjs.org/) - frontend library
- [Polaris](https://polaris.shopify.com/) - design system
- [Axios](https://www.npmjs.com/package/axios) - HTTP requests
- [Web3.js](https://web3js.readthedocs.io/) - interact with smart contracts