For the complete documentation index, see llms.txt. This page is also available as Markdown.

7.1 Writing and Deploying

Repeat the same steps used in the previous example to create a new file in Remix.

Paste:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract WalletAuth {
    address public owner;

    constructor() {
        owner = msg.sender;
    }

    function restrictedAction() public view returns (string memory) {
        require(msg.sender == owner, "Not authorized");
        return "Access granted";
    }
}

Here:

  • msg.sender represents the wallet calling the function

  • the constructor sets the deployer as the owner

  • access is restricted using require()

Last updated