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.
37 lines
1.1 KiB
37 lines
1.1 KiB
2 years ago
|
# Transfers History
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
- Create a JavaScript file `transfersHistory.js`that exports the function `transfersHistory(address, address)` that takes as parameters the address of a MinimalTokenEvent Smart Contract instance and the address of an user.
|
||
|
|
||
|
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
|
||
|
|
||
|
```js
|
||
|
const { ethers } = require("ethers");
|
||
|
|
||
|
async function transfersHistory(contractAddress, userAddress) {}
|
||
|
exports.transfersHistory = transfersHistory;
|
||
|
```
|
||
|
|
||
|
#### Usage
|
||
|
|
||
|
```js
|
||
|
const { transfersHistory } = require("./transfersHistory.sl.js");
|
||
|
|
||
|
transfersHistory(
|
||
|
"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",
|
||
|
"0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
|
||
|
);
|
||
|
/* expected:
|
||
|
[50, -25, 200, 30, -230]
|
||
|
*/
|
||
|
```
|
||
|
|
||
|
### Resources
|
||
|
|
||
|
- [solidity docs](https://docs.soliditylang.org/)
|
||
|
- [ethers](https://learnxinyminutes.com/docs/solidity/)
|
||
|
- [web3 : contracts events](https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html#contract-events)
|