3. Staking
Overview
The Form Component
import React, { useState } from 'react';
import { useAccount, useBalance } from 'wagmi';
export const FormComponent = ({ onSubmit }) => {
const { address } = useAccount();
const { data: balance } = useBalance({
address,
});
const [inputValue, setInputValue] = useState('');
return (
<div>
<form onSubmit={(e) => {
e.preventDefault();
onSubmit(inputValue);
setInputValue('');
}}>
<input
type="text"
placeholder="ETH amount"
onChange={(e) => setInputValue(e.target.value)}
value={inputValue}
/>
<span>ETH</span>
<div>Available to stake: {balance?.formatted} ETH</div>
<button type="submit">Submit</button>
</form>
</div>
);
};
Writing the Staking Transaction Function
Ensuring Correct Amount Format for Staking
Next Steps
Last updated
Was this helpful?