
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: whatâs affected and how to update safely.
use-wait-for-transaction-hash
Advanced tools
Simple hook for getting transaction status from the ETH network.
yarn add use-wait-for-transaction-hash
Simple usage with Notify component
import { useWaitForTransactionHash } from 'use-wait-for-transaction-hash';
interface Props {
providerUrl: string;
transactionHash: string;
}
function Notify({ providerUrl, transactionHash }: Props) {
const { status } = useWaitForTransactionHash({
hash: transactionHash,
providerUrl,
});
return (
<div>
<pre>Hash: {transactionHash}</pre>
<pre>Provider Url: {providerUrl}</pre>
<pre>Status: {status}</pre>
</div>
);
}
function App() {
const [toggle, setToggle] = useState(false);
return (
<div className="App">
<header className="App-header">
<button onClick={() => (toggle ? setToggle(false) : setToggle(true))}>
Toggle the transaction hash
</button>
<Notify
providerUrl="https://data-seed-prebsc-1-s1.binance.org:8545"
transactionHash={
toggle
? '0x5fbc777b0c99e84b8a3f1c750ae4d1cdaa5f8f852da892897f6b9cf0ea2f59b5'
: '0x35403cfc33cababac41ad998dff9038c57945ac7cbe9f22e5bdfbf89a8756bd7'
}
/>
</header>
</div>
);
}
For more detail, please check the example app (example folder),
import { useEffect } from 'react';
import { useWaitForTransactionHash } from 'use-wait-for-transaction-hash';
import toast, { Toaster } from 'react-hot-toast';
function Notify({ providerUrl, transactionHash }: Props) {
const { status } = useWaitForTransactionHash({
hash: transactionHash,
providerUrl,
});
// measure performance base on the transaction status
useEffect(() => {
switch (status) {
case 'SUCCESS':
toast.success('This is a success transaction');
break;
case 'FAILED':
toast.error('This is a failed transaction');
break;
default: // PENDING
}
}, [status]);
// clear previous toast message and show checking information
useEffect(() => {
toast.dismiss();
toast.loading('Checking...' + transactionHash);
}, [transactionHash]);
return (
<div>
<pre>Hash: {transactionHash}</pre>
<pre>Provider Url: {providerUrl}</pre>
<pre>Status: {status}</pre>
</div>
);
}
function App() {
return (
<div className="App">
<Notify
providerUrl="https://data-seed-prebsc-1-s1.binance.org:8545"
transactionHash="0x5fbc777b0c99e84b8a3f1c750ae4d1cdaa5f8f852da892897f6b9cf0ea2f59b5"
/>
<Toaster position="top-right" />
</div>
);
}
yarn test
đ¤ Huynh Duc Dung
Give a âď¸ if this project helped you!

This README was generated with â¤ď¸ by readme-md-generator
FAQs
Typescript starter project
We found that use-wait-for-transaction-hash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: whatâs affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.