From 40f4df7c94856a6324415446d4ede74160eb27e2 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 7 Dec 2022 20:56:39 -0800 Subject: [PATCH] Setting up contract --- package.json | 4 +++- src/App.tsx | 11 +++++++++-- yarn.lock | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a8cccbe..f3a32d8 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,9 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "^5.0.1", - "web3": "^1.8.1" + "web3": "^1.8.1", + "web3-eth": "^1.8.1", + "airdrop-artifact": "file:./artifacts/contracts/Airdrop.sol/" }, "browserslist": { "production": [ diff --git a/src/App.tsx b/src/App.tsx index 985e295..1ebcfca 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,13 @@ import './App.css'; import Web3 from 'web3'; +const web3 = new Web3(Web3.givenProvider); + +import { Airdrop } from 'airdrop-artifact'; + +const airdropAddress = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"; +const airdropContract = new web3.eth.Contract(Airdrop as any, airdropAddress); + interface AddressesProps { addressList: string[]; setAddressListFn: any; @@ -17,13 +24,13 @@ function Addresses(props: AddressesProps) { const save = () => { console.log(inputState); //TODO check if correct address format - if (!Web3.utils.isAddress(inputState)) { + if (!web3.utils.isAddress(inputState)) { setErrorText("Invalid ETH address"); return; } setErrorText(""); - const checksumAddr = Web3.utils.toChecksumAddress(inputState); + const checksumAddr = web3.utils.toChecksumAddress(inputState); if (addressList.includes(checksumAddr)) { //Do nothing diff --git a/yarn.lock b/yarn.lock index 5407d17..fa39f64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3397,6 +3397,9 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" +"airdrop-artifact@file:./artifacts/contracts/Airdrop.sol": + version "0.0.0" + ajv-formats@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -13020,7 +13023,7 @@ web3-eth-personal@1.8.1: web3-net "1.8.1" web3-utils "1.8.1" -web3-eth@1.8.1: +web3-eth@1.8.1, web3-eth@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.8.1.tgz#395f6cd56edaac5dbb23e8cec9886c3fd32c430e" integrity sha512-LgyzbhFqiFRd8M8sBXoFN4ztzOnkeckl3H/9lH5ek7AdoRMhBg7tYpYRP3E5qkhd/q+yiZmcUgy1AF6NHrC1wg==