Skip to content

Commit

Permalink
Functionality added
Browse files Browse the repository at this point in the history
  • Loading branch information
harshal2608 committed Dec 18, 2021
1 parent a197f12 commit d0f0ca8
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import { ethers } from "ethers";
import React, { useEffect, useState } from "react";
// import { ethers } from "ethers";
import "./App.css";
import abi from "./utils/WavePortal.json";

export default function App() {
const [currentAccount, setCurrentAccount] = useState("");
const contractAddress = "0x61c9e0c1c4d0a744a8f62c88674e7642a7cebb62";
const contractABI = abi.abi;

const wave = () => {};
const wave = async () => {
try {
const { ethereum } = window;

if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum);
const singer = provider.getSigner();
const wavePortalContract = new ethers.Contract(
contractAddress,
contractABI,
singer
);

let count = await wavePortalContract.getTotalWaves();
console.log("Retrived total wave count...", count.toNumber());

const waveTxn = await wavePortalContract.wave();
console.log("Mining...", waveTxn.hash);

await waveTxn.wait();
console.log("Mined --", waveTxn.hash);

count = await wavePortalContract.getTotalWaves();
console.log("Retrieved total wave count...", count.toNumber());
} else {
console.log("Ethereum OBject doesn;t exist");
}
} catch (error) {
console.log(error);
}
};

const checkIfWalletIsConnected = async () => {
try {
Expand Down Expand Up @@ -54,6 +87,7 @@ export default function App() {
useEffect(() => {
checkIfWalletIsConnected();
}, []);

return (
<div className="mainContainer">
<div className="dataContainer">
Expand Down
36 changes: 36 additions & 0 deletions src/utils/WavePortal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "WavePortal",
"sourceName": "contracts/WavePortal.sol",
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "getTotalWaves",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "wave",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5061003c6040518060600160405280602581526020016107206025913961004160201b6101081760201c565b6101c4565b6100dd816040516024016100559190610142565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506100e060201b60201c565b50565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b600061011482610164565b61011e818561016f565b935061012e818560208601610180565b610137816101b3565b840191505092915050565b6000602082019050818103600083015261015c8184610109565b905092915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561019e578082015181840152602081019050610183565b838111156101ad576000848401525b50505050565b6000601f19601f8301169050919050565b61054d806101d36000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636fe15b441461003b5780639a2cdc0814610045575b600080fd5b610043610063565b005b61004d6100bd565b60405161005a91906103db565b60405180910390f35b60016000808282546100759190610412565b925050819055506100bb6040518060400160405280600d81526020017f2573206861732077617665642100000000000000000000000000000000000000815250336101a1565b565b60006101006040518060400160405280601781526020017f5765206861766520256420746f74616c2077617665732100000000000000000081525060005461023d565b600054905090565b61019e8160405160240161011c9190610359565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b50565b61023982826040516024016101b792919061037b565b6040516020818303038152906040527f319af333000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b5050565b6102d582826040516024016102539291906103ab565b6040516020818303038152906040527f9710a9d0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b5050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b61030b81610468565b82525050565b600061031c826103f6565b6103268185610401565b93506103368185602086016104a4565b61033f81610506565b840191505092915050565b6103538161049a565b82525050565b600060208201905081810360008301526103738184610311565b905092915050565b600060408201905081810360008301526103958185610311565b90506103a46020830184610302565b9392505050565b600060408201905081810360008301526103c58185610311565b90506103d4602083018461034a565b9392505050565b60006020820190506103f0600083018461034a565b92915050565b600081519050919050565b600082825260208201905092915050565b600061041d8261049a565b91506104288361049a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561045d5761045c6104d7565b5b828201905092915050565b60006104738261047a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156104c25780820151818401526020810190506104a7565b838111156104d1576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000601f19601f830116905091905056fea26469706673582212209ef84f8b3eabbbee851deef84f6974451aa1208d8f593c7f20d32492644b488164736f6c63430008000033596f20796f2c204920616d206120636f6e747261637420616e64204920616d20736d617274",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636fe15b441461003b5780639a2cdc0814610045575b600080fd5b610043610063565b005b61004d6100bd565b60405161005a91906103db565b60405180910390f35b60016000808282546100759190610412565b925050819055506100bb6040518060400160405280600d81526020017f2573206861732077617665642100000000000000000000000000000000000000815250336101a1565b565b60006101006040518060400160405280601781526020017f5765206861766520256420746f74616c2077617665732100000000000000000081525060005461023d565b600054905090565b61019e8160405160240161011c9190610359565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b50565b61023982826040516024016101b792919061037b565b6040516020818303038152906040527f319af333000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b5050565b6102d582826040516024016102539291906103ab565b6040516020818303038152906040527f9710a9d0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506102d9565b5050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b61030b81610468565b82525050565b600061031c826103f6565b6103268185610401565b93506103368185602086016104a4565b61033f81610506565b840191505092915050565b6103538161049a565b82525050565b600060208201905081810360008301526103738184610311565b905092915050565b600060408201905081810360008301526103958185610311565b90506103a46020830184610302565b9392505050565b600060408201905081810360008301526103c58185610311565b90506103d4602083018461034a565b9392505050565b60006020820190506103f0600083018461034a565b92915050565b600081519050919050565b600082825260208201905092915050565b600061041d8261049a565b91506104288361049a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561045d5761045c6104d7565b5b828201905092915050565b60006104738261047a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156104c25780820151818401526020810190506104a7565b838111156104d1576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000601f19601f830116905091905056fea26469706673582212209ef84f8b3eabbbee851deef84f6974451aa1208d8f593c7f20d32492644b488164736f6c63430008000033",
"linkReferences": {},
"deployedLinkReferences": {}
}

0 comments on commit d0f0ca8

Please sign in to comment.