Link an address to a contract as a library in deployer
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
My contract has a libary Lib {}
in it. I would like to use an existing library in the migrations script.
Something like:
deployer.linkAddressAsLibrary('0xabcde...', 'AnExistingLibraryOnChain')
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
remix - How to deploy Library contract separate from the main ...
[Q] Is there any way to first deploy the library contract separately from the main contract and than link it to the main...
Read more >Compile a contract using linked libraries - OpenZeppelin Forum
I see a lot of example of library linking for the deployment. But the contract aspect is not clear. pragma solidity 0.8.15; import...
Read more >How can I link library and contract in one file? - Stack Overflow
In this case, you have to deploy the library and then need to specify a link for the library in contract deployment.
Read more >Deploying with Libraries on Remix-IDE - Medium
Click on Deploy. And you have deployed a contract linked to a library! Under the Hood. Let's see where the library's address gets...
Read more >Libraries in Solidity smart contracts - Crypto Market Pool
Deploy library contract to a test network; Configure Remix with deployed library address; Deploy calling contract. Before we start linking contracts the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, I just had an idea for how to handle this. (Which I am realizing now was implcitly suggested by @ayusht11 above, but we don’t seem to have taken much notice of it at the time, presumably because it wasn’t given as an explicit suggestion.)
We could handle this by allowing the first argument of
link
to be a library instance rather than a library class. Then you could doawait library = Library.at(address); deployer.link(library, Contract)
. That seems like it would be a fairly natural extension of the current syntax. What do people think of that?@gnidan This actually already works, the key is that
.link
returns a thenable, so it must be awaited. Here is what works for meAlternatively you could use
.then()
syntax.Also, it should be noted that my deploy script must be setup like this for
async
to work: