mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.1 KiB
1.1 KiB
Transfers History
Instructions
- Create a JavaScript file
transfersHistory.js
that exports the functiontransfersHistory(address, address)
that takes as parameters the address of aEventfulToken
Smart Contract instance and the address of an user.
The function will connect to a local node and retrieve the events. It returns an array with all the transfers from that account, starting from the most recent, positive if it is toward the user, and negative if it is outside.
Structure
const { ethers } = require("ethers");
async function transfersHistory(contractAddress, userAddress) {...}
exports.transfersHistory = transfersHistory;
Usage
const { transfersHistory } = require("./transfersHistory.js");
transfersHistory(
"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
);
/* expected:
[50, -25, 200, 30, -230]
*/