Setting up contract

This commit is contained in:
Greg Shuflin 2022-12-07 20:56:39 -08:00
parent 171bf81163
commit 40f4df7c94
3 changed files with 16 additions and 4 deletions

View File

@ -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": [

View File

@ -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

View File

@ -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==