// SPDX-License-Identifier: MIT
// Importing the SillyStringUtils library
import "./SillyStringUtils.sol";
pragma solidity 0.8.17;
contract ImportsExercise {
// Using the SillyStringUtils library for string manipulation
using SillyStringUtils for string;
// Declaring a public variable to store a Haiku
SillyStringUtils.Haiku public haiku;
// Function to save a Haiku
function saveHaiku(string memory _line1, string memory _line2, string memory _line3) public {
haiku.line1 = _line1;
haiku.line2 = _line2;
haiku.line3 = _line3;
}
// Function to retrieve the saved Haiku
function getHaiku() public view returns (SillyStringUtils.Haiku memory) {
return haiku;
}
// Function to append a shrugging emoji to the third line of the Haiku
function shruggieHaiku() public view returns (SillyStringUtils.Haiku memory) {
// Creating a copy of the Haiku
SillyStringUtils.Haiku memory newHaiku = haiku;
// Appending the shrugging emoji to the third line using the shruggie function from the SillyStringUtils library
newHaiku.line3 = newHaiku.line3.shruggie();
return newHaiku;
}
}
感谢X用户@isnotberlin提供的代码 以下是,Base Learn Supreme的3个NFT代码,SCD ERC721 、Minimal Token、ERC20 1. Own a(n) SCD ERC721 Pin NFT Solidity 接口 复制代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Importing OpenZeppelin ERC721 contract import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"; // Interface for interacting with a submission contract interface ISubmission { // Struct representing a haiku struct Haiku { address author; // Address of the haiku author string line1; // First line of the haiku string line2; // Second line of the haiku string line3; // Third line of the haiku } // Function to mint a new haiku function mintHaiku( string memory _line1, string memory _line2, string memory _line3 ) external; // Function to get the total number of haikus function counter() ...
评论
发表评论