forked from ShreyaVishesh/P2P_Express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interaction.js
38 lines (29 loc) · 1.01 KB
/
Interaction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {React, useState, useEffect} from 'react'
import {ethers} from 'ethers'
import styles from './Wallet.module.css'
const Interactions = (props) => {
const [transferHash, setTransferHash] = useState(null);
const transferHandler = async (e) => {
e.preventDefault();
let transferAmount = e.target.sendAmount.value;
let recieverAddress = e.target.recieverAddress.value;
let txt = await props.contract.transfer(recieverAddress, transferAmount);
setTransferHash(txt.hash);
}
return (
<div className={styles.interactionsCard}>
<form onSubmit={transferHandler}>
<h3> Transfer Units </h3>
<p> Seller's Address </p>
<input type='text' id='recieverAddress' className={styles.addressInput}/>
<p> Send Amount </p>
<input type='number' id='sendAmount' min='0' step='1'/>
<button type='submit' className={styles.button6}>Send</button>
<div>
{transferHash}
</div>
</form>
</div>
)
}
export default Interactions;