// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyFirstScrollContract {
// Public statement accessible by anyone to see that this is your first contract
string public firstContractStatement;
// Address of the contract owner
address public contractOwner;
// Event to log the affirmation of the first contract and owner
event Affirmation(address owner, string statement);
// The initializer serves as a constructor substitute
function initialize() public {
// Ensure that this function behaves like a constructor and is called only once
require(contractOwner == address(0), "Already initialized");
// Set the owner to the sender of the transaction
contractOwner = msg.sender;
// A simple statement indicating this is your first contract on Scroll Network
firstContractStatement = "This is my first contract on the Scroll Network.";
// Emit an event to log the action
emit Affirmation(contractOwner, firstContractStatement);
}
// Function to affirm the contract's purpose
function affirmContract() public view returns (string memory) {
require(
msg.sender == contractOwner,
"Only the owner can affirm the contract."
);
return firstContractStatement;
}
}
{
"compilationTarget": {
"MyFirstScrollContract.sol": "MyFirstScrollContract"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"statement","type":"string"}],"name":"Affirmation","type":"event"},{"inputs":[],"name":"affirmContract","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstContractStatement","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"}]