Skip to content

Json unmarshall error if contract is not verified #89

@AlexBlack772

Description

@AlexBlack772

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"
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions