5

I have a sol file with a library and also a contract.

The contract can use the library and everythings deploys correct using the solidity-browser.

If I add a new library and call a function of that new library then I get the following browser-solidity error during deployment -

    Error deploying required libraries: Invalid bytecode format.

Does solidity support a contract using multiple libraries? If it does do I then need to do something else to enable using multiple libraries in a contract?

Solidity code example -

library MyLibrary_1
{
    function MyLibrary_1()
    {

    }

    function TestFunction() public
    {
        uint8 value = 5 + 5;
    }
}

library MyLibrary_2
{
    function MyLibrary_2()
    {

    }

    function TestFunction() public
    {
        uint8 value = 5 + 5;
    }
}

contract MyContract
{
    function MyContract()
    {

    }

    function MyContract_function() public
    {
        MyLibrary_1.TestFunction();
        MyLibrary_2.TestFunction();
    }

    function() 
    {
        throw;
    }
}   
2
  • Can you provide minimal source to reproduce this, or export your browser-solidity workstation to a gist? I don't believe there is enough information here to answer your question. Aug 12, 2016 at 16:22
  • Added a solidity code example for the issue.
    – Alex Darby
    Aug 12, 2016 at 16:43

1 Answer 1

4

Found the issue. Do not use underscore characters when naming a solidity library as the solidity linker cannot process this character correctly during deployment.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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