-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Once-Upon/feature/1.0.0-2
1.0.0-2
- Loading branch information
Showing
3 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,82 @@ | ||
# usability | ||
# usability | ||
|
||
Convenient data about token transfers and involved parties for Ethereum L1 and L2 transactions | ||
|
||
### Input | ||
Raw transaction data from an EVM RPC | ||
|
||
### Output | ||
Transaction objects with | ||
* a `parties` key containing an array of involved parties (addresses included in input data, logs, etc.) in the transaction. | ||
* an `assetTransfers` key containing an array of objects for all individual ETH, ERC20, ERC721, ERC1155 transfers that took place in that transaction. | ||
* a `netAssetTransfers` key containing an object with rolled up net balance change information for each address involved in the transaction, containing their net gain or loss of ETH, ERC20, ERC721, ERC1155 in that that transaction. | ||
|
||
In other words, `assetTransfers` shows everything that happened under the hood in order, and `netAssetTransfers` is a summary of the end result. | ||
|
||
### Example | ||
|
||
```typescript | ||
const inputTransaction = { | ||
to: '0xabc...123', | ||
// ... | ||
}; | ||
|
||
const outputTransaction = { | ||
to: '0xabc...123', | ||
// ... | ||
parties: [ | ||
"0x662127bf82b794a26b7ddb6b495f6a5a20b81738", | ||
"0x2d660d49473dbbcaf63929d10d0e3501b4533182", | ||
"0x8ca5e648c5dfefcdda06d627f4b490b719ccfd98", | ||
// ... | ||
], | ||
assetTransfers: [ | ||
{ | ||
"contract": "0x2d660d49473dbbcaf63929d10d0e3501b4533182", | ||
"from": "0x0000000000000000000000000000000000000000", | ||
"to": "0x662127bf82b794a26b7ddb6b495f6a5a20b81738", | ||
"tokenId": "610", | ||
"type": "erc721" | ||
}, | ||
// .. | ||
], | ||
netAssetTransfers: { | ||
"0x662127bf82b794a26b7ddb6b495f6a5a20b81738": { | ||
"received": [ | ||
{ | ||
"contract": "0x2d660d49473dbbcaf63929d10d0e3501b4533182", | ||
"tokenId": "610", | ||
"type": "erc721" | ||
} | ||
], | ||
"sent": [ | ||
{ | ||
"asset": "eth", | ||
"id": "eth", | ||
"type": "eth", | ||
"value": "100777000000000000" | ||
} | ||
] | ||
}, | ||
// .. | ||
}, | ||
}; | ||
``` | ||
|
||
### Tests | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
### Contributing | ||
|
||
Please open a PR on this repo and request review from [pcowgill](https://github.com/pcowgill) and [jordanmessina](https://github.com/jordanmessina) | ||
|
||
### Other resources | ||
|
||
For additional decoration of transaction objects with more context, this library can be used in combination with [@once-upon/evm-context](https://github.com/Once-Upon/context). | ||
|
||
## License | ||
|
||
See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters