uniblock
A nodejs module for extracting relevant uniswap
transactions and event logs for a specific ethereum
block.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Installing
Install:
npm install uniblock
or if you want to develop locally:
git clone [path to repo]
cd uniblock
npm install
Using
Run example:
npm start
Use it:
const Uniblock = require('uniblock')
(async () => {
const uniblock = new Uniblock()
const block = await uniblock.createUniblock(9199989)
debug(`uniblock ${block.number} succesfully created`)
})()
//returns:
{
number: 9199989,
events: [
{
blockNumber: 9199989,
blockHash: '0xe47bcfa6ab18c397ab7c941d317fe869830748ef04a3a57f76bdcca6176ebaee',
transactionIndex: 1,
removed: false,
address: '0x3958B4eC427F8fa24eB60F42821760e88d485f7F',
data: '0x',
topics: [Array],
transactionHash: '0xff6834ebc18472379f2c885509d96a6cafd849ce42f1026b231d45b4c0b47ba0',
logIndex: 2
}
],
transactions: [
'0xff6834ebc18472379f2c885509d96a6cafd849ce42f1026b231d45b4c0b47ba0'
],
parsed: [
_LogDescription {
decode: [Function],
name: 'EthPurchase',
signature: 'EthPurchase(address,uint256,uint256)',
topic: '0x7f4091b46c33e918a0f3aa42307641d17bb67029427a5369e54b353984238705',
values: [Result]
}
]
}
uniblock.createUniblock
uniblock.createUniblock(blockNumber, extendedBlock, skipFetch)
If extendedBlock
param is true, the returned uniblock
will have additional fields available:
# note the uniblock.extended.events and uniblock.extended.transactions
{
number: 9199989,
events: ...
transactions: ...,
parsed: ...,
extended: {
events: [
{
blockNumber: 9199989,
blockHash: '0xe47bcfa6ab18c397ab7c941d317fe869830748ef04a3a57f76bdcca6176ebaee',
transactionIndex: 1,
removed: false,
address: '0xC011A72400E58ecD99Ee497CF89E3775d4bd732F',
data: '0x00000000000000000000000000000000000000000000000b093bf3e47be49a1f',
topics: [Array],
transactionHash: '0xff6834ebc18472379f2c885509d96a6cafd849ce42f1026b231d45b4c0b47ba0',
logIndex: 1
},
{
blockNumber: 9199989,
blockHash: '0xe47bcfa6ab18c397ab7c941d317fe869830748ef04a3a57f76bdcca6176ebaee',
transactionIndex: 1,
removed: false,
address: '0x3958B4eC427F8fa24eB60F42821760e88d485f7F',
data: '0x',
topics: [Array],
transactionHash: '0xff6834ebc18472379f2c885509d96a6cafd849ce42f1026b231d45b4c0b47ba0',
logIndex: 2
}
],
transactions: [
{
hash: '0xff6834ebc18472379f2c885509d96a6cafd849ce42f1026b231d45b4c0b47ba0',
blockHash: '0xe47bcfa6ab18c397ab7c941d317fe869830748ef04a3a57f76bdcca6176ebaee',
blockNumber: 9199989,
transactionIndex: 1,
confirmations: 2393,
from: '0xEF422dBBF46120dE627fFb913C9AFaD44c735618',
gasPrice: [BigNumber],
gasLimit: [BigNumber],
to: '0x3958B4eC427F8fa24eB60F42821760e88d485f7F',
value: [BigNumber],
nonce: 3458,
data: '0x013efd8b0000000000000000000000000000000000000000000000001a28dd83499c800000000000000000000000000000000000000000000000000c59edd658bdc68000000000000000000000000000000000000000000000000000000000005e0dab8b',
r: '0x2973982031c5ef3e4e2d9dc78ca30582b24fa3556805da56668328afecb1abf1',
s: '0x158704dfd278a42a4e2e6b0b66e41d70de2f89d99ef20364207e6c0c924af58f',
v: 37,
creates: null,
raw: '0xf8cc820d82850ba43b740083030d40943958b4ec427f8fa24eb60f42821760e88d485f7f80b864013efd8b0000000000000000000000000000000000000000000000001a28dd83499c800000000000000000000000000000000000000000000000000c59edd658bdc68000000000000000000000000000000000000000000000000000000000005e0dab8b25a02973982031c5ef3e4e2d9dc78ca30582b24fa3556805da56668328afecb1abf1a0158704dfd278a42a4e2e6b0b66e41d70de2f89d99ef20364207e6c0c924af58f',
networkId: 1,
wait: [Function]
}
]
}
If skipFetch
is true, the uniblock
will not fetch for newly created exchanges before creating uniblock
response.
uniblock.exchanges
You can list current known exchanges:
console.log(uniblock.exchanges)
uniblock.isKnownExchange
To check if an address is a known exchange you can use:
console.log(uniblock.isKnownExchange('0x4839f54EB79a4D2f984D8769805faCACdD017e80')) //true
Tests
TO DO
Standard
If standard.js is complaining about code formmating/style you can try to run:
npm run standard:fix
Debug
uniblock
is using the debug
module, set DEBUG environment variable to see the logs:
export DEBUG=uniblock:*
Built With
Contributing
Please raise an issue, or open a PR.
License
MIT License
Copyright (c) 2019 Nikola Jokić, Filip Lasić
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.