Skip to content

Imports Exercise

Create a contract that adheres to the following specifications.


Contract

Create a contract called ImportsExercise. It should import a copy of SillyStringUtils

// SPDX-License-Identifier: MIT
 
pragma solidity ^0.8.17;
 
library SillyStringUtils {
 
    struct Haiku {
        string line1;
        string line2;
        string line3;
    }
 
    function shruggie(string memory _input) internal pure returns (string memory) {
        return string.concat(_input, unicode" 🤷");
    }
}

Add a public instance of Haiku called haiku.

Add the following two functions.

Save Haiku

saveHaiku should accept three strings and save them as the lines of haiku.

Get Haiku

getHaiku should return the haiku as a Haiku type.

Shruggie Haiku

shruggieHaiku should use the library to add 🤷 to the end of line3. It must not modify the original haiku. It should return the modified Haiku.


Submit your Contract and Earn an NFT Badge! (BETA)

Contract Verification Best Practices

To simplify the verification of your contract on a blockchain explorer like BaseScan.org, consider these two common strategies:

  1. Flattening: This method involves combining your main contract and all of its imported dependencies into a single file. This makes it easier for explorers to verify the code since they only have to process one file.

  2. Modular Deployment: Alternatively, you can deploy each imported contract separately and then reference them in your main contract via their deployed addresses. This approach maintains the modularity and readability of your code. Each contract is deployed and verified independently, which can facilitate easier updates and reusability.

  3. Use Desktop Tools: Forge and Hardhat both have tools to write scripts that both deploy and verify your contracts.

Loading wallet connection...