book
book copied to clipboard
Documentation needed: cannot deploy contract with linked libraries using deployCode
Component
Forge
Describe the feature you would like
I need to deploy a contract with an incompatible version number to my test script. The natural solution is to use deployCode, however, this contract also requires certain libraries. The following leads to an error:
address factory = deployCode(
“Factory.sol”,
abi.encode(arg1)
);
Error:
[FAIL. Reason: Setup failed: No bytecode for contract. Is it abstract or unlinked?]
It's a known limitation that deployCode doesn't support library linking which prevents the Factory contract from being deployed.
What is the best alternative for deploying a contract that needs a unique version number and depends on libraries?
Additional context
No response
Got the same error :/
Unable to getCode of test smart that contains library function call
➜ abi.encodePacked(vm.getCode("Counter.sol:Counter"))
Traces:
[3109] 0xBd770416a3345F91E4B34576cb804a576fa48EB1::run()
├─ [0] VM::getCode(Counter.sol:Counter)
│ └─ ← "No bytecode for contract. Is it abstract or unlinked?"
└─ ← "No bytecode for contract. Is it abstract or unlinked?"
replacing Lib.x() to Lib.X (reading variable) "solves"
➜ abi.encodePacked(vm.getCode("Counter.sol:Counter"))
Type: dynamic bytes
├ Hex (Memory):
├─ Length ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000145
├─ Contents ([0x20:..]): 0x608060405234801561001057600080fd5b50610125806100206000396000f3fe608060405
├ Hex (Tuple Encoded):
├─ Pointer ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000020
├─ Length ([0x20:0x40]): 0x0000000000000000000000000000000000000000000000000000000000000145
└─ Contents ([0x40:..]): 0x608060405234801…➜