invalid opcode when running example
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
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?
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.
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.
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.
I replaced on line 30 40 with 140 and it started to work.