nanmu42 / etherscan-api

:guitar: Golang client for Ethereum Etherscan API (and its families like BscScan) / Golang 以太坊 Etherscan API库(也支持同一家族的BscScan)
MIT License
240 stars 107 forks source link

Error handling ERC-1155 #76

Open rpcerror opened 1 year ago

rpcerror commented 1 year ago

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.

nanmu42 commented 1 year ago

Yes, collecting the result field into error messages would be an improvement.

As a quick walkaround, try enabling verbose mode to see the full response.

https://github.com/nanmu42/etherscan-api/blob/74c513586453640037774b7947f605d14ce7b625/client.go#L147

rpcerror commented 1 year ago

This worked, thank you. However looking at the API response and reading current etherscan docs It seems like they have removed the erc-1155 token check functrion completely, or I must be blind as I cant find it: https://docs.etherscan.io/api-endpoints/tokens

Or maybe I am doing something wrong in my code? The error I get: {"status":"0","message":"NOTOK","result":"Error! Missing Or invalid Action name"}

nanmu42 commented 1 year ago

Is this what you are looking for?

https://docs.etherscan.io/api-endpoints/accounts#get-a-list-of-erc1155-token-transfer-events-by-address

rpcerror commented 1 year ago

Yes, this is right. Something must be not right though, the request I am sending should be 100% good according to their API docs, here it is:

GET /api?action=token1155tx&address=

&apikey=&contractaddress=&module=account&offset=10000&page=1&sort=asc

but I get this error:

{"status":"0","message":"NOTOK","result":"Error! Missing Or invalid Action name"}

Do you know what might be the issue?

nanmu42 commented 1 year ago

This is odd.

Does this endpoint need a paid plan or something?

rpcerror commented 1 year ago

No, it does not. 1155 transfers function is included in the free plan based on etherscan API docs. What the issue might be related to then?

rpcerror commented 1 year ago

I have just messaged etherscan on email, and they claim everything is fine on their end. Here's the reply: image

Could you please run the request too and check if it returns an error on your side?

rpcerror commented 1 year ago

And let me tell you, it works fine for me via browser. image

Looking forward to you reply