AdminAuth.sol

Overview

The AdminAuth contract is a Solidity smart contract designed to manage owner and admin privileges over other smart contracts. It provides a set of modifiers and functions that allow the owner and admin to perform certain actions, such as withdrawing stuck funds and destroying the contract. This contract is used to control access and permissions within a decentralized application (DApp) or smart contract ecosystem.

Contract Information

  • SPDX-License-Identifier: MIT

  • Solidity Version: 0.8.10

Public Functions

  1. withdrawStuckFunds(address _token, address _receiver, uint256 _amount)

    Visibility: Public

    Modifiers: onlyOwner

    Parameters:

    • _token: The address of the token to be withdrawn. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for Ether.

    • _receiver: The address to receive the withdrawn tokens or Ether.

    • _amount: The amount of tokens or Ether to withdraw.

    This function allows the owner to withdraw stuck funds from the contract. If the _token address is the Ethereum address, the function transfers Ether to the _receiver. Otherwise, it uses the SafeERC20 library to transfer ERC-20 tokens to the _receiver.

  2. kill()

    • Visibility: Public

    • Modifiers: onlyAdmin

    This function allows the admin to destroy the contract by invoking selfdestruct. The remaining Ether balance in the contract is sent to the admin's address.

Modifiers

  1. onlyOwner

    This modifier restricts access to functions to only the owner of the adminVault contract. If the sender is not the owner, the SenderNotOwner() error is thrown, reverting the transaction.

  2. onlyAdmin

    This modifier restricts access to functions to only the admin of the adminVault contract. If the sender is not the admin, the SenderNotAdmin() error is thrown, reverting the transaction.

Custom Errors

The contract defines two custom errors that can be thrown during execution:

  1. SenderNotOwner(): This error is thrown when a function with the onlyOwner modifier is called, but the sender is not the owner according to the adminVault contract.

  2. SenderNotAdmin(): This error is thrown when a function with the onlyAdmin modifier is called, but the sender is not the admin according to the adminVault contract.

Last updated