Is it possible to import a library into another library? I give a simplified example below of what I'd like to achieve:

library structLib {
    struct Point {
        uint X;
        uint Y;
import "./structLib.sol";

library ellipticCurveOperations {

    //adds point p1 to point p2
    function addition(Point p1, Point p2) internal returns (Point r) {

        //convert struct to array for use in precompiles
        uint[4] memory input;
        input[0] = p1.X;
        input[1] = p1.Y;
        input[2] = p2.X;
        input[3] = p2.Y;
        bool success;

        //use assembly to call Elliptic Curve precompile
        assembly {
            success := call(sub(gas, 2000), 6, 0, input, 0xc0, r, 0x60)
            switch success case 0 { invalid() }
        require(success, "EC addition failed");
import "./ellipticCurveOperations.sol" as Ops

contract addThings{
    using Ops for *;

    function add(Ops.Point a, Ops.Point b) public returns (Ops.Point){
        return Ops.addition(a, b);

Would this work? Is there any syntax I need to change?

Many thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.