Skip to content

Lesson 11: meet problem about DevOpsTools.get_most_recent_deployment #1687

Answered by lightrao
lightrao asked this question in Q&A
Discussion options

You must be logged in to vote

I create a custom funciton as alternative to DevOpsTools.get_most_recent_deployment:

    function getDeployedContractAddress() private view returns (address) {
        string memory path = string.concat(
            vm.projectRoot(),
            "/broadcast/DeployYourContract.s.sol/",
            Strings.toString(block.chainid),
            "/run-latest.json"
        );
        string memory json = vm.readFile(path);
        bytes memory contractAddress = stdJson.parseRaw(
            json,
            ".transactions[0].contractAddress"
        );
        return (bytesToAddress(contractAddress));
    }

    function bytesToAddress(
        bytes memory bys
    ) private pure returns (address

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
3 replies
@lightrao
Comment options

@EngrPips
Comment options

@lightrao
Comment options

Comment options

You must be logged in to vote
8 replies
@Hardeybola
Comment options

@Hardeybola
Comment options

@EngrPips
Comment options

@Hardeybola
Comment options

@EngrPips
Comment options

Answer selected by lightrao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants