Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions contracts/MyContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.20;

contract MyContract {
address public owner;
address public authorizedAddress;
uint256 public value;
bytes32 public merkleRoot;

Expand All @@ -13,20 +14,28 @@ contract MyContract {
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Claimed(address indexed account, uint256 amount);
event MerkleRootUpdated(bytes32 oldRoot, bytes32 newRoot);
event AuthorizedAddressUpdated(address indexed oldAddress, address indexed newAddress);

/**
* @notice Constructor sets the owner to kushmanmb.eth / yaketh.eth
* @dev Owner address: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB
* @dev Authorized address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43
*/
constructor() {
owner = 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB; // kushmanmb.eth / yaketh.eth
authorizedAddress = 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43;
}

modifier onlyOwner() {
require(msg.sender == owner, "Not the owner");
_;
}

modifier onlyAuthorized() {
require(msg.sender == authorizedAddress, "Not authorized");
_;
}

function setValue(uint256 _value) public onlyOwner {
value = _value;
emit ValueChanged(_value);
Expand All @@ -39,6 +48,26 @@ contract MyContract {
emit OwnershipTransferred(previousOwner, newOwner);
}

/**
* @notice Allows the owner to update the authorized address
* @param newAuthorizedAddress The new authorized address
*/
function setAuthorizedAddress(address newAuthorizedAddress) public onlyOwner {
require(newAuthorizedAddress != address(0), "Invalid address");
address oldAddress = authorizedAddress;
authorizedAddress = newAuthorizedAddress;
emit AuthorizedAddressUpdated(oldAddress, newAuthorizedAddress);
}

/**
* @notice Allows the authorized address to set the value (delegated owner function)
* @param _value The new value to set
*/
function setValueAuthorized(uint256 _value) public onlyAuthorized {
value = _value;
emit ValueChanged(_value);
}

/**
* @notice Sets the Merkle root for claim verification
* @param _merkleRoot The new Merkle root
Expand Down
21 changes: 14 additions & 7 deletions contracts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ DEPLOYMENT METHODS:
✓ Deploy using "Injected Provider - MetaMask"
✓ No constructor arguments needed
✓ Owner is hardcoded: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB
✓ Authorized Address is hardcoded: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43

2. FOUNDRY CAST (For advanced users)
$ forge create contracts/MyContract.sol:MyContract \\
Expand Down Expand Up @@ -129,11 +130,12 @@ Network Details:
Currency: ${network.currency}

Contract Details:
Name: MyContract
File: contracts/MyContract.sol
Compiler: Solidity ^0.8.20
Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB
License: MIT
Name: MyContract
File: contracts/MyContract.sol
Compiler: Solidity ^0.8.20
Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB
Authorized Address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43
License: MIT

Deployment Steps:

Expand Down Expand Up @@ -177,6 +179,10 @@ Deployment Steps:
e. Set Merkle root (only owner can do this):
- Call setMerkleRoot(bytes32 _merkleRoot)
- Use address: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB

f. Authorized address functions:
- setValueAuthorized(uint256): Can be called by 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43
- setAuthorizedAddress(address): Owner can update authorized address

Gas Estimates (approximate):
Deployment: ~1,200,000 gas
Expand Down Expand Up @@ -214,7 +220,8 @@ Quick Start:
4. Verify the contract: npm run verify -- [options]

Contract Info:
File: contracts/MyContract.sol
Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB (kushmanmb.eth / yaketh.eth)
File: contracts/MyContract.sol
Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB (kushmanmb.eth / yaketh.eth)
Authorized Address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43
`);
}
Loading