Add initial alchemy structure code

This commit is contained in:
RcleydsonR
2023-01-12 00:32:52 -03:00
parent 6a4884aec9
commit aedd4bc532
9 changed files with 12886 additions and 2334 deletions

32
src/utils/alchemy.ts Normal file
View File

@@ -0,0 +1,32 @@
import { Network, Alchemy } from "alchemy-sdk";
import { useEtherStore } from "@/store/ether";
const getAlchemy = () => {
const possibleSettings = {
Ethereum: {
apiKey: import.meta.env.VITE_GOERLI_API_KEY,
network: Network.ETH_GOERLI,
},
Polygon: {
apiKey: import.meta.env.VITE_MUMBAI_API_KEY,
network: Network.MATIC_MUMBAI,
},
};
const etherStore = useEtherStore();
const settings = possibleSettings[etherStore.networkName];
const alchemy = new Alchemy(settings);
return alchemy;
};
const showLatestBlockNumber = async () => {
const alchemy = getAlchemy();
const latestBlock = await alchemy.core.getBlockNumber();
if (latestBlock) console.log(latestBlock);
};
export default {
getAlchemy,
showLatestBlockNumber,
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long