diff --git a/src/Airdrop.json b/src/Airdrop.json new file mode 100644 index 0000000..3810c46 --- /dev/null +++ b/src/Airdrop.json @@ -0,0 +1,105 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "Airdrop", + "sourceName": "contracts/Airdrop.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amount", + "type": "uint256[]" + } + ], + "name": "airdropTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50604051610d0c380380610d0c833981810160405281019061003291906101c4565b61004e61004361009560201b60201c565b61009d60201b60201c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101f1565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061019182610166565b9050919050565b6101a181610186565b81146101ac57600080fd5b50565b6000815190506101be81610198565b92915050565b6000602082840312156101da576101d9610161565b5b60006101e8848285016101af565b91505092915050565b610b0c806102006000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063706f69371461005c578063715018a6146100785780638da5cb5b14610082578063f2fde38b146100a0578063fc0c546a146100bc575b600080fd5b61007660048036038101906100719190610715565b6100da565b005b610080610221565b005b61008a610235565b604051610097919061079c565b60405180910390f35b6100ba60048036038101906100b591906107b7565b61025e565b005b6100c46102e1565b6040516100d1919061079c565b60405180910390f35b6100e2610307565b8051825114610126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011d90610867565b60405180910390fd5b60005b825181101561021c57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3385848151811061018457610183610887565b5b602002602001015185858151811061019f5761019e610887565b5b60200260200101516040518463ffffffff1660e01b81526004016101c5939291906108c5565b6020604051808303816000875af11580156101e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102089190610934565b50808061021490610990565b915050610129565b505050565b610229610307565b6102336000610385565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610266610307565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102cc90610a4a565b60405180910390fd5b6102de81610385565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61030f610449565b73ffffffffffffffffffffffffffffffffffffffff1661032d610235565b73ffffffffffffffffffffffffffffffffffffffff1614610383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037a90610ab6565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6104b38261046a565b810181811067ffffffffffffffff821117156104d2576104d161047b565b5b80604052505050565b60006104e5610451565b90506104f182826104aa565b919050565b600067ffffffffffffffff8211156105115761051061047b565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061055282610527565b9050919050565b61056281610547565b811461056d57600080fd5b50565b60008135905061057f81610559565b92915050565b6000610598610593846104f6565b6104db565b905080838252602082019050602084028301858111156105bb576105ba610522565b5b835b818110156105e457806105d08882610570565b8452602084019350506020810190506105bd565b5050509392505050565b600082601f83011261060357610602610465565b5b8135610613848260208601610585565b91505092915050565b600067ffffffffffffffff8211156106375761063661047b565b5b602082029050602081019050919050565b6000819050919050565b61065b81610648565b811461066657600080fd5b50565b60008135905061067881610652565b92915050565b600061069161068c8461061c565b6104db565b905080838252602082019050602084028301858111156106b4576106b3610522565b5b835b818110156106dd57806106c98882610669565b8452602084019350506020810190506106b6565b5050509392505050565b600082601f8301126106fc576106fb610465565b5b813561070c84826020860161067e565b91505092915050565b6000806040838503121561072c5761072b61045b565b5b600083013567ffffffffffffffff81111561074a57610749610460565b5b610756858286016105ee565b925050602083013567ffffffffffffffff81111561077757610776610460565b5b610783858286016106e7565b9150509250929050565b61079681610547565b82525050565b60006020820190506107b1600083018461078d565b92915050565b6000602082840312156107cd576107cc61045b565b5b60006107db84828501610570565b91505092915050565b600082825260208201905092915050565b7f41697264726f703a20526563697069656e747320616e6420616d6f756e74206c60008201527f656e677468206d69736d61746368000000000000000000000000000000000000602082015250565b6000610851602e836107e4565b915061085c826107f5565b604082019050919050565b6000602082019050818103600083015261088081610844565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6108bf81610648565b82525050565b60006060820190506108da600083018661078d565b6108e7602083018561078d565b6108f460408301846108b6565b949350505050565b60008115159050919050565b610911816108fc565b811461091c57600080fd5b50565b60008151905061092e81610908565b92915050565b60006020828403121561094a5761094961045b565b5b60006109588482850161091f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061099b82610648565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036109cd576109cc610961565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610a346026836107e4565b9150610a3f826109d8565b604082019050919050565b60006020820190508181036000830152610a6381610a27565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610aa06020836107e4565b9150610aab82610a6a565b602082019050919050565b60006020820190508181036000830152610acf81610a93565b905091905056fea2646970667358221220261310b693ac62fe08916b20836cb9b54e3ed0e07f41c2f4b2ef06ce66681e2764736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063706f69371461005c578063715018a6146100785780638da5cb5b14610082578063f2fde38b146100a0578063fc0c546a146100bc575b600080fd5b61007660048036038101906100719190610715565b6100da565b005b610080610221565b005b61008a610235565b604051610097919061079c565b60405180910390f35b6100ba60048036038101906100b591906107b7565b61025e565b005b6100c46102e1565b6040516100d1919061079c565b60405180910390f35b6100e2610307565b8051825114610126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011d90610867565b60405180910390fd5b60005b825181101561021c57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3385848151811061018457610183610887565b5b602002602001015185858151811061019f5761019e610887565b5b60200260200101516040518463ffffffff1660e01b81526004016101c5939291906108c5565b6020604051808303816000875af11580156101e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102089190610934565b50808061021490610990565b915050610129565b505050565b610229610307565b6102336000610385565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610266610307565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102cc90610a4a565b60405180910390fd5b6102de81610385565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61030f610449565b73ffffffffffffffffffffffffffffffffffffffff1661032d610235565b73ffffffffffffffffffffffffffffffffffffffff1614610383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037a90610ab6565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6104b38261046a565b810181811067ffffffffffffffff821117156104d2576104d161047b565b5b80604052505050565b60006104e5610451565b90506104f182826104aa565b919050565b600067ffffffffffffffff8211156105115761051061047b565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061055282610527565b9050919050565b61056281610547565b811461056d57600080fd5b50565b60008135905061057f81610559565b92915050565b6000610598610593846104f6565b6104db565b905080838252602082019050602084028301858111156105bb576105ba610522565b5b835b818110156105e457806105d08882610570565b8452602084019350506020810190506105bd565b5050509392505050565b600082601f83011261060357610602610465565b5b8135610613848260208601610585565b91505092915050565b600067ffffffffffffffff8211156106375761063661047b565b5b602082029050602081019050919050565b6000819050919050565b61065b81610648565b811461066657600080fd5b50565b60008135905061067881610652565b92915050565b600061069161068c8461061c565b6104db565b905080838252602082019050602084028301858111156106b4576106b3610522565b5b835b818110156106dd57806106c98882610669565b8452602084019350506020810190506106b6565b5050509392505050565b600082601f8301126106fc576106fb610465565b5b813561070c84826020860161067e565b91505092915050565b6000806040838503121561072c5761072b61045b565b5b600083013567ffffffffffffffff81111561074a57610749610460565b5b610756858286016105ee565b925050602083013567ffffffffffffffff81111561077757610776610460565b5b610783858286016106e7565b9150509250929050565b61079681610547565b82525050565b60006020820190506107b1600083018461078d565b92915050565b6000602082840312156107cd576107cc61045b565b5b60006107db84828501610570565b91505092915050565b600082825260208201905092915050565b7f41697264726f703a20526563697069656e747320616e6420616d6f756e74206c60008201527f656e677468206d69736d61746368000000000000000000000000000000000000602082015250565b6000610851602e836107e4565b915061085c826107f5565b604082019050919050565b6000602082019050818103600083015261088081610844565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6108bf81610648565b82525050565b60006060820190506108da600083018661078d565b6108e7602083018561078d565b6108f460408301846108b6565b949350505050565b60008115159050919050565b610911816108fc565b811461091c57600080fd5b50565b60008151905061092e81610908565b92915050565b60006020828403121561094a5761094961045b565b5b60006109588482850161091f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061099b82610648565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036109cd576109cc610961565b5b600182019050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610a346026836107e4565b9150610a3f826109d8565b604082019050919050565b60006020820190508181036000830152610a6381610a27565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610aa06020836107e4565b9150610aab82610a6a565b602082019050919050565b60006020820190508181036000830152610acf81610a93565b905091905056fea2646970667358221220261310b693ac62fe08916b20836cb9b54e3ed0e07f41c2f4b2ef06ce66681e2764736f6c63430008110033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/src/App.tsx b/src/App.tsx index 1ebcfca..c1c205b 100644 --- a/src/App.tsx +++ b/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,13 +38,23 @@ function Addresses(props: AddressesProps) { } setInputState(""); } + + const num = isNaN(numTokens) ? 0 : numTokens; + + return ( -