0

I have a library which contains a function concat - it can merge two bytes. I have deployed a contract which uses that library and it works. I would like to make a simple bytes builder on my website. Do I need to deploy a special contract BytesBuilder or can I simply call the already deployed library and call lib.concat somehow?

7
  • I believe that if the function is public in the library then it is also public in the contract, and therefore you can call it via the contract. Have you tried? Sep 1, 2019 at 11:13
  • Yes, my contract communicates with library with success. My question was can I exclude the contract and just call the library which has already been deployed and call function to build bytes, or have I to deploy another contract, add some more functions for builder and deploy again.
    – Radek_pl
    Sep 1, 2019 at 11:21
  • I guess there is a misunderstanding, sorry. Let me explain. I can't use my contract I already have deployed because it implements the library only for it's internal use: I call the function with bytes put as parameter and it grabs it and splits to necessary chunks and performs other work with them - it works perfectly. Then I found out I could make an external bytes builder generator on my website. The library has ready to go functions to merge bytes, but the contract doesn't, it only reads and parses. I was thinking if I could still use that library to make a builder.
    – Radek_pl
    Sep 1, 2019 at 11:36
  • So there is no misunderstanding here. As I stated in my first comment - if the function is public in the library, then you can call it via the contract which you have already deployed. Otherwise, you'd need to expose it in a new contract (either by declaring it public this time, or by providing a public function in the new contract, which will call the internal function in the library). Sep 1, 2019 at 11:39
  • By the way, for an "external bytes builder generator on my website", you don't need neither a contract nor a library (i.e., you don't need anything on the blockchain). You can get it done with a simple usage of web3.utils. It will also work much faster (no RPC involved). Sep 1, 2019 at 11:56

0

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.

Browse other questions tagged or ask your own question.