0

I am trying to do a small example contract of

Error deploying required libraries: Invalid bytecode format.

Here is the contract code

library CounterLib {
struct Counter { 
    uint i;


}

 function incremented(Counter storage self) returns (uint) {
    return ++self.i;
 }
}

contract CounterContract {
   using CounterLib for CounterLib.Counter;

   CounterLib.Counter counter;

   function increment() returns (uint) {
     return counter.incremented();
   }
}
  • Is pragma solidity ^0.4.*; where * is a version number, at the top of your Solidity file? – willjgriff Jan 23 '18 at 11:33
  • @willjgriff Yes. – BalaChandra Jan 23 '18 at 12:02
1

How are you deploying this? With Truffle or Remix or something else?

If I copy this into Remix and deploy it with the Javascript VM it seems to work as expected, so there's nothing wrong with the code you've pasted above. Note that before deploying CounterContract it must be linked to the deployed CounterLib library. Linking takes the address of the deployed CounterLib library and copies it into the bytecode of the CounterContract before deployment.

Remix does linking automatically and Truffle requires you to specify linked contracts in the deploy script. What are you using and how are you linking the CounterLib with the CounterContract?

  • I am also using remix with javascript VM, but I am getting this error. – BalaChandra Jan 23 '18 at 12:02
  • 1
    There might some issue, with my browser. If I open a private window it is working fine. I tried with another browser, it is working fine. – BalaChandra Jan 23 '18 at 12:06
1

The issue is with my browser I think, I tried in another browser, the code works as expected and I also tried using private window, then also it worked fine. But I try to create using my normal browser window. I am getting this error. Don't know the reason, but for now using another browser.

  • Out of interest, what browser has the error and what browser doesn't? – willjgriff Jan 23 '18 at 12:38
  • I am using ubuntu, chromium browser has this error. In google chrome, it is working fine. And in chromium also, I am getting this error, When I am using storage references in library. Normal ones like safe math works fine. – BalaChandra Jan 24 '18 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.