Git Product home page Git Product logo

Comments (7)

rkalis avatar rkalis commented on September 3, 2024 1

Hey @mrwillis, I must have completely missed the notification for this issue, apologies!

One thing I noticed is that the flattened code contains two SPDX license identifiers, which is currently not working (see comments in #27). After removing it, the code still doesn't seem to be verifying correctly. After updating the Solidity version to v0.6.11 like you mentioned before and moving the experimental pragma one line up, it now verifies correctly. I'm not sure what the cause of the failure is for v0.5.16, but if it is working correctly for v0.6, then that I'd say that is good enough.

So the main cause of this failure was probably the duplicate SPDX identifiers. I still need to come up with a good fix for that. Something I'm thinking might be to detect whether there are multiple identifiers, and if so, we strip out all of them and require the user to provide a license manually e.g. --license MIT.

from truffle-plugin-verify.

rkalis avatar rkalis commented on September 3, 2024 1

Hey @Enigmatic331 I have been working on allowing the user to provide their license manually (--license MIT). And using @mrwillis' example repo I ran into the issue that the source code is failing the verification through truffle-plugin-verify and through the Api demo page, but succeeding the verification on the web form.

This is the data sent to the API:

{
  "apikey": "<redacted>",
  "module": "contract",
  "action": "verifysourcecode",
  "contractaddress": "0xF177FF5d7D91381cDDcF79cC73DbFfDa8D471383",
  "sourceCode": "// SPDX-License-Identifier: MIT\n\npragma experimental ABIEncoderV2;\npragma solidity 0.6.11;\n\n\n// \nlibrary ConvertLib {\n\n\tstruct TestStruct {\n\t\tuint256 name;\n\t}\n\n\tfunction convert(uint amount,uint conversionRate) internal pure returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n\n// \n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tconstructor() public {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) public returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\temit Transfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) public view returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) public view returns(uint) {\n\t\treturn balances[addr];\n\t}\n\n\tfunction test(ConvertLib.TestStruct memory testObj) public pure {\n\t\trequire(testObj.name > 10);\n\t}\n}",
  "codeformat": "solidity-single-file",
  "contractname": "MetaCoin",
  "compilerversion": "v0.6.11+commit.5ef660b1",
  "optimizationUsed": 0,
  "runs": 200,
  "constructorArguements": "",
  "licenseType": 3
}

The address above is not verified yet, so you can use it in testing. Since the --license stuff is currently just WIP, it's not published anywhere it might be difficult to test for you guys. Let me know if you want me to publish a "beta" tag to NPM or something.

from truffle-plugin-verify.

Enigmatic331 avatar Enigmatic331 commented on September 3, 2024

Hey @mrwillis - Reckon you should be sorted by now, but just in case:

Due to some limitations in the Etherscan verification engine, if you want to use pragma experimental ABIEncoderV2;, this statement should be the first line in your contract file (even above the pragma solidity ^0.6.0; statement).

And yea I've been meaning to look into this on Etherscan's side since forever, need to get an off-day to do this. :)

from truffle-plugin-verify.

rkalis avatar rkalis commented on September 3, 2024

Hey @Enigmatic331, did you have time to look into this API issue yet?

from truffle-plugin-verify.

Enigmatic331 avatar Enigmatic331 commented on September 3, 2024

Hey @rkalis super sorry that I missed this - Let me have a look and ping back shortly.

from truffle-plugin-verify.

Enigmatic331 avatar Enigmatic331 commented on September 3, 2024

@rkalis - We've pushed a fix over to the API servers - Could you take a look if this sorts it out please?
(e.g. https://rinkeby.etherscan.io/address/0xF177FF5d7D91381cDDcF79cC73DbFfDa8D471383#code)

Much appreciated as always!

from truffle-plugin-verify.

rkalis avatar rkalis commented on September 3, 2024

Thanks @Enigmatic331 it's working now! @mrwillis I just published a new release that allows you to specify an SPDX license identifier using the --license parameter.

from truffle-plugin-verify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.