nanmu42 / etherscan-api Goto Github PK
View Code? Open in Web Editor NEW:guitar: Golang client for Ethereum Etherscan API (and its families like BscScan) / Golang 以太坊 Etherscan API库(也支持同一家族的BscScan)
License: MIT License
:guitar: Golang client for Ethereum Etherscan API (and its families like BscScan) / Golang 以太坊 Etherscan API库(也支持同一家族的BscScan)
License: MIT License
They are not pass, if the code in helper.go change to:
// compose adds input to param, whose key is tag
// if input is nil, compose is a no-op.
func compose(param map[string]interface{}, tag string, input interface{}) {
if reflect.ValueOf(input).IsNil() {
return
}
param[tag] = input
}
Some test cases are outdated.
Add support for being able to retrieve an ETH Transaction Receipt (https://docs.etherscan.io/api-endpoints/geth-parity-proxy#eth_gettransactionreceipt)
There is an upstream regression causing CI failling under HTTP/2: golang/go#49366 .
A fix has been deployed at golang/go@76fbd61 , which should be included in go 1.17.4.
Etherscan API Normal Transfers json response contains also the "methodId" field
(https://docs.etherscan.io/api-endpoints/accounts#response-7)
,which is missing in NormalTx struct. I have added it in code (locally) and it works,but I guess it needs to be formal (if you want to,of course),but I don't understand too much the mechanics of pull requests and merge approvals here
I've found a bug.
[Error] json unmarshal outcome: json: cannot unmarshal number 0_0 into Go struct field InternalTx.traceId of type int
To recreate this issue
internalTX, err := etherScanClient.InternalTxByAddress(address, &startBlock, &bestBlock, 1, 0, true)
Address "0x8b7B6C61238088593BF75eEC8FBF58D0a615d30c"
where startBlock is 0 and bestBlock is the current best block of around 6.3 million
The Json returned is huge so I'll only quote the relevant node.
{
"status": "1",
"message": "OK",
"result": [
{
"blockNumber": "4244642",
"timeStamp": "1504704720",
"hash": "0x67419842db50db416b035163ccefca0a06908677f642a93063c5104d2f8dd011",
"from": "0x1522900b6dafac587d499a862861c0869be6e428",
"to": "0x8b7b6c61238088593bf75eec8fbf58d0a615d30c",
"value": "30000000000000000",
"contractAddress": "",
"input": "",
"type": "call",
"gas": "403263",
"gasUsed": "0",
"traceId": "0_0",
"isError": "1",
"errCode": "Bad instruction"
},
The InternalTx.traceId will need to be a string or the string "0_0" will need to be serialized to an int.
Which method do you prefer?
Code:
client := etherscan.NewCustomized(etherscan.Customization{
Timeout: 15 * time.Second,
Key: "2N9DPZFRMK2B9MNK17JX******", // my bscscan api key
BaseURL: "https://api.bscscan.com/api?",
Verbose: false,
})
// (optional) add hooks, e.g. for rate limit
client.BeforeRequest = func(module, action string, param map[string]interface{}) error {
return nil
}
client.AfterRequest = func(module, action string, param map[string]interface{}, outcome interface{}, requestErr error) {
// ...
}
// check account balance
balance, err := client.AccountBalance("0xb84c69a8e7b9d26ea1efd91fd99ff6d297aca415")
if err != nil {
panic(err)
}
// balance in wei, in *big.Int type
fmt.Println(balance.Int())
Result: read tcp 192.168.31.24:59215->23.92.68.154:443: wsarecv: 远程主机强迫关闭了一个现有的连接。
https://docs.etherscan.io/api-endpoints/gas-tracker
可否支持 gas-tracker 系列接口
Consider adding minimal support for https://docs.etherscan.io/api-endpoints/logs
能否提供一个查询ERC721物品的交易记录
类似下面这个 查询 tokenId=981521的所有交易记录
https://etherscan.io/token/0x06012c8cf97bead5deae237070f9587f8e7a266d?a=981521&tdsourcetag=s_pcqq_aiomsg
pull request #10
This would allow for an empty string pointer to be passed in to ERC20Transfers
resulting in the parameter of the contract address being omitted from the underlying api call.
The result being all coin transfers being returned instead of a list filtered by contract address.
I noticed that the proxy methods were not implemented and wouldn't mind contributing if you're open to a pull request.
These are what I'm referring to.
https://etherscan.io/apis#proxy
Is there anything else omitted that you're aware of?
There is an issue with error handling while using the ERC-1155 function. With err, result or any other error type the code only logs: etherscan server: NOTOK instead of providing an actual error message.
Hey all,
I am trying to use this library to get some information from the etherscan APIs specifically Income transaction to an address on the blockchain is there a way to filter these transactions or to get only these transactions using API calls?
Thanks.
etherScanClient.ERC20Transfers(&contract, &address, &startBlock, &bestBlock, 1, 0)
Address : 0xd46d54fdac2bf746dfd97d699810c3774a427b3c
Contract : 0x5eac95ad5b287cf44e058dcf694419333b796123
StartBlock : 0
BestBlock : Around 6.3 million
JSON response
{
"status": "1",
"message": "OK",
"result": [
{
"blockNumber": "5802549",
"timeStamp": "1529204204",
"hash": "0x4a9430b79d072f22bdeb553cbee94148b03b71173ceaa14c6eb317dcaf49f377",
"nonce": "9755",
"blockHash": "0x3828622f018be7635a6a42afda5725efc133ae7a3bedc122e32e7e3644deb156",
"from": "0x2881badc252165ee04c697306fea572cd19d8549",
"contractAddress": "0x5eac95ad5b287cf44e058dcf694419333b796123",
"to": "0xd46d54fdac2bf746dfd97d699810c3774a427b3c",
"value": "600000000000000000000",
"tokenName": "",
"tokenSymbol": "",
"tokenDecimal": "",
"transactionIndex": "108",
"gas": "1500000",
"gasPrice": "3000000000",
"gasUsed": "1446427",
"cumulativeGasUsed": "6025951",
"input": "0xbadcb92a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000002086ac35105260000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000e0060462c47ff9679baef07159cae08c29f274a90000000000000000000000002d03fbf63a78d0eb83873d9159d0e20a171cbbdd000000000000000000000000da0c2012be2ce446911a304db5df62e39f6a1f8a00000000000000000000000078b978a9d7e91ee529ea4fc4b76feaf8762f698c00000000000000000000000044f62f2aaabc29ad3a6b04e1ff6f9ce452d1c140000000000000000000000000889713a4c501f65e369a4ea497ea7f9af871d395000000000000000000000000d46d54fdac2bf746dfd97d699810c3774a427b3c0000000000000000000000006fa1aff85c0c9aedf387ec8a3f4e13fe8ea70cde000000000000000000000000d2a061247cbbc6bf9ac8b2d0b7a24381418ba40e000000000000000000000000714ee0584d1e88d0d9f510b5c55d3bb286a41ab00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000005bd9c36f000000000000000000000000000000000000000000000000000000005c530d6f",
"confirmations": "586769"
}
]
}
Error : "json unmarshal outcome: json: invalid use of ,string struct tag, trying to unmarshal "" into uint8"
I'll look into resolving this when I wake up. I'm guessing that the empty string should be deserialized into a 0. If you have another idea let me know.
Some contract are "TransparentUpgradeableProxy" and to know the Implementation address can be useful.
Add support for being able to query a block number with a timestamp (https://docs.etherscan.io/api-endpoints/blocks#get-block-number-by-timestamp)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.