Comments (5)
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.
https://skinetics.notion.site/Unity-Rest-API-e5f22d05e0d5418fa3b9b55e457e2767
from silfur.
#7 ->
from silfur.
https://stackoverflow.com/questions/70382479/error-library-web3-and-webpack-in-react-and-angular
from silfur.
Auth configured for smart contract!
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)
- Fix issue with "change network to polygon" on `game-redo` branch
- [HDASH-4] Repeat issue
- π©Έπ -> [HDASH-4 , HDASH-5]: Add flask environment that communicates with React applets HOT 1
- π§ͺπ¨ β£ Extend DAO to support multiple input methods
- Improve voting token mint experience on frontend
- Medium Clone
- Take user inputs for minting via Flask API
- Migrate Proposal board from Vite to Next.js
- π«₯π¬ β Interacting with anomalies from smart contract
- Add CreatePost lib component HOT 3
- Create method to stake your planets to earn reward ERC20s
- Implement off-chain "commenting" post system for users
- Migrate offchain auth to `useSession` from `useUser`
- Add Lens graphql client to offchain directory
- Create new Linear team
- π¦π β Generate asset, ID & stats/elements for anomalies when being claimed HOT 1
- Add voting mechanism for anomaly discussion
- Fix build errors originating from new governance actions
- ππ β Statements for each table schema HOT 1
- π¦π β Inventory schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silfur.