Coder Social home page Coder Social logo

Comments (5)

Gizmotronn avatar Gizmotronn commented on August 29, 2024

I am just calling the tokens "Credits" with shortname "SKK" (SignalKineticsKoin), 'Credit' derives from the currency in Star Wars. Not sure what we'll call the main currency later -> maybe 'gears' or something robotics?? Also, I'm looking into multiple currencies.

from silfur.

Gizmotronn avatar Gizmotronn commented on August 29, 2024

https://skinetics.notion.site/Unity-Rest-API-e5f22d05e0d5418fa3b9b55e457e2767

from silfur.

Gizmotronn avatar Gizmotronn commented on August 29, 2024

#7 ->
Screen Shot 2022-02-07 at 9 53 59 pm

Slack msg

from silfur.

Gizmotronn avatar Gizmotronn commented on August 29, 2024

https://stackoverflow.com/questions/70382479/error-library-web3-and-webpack-in-react-and-angular

from silfur.

Gizmotronn avatar Gizmotronn commented on August 29, 2024

Auth configured for smart contract!

Screen Shot 2022-02-10 at 3 33 12 pm

blockchainActions.js:

// Constants
import Web3 from "web3";
import GearToken from "../../build/contracts/GearToken.json";
//Log
//import { fetchData} from "../data/dataActions";

const connectRequest = () => {
    return {
      type: "CONNECTION_REQUEST",
    };
};
  
const connectSuccess = (payload) => {
    return {
      type: "CONNECTION_SUCCESS",
      payload: payload,
    };
};
  
const connectFailed = (payload) => {
    return {
      type: "CONNECTION_FAILED",
      payload: payload,
    };
};
  
const updateAccountRequest = (payload) => {
    return {
      type: "UPDATE_ACCOUNT",
      payload: payload,
    };
};
  
export const connect = () => {
    return async (dispatch) => {
      dispatch(connectRequest());
      if (window.ethereum) {
        let web3 = new Web3(window.ethereum);
        try {
          const accounts = await window.ethereum.request({
            method: "eth_accounts",
          });
          const networkId = await window.ethereum.request({
            method: "net_version",
          });
          console.log(networkId);
          if (networkId == 137) {
            const gearToken = new web3.eth.Contract(
                GearToken.abi,
                "0xbDE17f0284769996613652642dCab1db36Fcb54E"
            );
            dispatch(
                connectSuccess({
                    account: accounts[0],
                    gearToken: gearToken,
                    web3: web3
                })
            );
            // Add listeners start
            window.ethereum.on("accountsChanged", (accounts) => {
              dispatch(updateAccount(accounts[0]));
            });
            window.ethereum.on("chainChanged", () => {
              window.location.reload();
            });
            // Add listeners end
          } else {
            dispatch(connectFailed("Change network to Polygon."));
          }
        } catch (err) {
          dispatch(connectFailed("Something went wrong."));
        }
      } else {
        dispatch(connectFailed("Install Metamask."));
      }
    };
};
  
export const updateAccount = (account) => {
    return async (dispatch) => {
      dispatch(updateAccountRequest({ account: account }));
      //dispatch(fetchData(account));
    };
};

app.js:

import React, {useEffect} from "react";
import logo from './logo.svg';
import './App.css';
import {useDispatch, useSelector} from "react-redux";
import {connect} from "./redux/blockchain/blockchainActions";
import * as s from "./styles/globalStyles";

function App() {
  const dispatch = useDispatch();
  const blockchain = useSelector(state => state.blockchain);

  console.table(blockchain);

  useEffect(() => {
  }, [dispatch]);

  return <s.Screen>
    {blockchain.account !== "" || blockchain.gearToken !== null ? (
    <s.Container flex={1} ai={"center"} jc={"center"}>
      <s.TextTitle>
        Connect to our game
      </s.TextTitle>
      <s.SpacerSmall />
      <button onClick={(e) => {
        e.preventDefault(); // prevent default form submit
        dispatch(connect());
      }}>CONNECT</button>
    </s.Container>
    ) : (
      <s.Container ai={"center"} style={{ padding: "24px" }}>
        <s.TextTitle>
          Welcome to our game
        </s.TextTitle>
        <s.SpacerSmall />
      </s.Container>
    )}
  </s.Screen>
}

export default App;

from silfur.

Related Issues (20)

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.