Set up contract in dapp
This commit is contained in:
parent
40f4df7c94
commit
c5749e11d0
105
src/Airdrop.json
Normal file
105
src/Airdrop.json
Normal file
File diff suppressed because one or more lines are too long
17
src/App.tsx
17
src/App.tsx
@ -6,10 +6,10 @@ import Web3 from 'web3';
|
||||
|
||||
const web3 = new Web3(Web3.givenProvider);
|
||||
|
||||
import { Airdrop } from 'airdrop-artifact';
|
||||
import Airdrop from "./Airdrop.json";
|
||||
|
||||
const airdropAddress = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512";
|
||||
const airdropContract = new web3.eth.Contract(Airdrop as any, airdropAddress);
|
||||
const airdropContract = new web3.eth.Contract(Airdrop.abi as any, airdropAddress);
|
||||
|
||||
interface AddressesProps {
|
||||
addressList: string[];
|
||||
@ -19,11 +19,10 @@ interface AddressesProps {
|
||||
function Addresses(props: AddressesProps) {
|
||||
const [inputState, setInputState] = useState("");
|
||||
const [errorText, setErrorText] = useState("");
|
||||
const [numTokens, setNumTokens] = useState(0);
|
||||
const { setAddressListFn, addressList } = props;
|
||||
|
||||
const save = () => {
|
||||
console.log(inputState);
|
||||
//TODO check if correct address format
|
||||
if (!web3.utils.isAddress(inputState)) {
|
||||
setErrorText("Invalid ETH address");
|
||||
return;
|
||||
@ -39,12 +38,22 @@ function Addresses(props: AddressesProps) {
|
||||
}
|
||||
setInputState("");
|
||||
}
|
||||
|
||||
const num = isNaN(numTokens) ? 0 : numTokens;
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<input id="address" value={inputState} onChange={ (evt) => setInputState(evt.target.value) } ></input>
|
||||
<div className="addressError">{errorText}</div>
|
||||
<button onClick={save}>Add address</button>
|
||||
</div>
|
||||
<div>
|
||||
Number of tokens:
|
||||
<input type="numeric" value={num} onChange={ (evt) => setNumTokens(parseInt(evt.target.value)) }></input>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user