Comments (12)
Unlike the other worker issues, this is NOT covered by indexer in #162.
from blockscout.
@acravenho I can't find getPastEvents
in https://github.com/ethereum/web3.js to determine which JSONRPC method that is using. Is it just a way of interpreting getPastLogs
's data, in which case the logs
table has the data already, or is it different?
from blockscout.
@KronicDeth We are already storing all the information we need to obtain the token transfer information.
Here is an example of a token transfer: https://etherscan.io/tx/0x3f51128311e0000d108ae83b1a5cc470d404fffe5d6eade307897ed6cf90bb25#eventlog
The first argument: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
stands for a token transfer. This is always the same.
The second argument: 0x0000000000000000000000009a4a90e2732f3fa4087b0bb4bf85c76d14833df1
is the from address
The third argument: 0x000000000000000000000000f0967af4b05014ddd3add8ef39848a06aa502fff
is the to address.
The data
field is the hex value of the amount of the token transfer.
In the parent transaction, the to
field is the contract we are interacting with. If we do not have information on this token, we need to query the ABI
to obtain the total supply
, token name
, token symbol
and decimals
, then store the information for future transfers from that token contract.
Here is how I am indexing token transfers. As we are indexing, if we see an event beginning with 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
, we should check the DB for token info. If the token info does not exist, we query the ABI to fetch the token info. Once we have the token info we store the transfer to
, from
, amount
, and block
.
from blockscout.
Why does 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
mean token transfer? Where is that defined? Is it the call encoding of a function everyone uses for token transfers? I'd prefer to be able to link to so other projects source or a white paper saying that value means token transfer than have a magic constant.
So, we do need separate token table to store total supply
, token name
, token symbol
and decimals
and it probably needs to work with @alexgaribay's market information for converting to USD.
from blockscout.
The first topic in the array is the sha3 hash of the hexadecimal representation of the canonical signature of the event. The remaining items in the topics array (there may be up to three) are the hexadecimal values of the indexed parameters to the event. The event's remaining parameters (non-indexed) are stored in the 'data' field of the log.
For example, the ERC20 token Transfer event, which is defined as
Transfer(address indexed _from, address indexed _to, uint256 _value)
https://ethereum.stackexchange.com/questions/12553/understanding-logs-and-log-blooms
from blockscout.
Are the topics always sha3 hashes and 32-bytes long when present? If so, we'll need to change the column type from :string
to :bytea
and the schema type to Explorer.Chain.Hash.Full
. If only the first_topic
is guaranteed to be a sha3 hash, then that one should be changed and we'll have to leave the others as :string
.
from blockscout.
@acravenho What information do we want to gather about the token? I'm guessing at least name
and symbol
?
from blockscout.
@alexgaribay We want to capture the following:
- name
- symbol
- total supply
- decimals
- owner
- contract address
from blockscout.
@acravenho We already cache some information about tokens by hitting CoinMarketCap's API. total_supply
is an available field but we don't currently hold it. Would you rather that value be stored from the API or in a table holding the attributes you listed?
from blockscout.
@alexgaribay I'm not sure the best place to hold them. I believe CMC is only storing just a small number of the total 20k+ tokens. It would seem that creating a table might be a better way to go.
from blockscout.
I think I may have made that unclear. There will be tokens
table that holds some information needed for token transfers. Additionally, the there will also be some cached information about tokens related to exchange rates and supply. total_supply
can come from two sources; the contract call from web3 or from CMC. Seeing as how total supply can change, at least with POA, it makes more sense to me to not store that value in the new tokens
table and add token_supply
as a field we capture from CMC.
from blockscout.
I think we should be reading the smart contract. This is the most accurate data possible. The POA ERC20 token contract is an edge case because it updates based on the burn and minting of tokens when someone uses the bridge.
The idea behind this table would be to populate a page like this from Etherscan: https://etherscan.io/token/0xc528c28fec0a90c083328bc45f587ee215760a0f
from blockscout.
Related Issues (20)
- no function clause matching in Explorer.Chain.Address.MetadataPreloader.alter_address/4
- cant put compiler version HOT 1
- Fix 400 on logs csv from frontend v2
- Did not receive ETH in Binance sent from Metamask. HOT 1
- Funds send from wrong network HOT 2
- I sent $10 to the wrong network. I want to cancel the transaction HOT 1
- Fix `GAS_PRICE_ORACLE_NUM_OF_BLOCKS` processing
- I didn’t get my amount in my Binance account HOT 1
- .
- Add Optimism Plasma support for batch indexer HOT 1
- State changes not correct when there are internal transactions HOT 1
- Internal transactions not handled HOT 1
- Store smart-contract proxy types in the DB
- Research specific client API endpoints in order to speed up fetching of on-chain data HOT 1
- Readme Link is down HOT 2
- Block catch up failed with response too large HOT 1
- No contract names on token/token-transfers tab
- Support Diamond proxy smart-contracts
- I traded on runechain in the rsic-genesis token, my tokens disappeared HOT 1
- Transaction not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockscout.