Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow getting address for linked libraries #7274

Closed
haltman-at opened this issue Aug 17, 2019 · 1 comment · Fixed by #7701
Assignees
Labels
Projects

Comments

@haltman-at
Copy link

@haltman-at haltman-at commented Aug 17, 2019

Abstract

As best I can tell, there's currently no way in Solidity to get the address of a linked library. This could be useful e.g. for doing a manual delegatecall. I would like there to be syntax for getting the address of a linked library.

Motivation

I propose allowing the syntax address(LibraryName), where LibraryName is the name of the library, as a means of getting the address of the linked copy of the library LibraryName.

Another syntax, such as LibraryName.address, would be fine too, but I think the former makes more sense in this case. It makes sense to convert a library name to an address, since internally it's identified by an address; while writing LibraryName.address looks misleadingly like a state variable access (yes, even though libraries can't have state variables).

Then one could do something like this:

library Library {
  ...
}

contract Contract {
  ...
  function f() public {
    ...
    (bool result, bytes memory out) = address(Library).delegatecall(...);
    ...
  }
}

Specification

Given an expression E, where E has type type(library LibraryName), where LibraryName is the name of a library, I propose that it should be possible to convert E to type address by the usual means (i.e., writing address(E)), and that this conversion would return the address where the linked copy of LibraryName is kept.

Backwards Compatibility

There should be no backwards compatibility problems.

@ekpyron ekpyron added this to To do in 0.5.12 via automation Aug 17, 2019
@axic axic added the feature label Aug 18, 2019
@chriseth chriseth removed this from To do in 0.5.12 Oct 2, 2019
@chriseth chriseth added this to To do in 0.5.13 via automation Oct 2, 2019
@chriseth

This comment has been minimized.

Copy link
Contributor

@chriseth chriseth commented Oct 2, 2019

Discussion resulted in address(LibraryName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.5.13
  
Done
4 participants
You can’t perform that action at this time.