Language : typescript
const [transactions, setTransactions] = useState([]);
useEffect(() => {
const fetchTransactions = async () => {
// ropsten eth rinkeby
const data = await Web3API.account.getTransactions({
chain: chainId,
address: account,
limit: 5,
});
if (data) {
setTransactions(data.result);
}
};
setTimeout(() => {
fetchTransactions();
}, 3000);
}, [Web3API.account, account, chainId, user]);
I fixed with below method, any guy has better one?
type TranType =
| {
hash: string;
nonce: string;
transaction_index: string;
from_address: string;
to_address: string;
value: string;
gas: string;
gas_price: string;
input: string;
receipt_cumulative_gas_used: string;
receipt_gas_used: string;
receipt_contract_address: string;
receipt_root: string;
receipt_status: string;
block_timestamp: string;
block_number: string;
block_hash: string;
}[]
| undefined;
const [transactions, setTransactions] = useState<TranType>();
setTransactions(data.result);