Tutorial - React Redux App + Solidity desde cero. Metamask-Ethers

14

  • 40
  • 0
  • 0.112
  • Reply

  • Open in the desktop app ADD TO PLAYLIST

    jfdesousa7

    Published on May 24, 2022
    About :

    Saludos, en el día de hoy crearemos una app donde usaremos Redux en una aplicación real, en esta ocasión leeremos data desde Ethereum, crearemos un contrato inteligente usando Solidity como lenguaje de programación, además de otras librerías como ethers para la conexión con la web3, usaremos React como librería para el frontend y el core de este tutorial es la de usar Redux para gestionar los estados generales de nuestra aplicación.

    App.js

    import React, { useState } from "react";
    import { useDispatch, useSelector } from "react-redux";
    import { connect } from "./redux/ethereum/ethereumActionsCreator";
    import { fetchData } from "./redux/data/dataActionsCreator";

    const App = () => {
    const dispatch = useDispatch();
    const { ethereum, data } = useSelector((state) => state);
    const [value, setValue] = useState("");

    const handleButton = async () => {
    const txResult = await ethereum.contract.setValor(value);
    await txResult.wait();
    dispatch(fetchData());
    setValue("");
    };

    return (


    {ethereum.error ? ethereum.error : null}
    {ethereum.account === undefined ? (
    <>

    Debes conectarte con metamask


    <button onClick={() => dispatch(connect())}>Conectar
    </>
    ) : (
    <>

    Hola address: {ethereum.account}


    Valor: {data.valor}

          <div>
            <input
              text="text"
              value={value}
              onChange={(e) => setValue(e.target.value)}
            />
            <button onClick={handleButton}>Asignar valor</button>
          </div>
        </>
      )}
    </div>
    

    );
    };

    export default App;

    Tags :

    programming technology development geek geekzone programacion developspanish

    Woo! This creator can upvote comments using 3speak's stake today because they are a top performing creator! Leave a quality comment relating to their content and you could receive an upvote worth at least a dollar.

    Their limit for today is $0!
    Comments:
    Time until jfdesousa7 can give away $0 to their commenters.
    0 Days 0 Hours 0 Minutes 0 Seconds
    Reply:

    To comment on this video please connect a HIVE account to your profile: Connect HIVE Account

    04:49
    1 views 2 years ago $

    More Videos

    00:39
    5 views 3 years ago $
    00:50
    1 views 8 months ago $
    00:50
    0 views 4 months ago $
    05:24
    5 views 10 months ago $