Skip to content
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

invalid opcode when running example #2

Open
lsaether opened this issue Mar 20, 2018 · 5 comments
Open

invalid opcode when running example #2

lsaether opened this issue Mar 20, 2018 · 5 comments

Comments

@lsaether
Copy link

It appears that something in this library isn't working with recent versions of solidity, truffle and ganache-cli.

Trying to run the example in the README goes okay until I try to generateHash, in which case I run into the invalid opcode error. Any idea where the invalid opcode is happening? I'm digging through it to try to find it

@MrChico
Copy link
Owner

MrChico commented Mar 20, 2018

Does not surprise me, the code is over a year old and Solidity has undergone a lot of changes. Does this seem like something you would be able to fix yourself easily?

@bonedaddy
Copy link

bonedaddy commented Mar 20, 2018

I believe the invalid opcode comes from using sha256. if you comment out line 18 which converts to base58 you should be able to run the function successfully and generate the base58 encoded version client-side.

@lsaether
Copy link
Author

The problem I think is the while loop on line 41

           while (carry > 0) {
                digits[digitlength] = uint8(carry % 58);
                digitlength++;
                carry = carry / 58;
            }

specifically the line carry = carry / 58; appears to not be breaking the loop and causing the invalid opcode error. When commenting that out and forcing the loop to break by setting carry = 0 the code compiles and runs but of course doesn't covert to base58 correctly.

As @postables suggests, I am just doing the base58 encoding client side. Since all I really need to verify here is the hash which can be done using solidity built-in sha256.

@nklipa13
Copy link

nklipa13 commented Apr 2, 2018

I'm trying do generateHash without base58, but when I do base58 on bytes I get, its not giving me same output as ipfs. If anyone made it work it would be great if they leave code sample here.

@Lizusha
Copy link

Lizusha commented Dec 18, 2020

I replaced on line 30 40 with 140 and it started to work.

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

5 participants