useTxFee
Props
Name
Type
Description
Return Type
Name
Type
Description
Basic Usage
import { useTx, useTxFee, formatBalance } from 'typink';
function RemarkWithFee() {
const [message, setMessage] = useState('Hello!');
const remarkTx = useTx((tx) => tx.system.remark);
const { fee, isLoading, error } = useTxFee({
tx: remarkTx,
args: [message],
enabled: message.trim().length > 0,
});
return (
<div>
<input
value={message}
onChange={(e) => setMessage(e.target.value)}
placeholder="Enter message"
/>
{isLoading && <p>Calculating fee...</p>}
{error && <p style={{ color: 'red' }}>Error: {error}</p>}
{fee && <p>Estimated Fee: {formatBalance(fee)}</p>}
<button onClick={() => remarkTx.signAndSend({ args: [message] })}>
Send Remark
</button>
</div>
);
}Last updated