Giter Site home page Giter Site logo

btcalchemist / meme-of-the-day-dapp-eth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matprime/meme-of-the-day-dapp

0.0 0.0 0.0 1.85 MB

upload your meme, vote and comment on other memes, discover top memes - Ethereum test

JavaScript 88.05% HTML 7.37% CSS 4.58%

meme-of-the-day-dapp-eth's Introduction

Meme of the Day dApp -- For Fantom Protocol & Opera Blockchain

Upload your meme, vote and comment on other memes, discover top memes with this dApp.

Meme of the Day is a fun social platform that was created for use with Fantom's Opera blockchain and Interplanetary File System (IPFS). The dApp interface runs in a web browser, where the user uploads a meme image that is saved in IPFS, which creates a hash that is stored on the Opera blockchain. This is our initial proof of concept functionality. Until Fantom releases Opera testnet, it is possible to get the dApp up and running in a local development environment with local Ethereum blockchain (Ganache). The Fantom Opera network is web3js compatible, so using the web3js calls in the documentation (https://web3js.readthedocs.io/en/v1.2.5/) should work the same as with the Opera network and Ethereum network.

Beyond this, our vision is for people to vote and possibly comment on the memes they like, which would be featured in a list that is updated in real-time. After a user pays for their first vote, they would receive three free votes, paid directly from the transaction fee of the first vote (equal to the required gas for four total vote operations). The smart contract would save that gas in a dedicated Opera account that it would access to implement the three free votes.

We are hopeful that Meme of the Day and the future voting mechanism would encourage more user interest and engagement with Opera network and the Fantom protocol. This dApp can prove that a user is the true creator of a meme (or any file they uplod to IPFS), and it is open to users from multiple blockchains, thanks to Fantom's interoperable protocol.

Dependencies are:

  • Node.js 10.1x.x

download from https://nodejs.org and follow installation instructions

  • Truffle

npm install -g [email protected] (important is to use this version)

  • Web3.js

The Fantom Opera network is web3js compatible, so using the web3js calls in the documentation (https://web3js.readthedocs.io/en/v1.2.5/) should work with the Opera Network and Ethereum network.

  • IPFS

Public open IPFS through Infura is already coded into Meme dApp, find more about IPFS here https://infura.io/

Currently it is possible to use local Ethereum blockchain (Ganache) to run the dApp. After Opera testnet will be deployed and available, it will be possible to use the dApp on it.

Currently it is possible to use Metamask for testing the dApp.

Installation procedure

git clone https://github.com/matprime/meme-of-the-day-dApp
cd meme-of-the-day-dApp
npm install
truffle migrate --reset
npm run start

Before starting the dApp with last command "npm run start", you need to make sure that local Opera blockchain is running. Please look into Opera blockchain repository at https://github.com/Fantom-foundation/go-lachesis on how to start it. After Opera blockchain is running and you started the dApp, you should see web browser open up, and the dApp will load and show the latest meme uploaded in browser window.

If you are testing on a local blockchain, make sure Ganache is running with port 8545 in server settings (this is specified in truffle-config.js).

Note: For frontend test to display memes when dApp is started for the first time on your local computer, the wallet addresses in the MemesHandler.sol constructor must match the addresses in your Ganache test environment.


Command to migrate smart contract to blockchain

truffle migrate

After successful migration of smart contract to blockchain, you can interact with it using Truffle console.

Some commands you can use with Truffle console After smart contract deployment to blockchain with migration, you can use Truffle console to interact with smart contracts using CLI. To start Truffle console from command shell type:

truffle console

After Truffle console is running you can get contract from blockchain with command:

truffle(development)> const memeshandler = await MemesHandler.deployed()

You can store hash of meme to blockchain using contracts set function:

truffle(development)> result = memeshandler.newMeme('QmYHaaWHgpT2iBGNxMCCFpDKgskej6bhubd5cnytUuJKRp')

To get the account under which meme was stored on blockchain, you can type:

truffle(development)> const memesList = memeshandler.getMemesList()

You need to type constant as command to get value stored in it:

truffle(development)> memesList
[ '0x787eBC47F34081a0Df4dc3923798828ae52C538C' ]

Read the IPFS file hash from meme stored on blockchain:

const meme = memeshandler.getMemeByAddress('0x787eBC47F34081a0Df4dc3923798828ae52C538C')

Output IPFS file hash into console:

meme
'QmYHaaWHgpT2iBGNxMCCFpDKgskej6bhubd5cnytUuJKRp'

To run tests defined in folder /test run from shell command

truffle test

Tests will check if contract deployment on blockchain was done correctly, and it will check if get and set methods of smart contract are working correctly. After running the command, you will see output similar to:

Using network 'development'.

Compiling ./src/contracts/FilesHandler.sol...


  Contract: FilesHandler
    deployment
0xDA228234a792cb9C7C8cf9E9E0dB48A8F57C7D08
      ✓ deployed successfully!
    storage access
Saving and retrieveing from Blockhain
test123
      ✓ Hash saved and retrieved (282ms)


  2 passing (422ms)

meme-of-the-day-dapp-eth's People

Contributors

matprime avatar btcalchemist avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.