Skip to content

Json unmarshall error if contract is not verified #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlexBlack772 opened this issue Mar 12, 2025 · 0 comments
Open

Json unmarshall error if contract is not verified #89

AlexBlack772 opened this issue Mar 12, 2025 · 0 comments

Comments

@AlexBlack772
Copy link

If contract is not verified and we use getsource method, etherscan returns following json

{"status":"1","message":"OK","result":[{"SourceCode":"","ABI":"Contract source code not verified","ContractName":"","CompilerVersion":"","OptimizationUsed":"","Runs":"","ConstructorArguments":"","EVMVersion":"Default","Library":"","LicenseType":"Unknown","Proxy":"0","Implementation":"","SwarmSource":"","SimilarMatch":""}]}

but etherscan-api could not decode it, and fails with an error

json unmarshal outcome: json: invalid use of ,string struct tag, trying to unmarshal "" into int

I think it happens due to following code

type ContractSource struct {
....
OptimizationUsed int json:"OptimizationUsed,string"
Runs int json:"Runs,string"
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant