GithubHelp home page GithubHelp logo

first-dapp-project's Introduction

How To Use ๐Ÿค”?

  1. First install truffle globally npm install truffle -g
  2. Use truffle init to intiate truffle.
  3. Now make changes in migration folder
    const demo = artifacts.require("demo");     
    module.exports = function(deployer){
        deployer.deploy(demo);              
    }
  4. Add changes in truffle-config.js file.
    • Uncomment the development network and change port to 7545
    • Then add the line given below in the module.exports = section
      contracts_build_directory: "./frontend/public/contracts"
  5. ๐Ÿ‘‡ Add the Demo.sol file in contract folder. Here is the code ๐Ÿ‘‡ (--You can skip this step--)
    // SPDX-License-Identifier: UNLICENCED
    pragma solidity ^0.8.7;
    contract demo{
        uint tomato;
    
        receive() external payable{}
    
    
    
        uint public numoffunder;    
        mapping (uint => address) private funders;
        
        function transfer_tocontract() external payable{
            funders[numoffunder] = msg.sender;
        }
        function withdraw(uint withdrawAmount) external payable{
            require(
                withdrawAmount <= 2000000000000000000,
                "Cannot withdraw more than 2 ether"
            );
            payable(msg.sender).transfer(withdrawAmount);
            
        }
    
    
        //setting and getting value of tomato
        function setvalue(uint value) public {
            tomato = value;
        }
    
        function getvalue() view public returns(uint){
            return tomato;
        }
    }   
  6. Add the Frontend folder in this repo in the root directory of project.
  7. Use npm install accordingly to install dependencies in frontend folder.
  8. Now migrate the contract using truffle migrate --reset in frontend folder.
  9. Finally Use npm start to see the working โœ”โœ”

Screenshot ๐Ÿ‘€

image

first-dapp-project's People

Contributors

pranshu-taneja avatar

Watchers

 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.