Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"@openzeppelin/contracts/utils/Pausable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
"
},
"@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
"
},
"contracts/L1.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.19;\r
\r
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";\r
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";\r
import "@openzeppelin/contracts/access/Ownable.sol";\r
import "@openzeppelin/contracts/utils/Pausable.sol";\r
\r
contract PenkMarketL1 is ReentrancyGuard, Ownable, Pausable {\r
\r
// Token addresses\r
address public immutable USDC_ADDRESS;\r
address public immutable PEPU_ADDRESS;\r
address public verifierAddress;\r
\r
// Transaction states\r
enum TransactionStatus { PENDING, COMPLETED, REFUNDED }\r
\r
// Transaction structure\r
struct Transaction {\r
address user;\r
address tokenAddress;\r
uint256 amount;\r
uint256 timestamp;\r
TransactionStatus status;\r
string tokenType;\r
}\r
\r
// State variables\r
uint256 public transactionNonce;\r
mapping(bytes32 => Transaction) public transactions;\r
mapping(bytes32 => bool) public txidExists;\r
mapping(address => bytes32[]) public userTransactions;\r
\r
// Token whitelist storage\r
address[] public allowedTokens;\r
mapping(address => bool) public isTokenAllowed;\r
\r
// PenkBonus system - default 2% (200 basis points)\r
uint256 public penkBonusBasisPoints = 200;\r
\r
// User refund time limit - default 1 hour (3600 seconds)\r
uint256 public userRefundTimeLimit = 3600;\r
\r
// Events\r
event TransactionCreated(\r
bytes32 indexed txid,\r
address indexed user,\r
address outputToken,\r
uint256 amount,\r
uint256 penkBonus,\r
uint256 totalAmount,\r
string tokenType,\r
uint256 timestamp\r
);\r
\r
event TransactionCompleted(\r
bytes32 indexed txid,\r
address indexed user,\r
uint256 amount,\r
string tokenType\r
);\r
\r
event TransactionRefunded(\r
bytes32 indexed txid,\r
address indexed user,\r
uint256 amount,\r
string tokenType\r
);\r
\r
event PenkBonusUpdated(uint256 oldBasisPoints, uint256 newBasisPoints);\r
\r
event UserRefundTimeLimitUpdated(uint256 oldTimeLimit, uint256 newTimeLimit);\r
\r
event VerifierUpdated(address indexed oldVerifier, address indexed newVerifier);\r
\r
event TokenAdded(address indexed token);\r
event TokenRemoved(address indexed token);\r
\r
// Modifiers\r
modifier validTransaction(bytes32 txid) {\r
require(txidExists[txid], "Transaction does not exist");\r
require(transactions[txid].status == TransactionStatus.PENDING, "Transaction is not pending");\r
_;\r
}\r
\r
modifier validOutputToken(address outputToken) {\r
require(isTokenAllowed[outputToken], "Output token not allowed");\r
_;\r
}\r
\r
modifier canUserRefund(bytes32 txid) {\r
require(txidExists[txid], "Transaction does not exist");\r
require(transactions[txid].status == TransactionStatus.PENDING, "Transaction is not pending");\r
require(transactions[txid].user == msg.sender, "Only transaction creator can refund");\r
require(block.timestamp >= transactions[txid].timestamp + userRefundTimeLimit, "Refund time limit not reached");\r
_;\r
}\r
\r
constructor(\r
address _usdcAddress,\r
address _pepuAddress,\r
address _verifierAddress\r
) Ownable(msg.sender) {\r
require(_usdcAddress != address(0), "Invalid USDC address");\r
require(_pepuAddress != address(0), "Invalid PEPU address");\r
require(_verifierAddress != address(0), "Invalid verifier address");\r
\r
USDC_ADDRESS = _usdcAddress;\r
PEPU_ADDRESS = _pepuAddress;\r
verifierAddress = _verifierAddress;\r
transactionNonce = 0;\r
}\r
\r
// Buy with ETH\r
function buy(address outputToken) external payable nonReentrant whenNotPaused validOutputToken(outputToken) {\r
require(msg.value > 0, "Must send ETH");\r
\r
// Generate transaction ID (bytes32 hash)\r
transactionNonce++;\r
bytes32 txid = _generateTxid(msg.sender, msg.value, address(0), transactionNonce, block.timestamp);\r
\r
// Ensure txid is unique\r
require(!txidExists[txid], "Transaction ID collision");\r
\r
// Store transaction\r
transactions[txid] = Transaction({\r
user: msg.sender,\r
tokenAddress: address(0),\r
amount: msg.value,\r
timestamp: block.timestamp,\r
status: TransactionStatus.PENDING,\r
tokenType: "ETH"\r
});\r
\r
txidExists[txid] = true;\r
userTransactions[msg.sender].push(txid);\r
\r
uint256 penkBonus = (msg.value * penkBonusBasisPoints) / 10000;\r
uint256 totalAmount = msg.value + penkBonus;\r
\r
emit TransactionCreated(txid, msg.sender, outputToken, msg.value, penkBonus, totalAmount, "ETH", block.timestamp);\r
}\r
\r
// Buy with USDC\r
function buyWithUSDC(address outputToken, uint256 amount) external nonReentrant whenNotPaused validOutputToken(outputToken) {\r
require(amount > 0, "Amount must be greater than 0");\r
\r
// Transfer USDC from user to contract\r
IERC20(USDC_ADDRESS).transferFrom(msg.sender, address(this), amount);\r
\r
// Generate transaction ID\r
transactionNonce++;\r
bytes32 txid = _generateTxid(msg.sender, amount, USDC_ADDRESS, transactionNonce, block.timestamp);\r
\r
// Ensure txid is unique\r
require(!txidExists[txid], "Transaction ID collision");\r
\r
// Store transaction\r
transactions[txid] = Transaction({\r
user: msg.sender,\r
tokenAddress: USDC_ADDRESS,\r
amount: amount,\r
timestamp: block.timestamp,\r
status: TransactionStatus.PENDING,\r
tokenType: "USDC"\r
});\r
\r
txidExists[txid] = true;\r
userTransactions[msg.sender].push(txid);\r
\r
uint256 penkBonus = (amount * penkBonusBasisPoints) / 10000;\r
uint256 totalAmount = amount + penkBonus;\r
\r
emit TransactionCreated(txid, msg.sender, outputToken, amount, penkBonus, totalAmount, "USDC", block.timestamp);\r
}\r
\r
// Buy with PEPU\r
function buyWithPEPU(address outputToken, uint256 amount) external nonReentrant whenNotPaused validOutputToken(outputToken) {\r
require(amount > 0, "Amount must be greater than 0");\r
\r
// Transfer PEPU from user to contract\r
IERC20(PEPU_ADDRESS).transferFrom(msg.sender, address(this), amount);\r
\r
// Generate transaction ID\r
transactionNonce++;\r
bytes32 txid = _generateTxid(msg.sender, amount, PEPU_ADDRESS, transactionNonce, block.timestamp);\r
\r
// Ensure txid is unique\r
require(!txidExists[txid], "Transaction ID collision");\r
\r
// Store transaction\r
transactions[txid] = Transaction({\r
user: msg.sender,\r
tokenAddress: PEPU_ADDRESS,\r
amount: amount,\r
timestamp: block.timestamp,\r
status: TransactionStatus.PENDING,\r
tokenType: "PEPU"\r
});\r
\r
txidExists[txid] = true;\r
userTransactions[msg.sender].push(txid);\r
\r
uint256 penkBonus = (amount * penkBonusBasisPoints) / 10000;\r
uint256 totalAmount = amount + penkBonus;\r
\r
emit TransactionCreated(txid, msg.sender, outputToken, amount, penkBonus, totalAmount, "PEPU", block.timestamp);\r
}\r
\r
// Complete transaction (verifier OR owner can call)\r
function completeTransaction(bytes32 txid) external validTransaction(txid) {\r
require(msg.sender == verifierAddress || msg.sender == owner(), "Only verifier or owner can complete transactions");\r
\r
Transaction storage transaction = transactions[txid];\r
transaction.status = TransactionStatus.COMPLETED;\r
\r
// Transfer tokens/ETH to owner when completing transaction\r
if (keccak256(abi.encodePacked(transaction.tokenType)) == keccak256(abi.encodePacked("ETH"))) {\r
// Transfer ETH to owner\r
(bool success, ) = payable(owner()).call{value: transaction.amount}("");\r
require(success, "ETH transfer to owner failed");\r
} else {\r
// Transfer ERC20 tokens to owner\r
IERC20(transaction.tokenAddress).transfer(owner(), transaction.amount);\r
}\r
\r
emit TransactionCompleted(txid, transaction.user, transaction.amount, transaction.tokenType);\r
}\r
\r
// Refund transaction (verifier OR owner can call)\r
function refundTransaction(bytes32 txid) external validTransaction(txid) {\r
require(msg.sender == verifierAddress || msg.sender == owner(), "Only verifier or owner can refund transactions");\r
\r
Transaction storage transaction = transactions[txid];\r
transaction.status = TransactionStatus.REFUNDED;\r
\r
// Refund the tokens/ETH\r
if (keccak256(abi.encodePacked(transaction.tokenType)) == keccak256(abi.encodePacked("ETH"))) {\r
payable(transaction.user).transfer(transaction.amount);\r
} else {\r
IERC20(transaction.tokenAddress).transfer(transaction.user, transaction.amount);\r
}\r
\r
emit TransactionRefunded(txid, transaction.user, transaction.amount, transaction.tokenType);\r
}\r
\r
// User self-refund after time limit (users can call this themselves)\r
function userRefund(bytes32 txid) external canUserRefund(txid) {\r
Transaction storage transaction = transactions[txid];\r
transaction.status = TransactionStatus.REFUNDED;\r
\r
// Refund the tokens/ETH\r
if (keccak256(abi.encodePacked(transaction.tokenType)) == keccak256(abi.encodePacked("ETH"))) {\r
payable(transaction.user).transfer(transaction.amount);\r
} else {\r
IERC20(transaction.tokenAddress).transfer(transaction.user, transaction.amount);\r
}\r
\r
emit TransactionRefunded(txid, transaction.user, transaction.amount, transaction.tokenType);\r
}\r
\r
// Set verifier address (only owner)\r
function setVerifier(address newVerifier) external onlyOwner {\r
require(newVerifier != address(0), "Invalid verifier address");\r
address oldVerifier = verifierAddress;\r
verifierAddress = newVerifier;\r
emit VerifierUpdated(oldVerifier, newVerifier);\r
}\r
\r
// Token whitelist management functions\r
\r
// Add token to whitelist (only owner)\r
function addToken(address token) external onlyOwner {\r
require(token != address(0), "Invalid token address");\r
require(!isTokenAllowed[token], "Token already allowed");\r
\r
_addToken(token);\r
}\r
\r
// Remove token from whitelist (only owner)\r
function removeToken(address token) external onlyOwner {\r
require(isTokenAllowed[token], "Token not in whitelist");\r
\r
isTokenAllowed[token] = false;\r
\r
// Remove from array\r
for (uint256 i = 0; i < allowedTokens.length; i++) {\r
if (allowedTokens[i] == token) {\r
allowedTokens[i] = allowedTokens[allowedTokens.length - 1];\r
allowedTokens.pop();\r
break;\r
}\r
}\r
\r
emit TokenRemoved(token);\r
}\r
\r
// Internal function to add token\r
function _addToken(address token) internal {\r
isTokenAllowed[token] = true;\r
allowedTokens.push(token);\r
emit TokenAdded(token);\r
}\r
\r
// Get all allowed tokens\r
function getAllowedTokens() external view returns (address[] memory) {\r
return allowedTokens;\r
}\r
\r
// Get number of allowed tokens\r
function getAllowedTokensCount() external view returns (uint256) {\r
return allowedTokens.length;\r
}\r
\r
// Check if token is allowed\r
function checkTokenAllowed(address token) external view returns (bool) {\r
return isTokenAllowed[token];\r
}\r
\r
// Get transaction details\r
function getTransaction(bytes32 txid) external view returns (Transaction memory) {\r
require(txidExists[txid], "Transaction does not exist");\r
return transactions[txid];\r
}\r
\r
// Get user's transaction IDs\r
function getUserTransactions(address user) external view returns (bytes32[] memory) {\r
return userTransactions[user];\r
}\r
\r
// Pause contract (only owner)\r
function pause() external onlyOwner {\r
_pause();\r
}\r
\r
// Unpause contract (only owner)\r
function unpause() external onlyOwner {\r
_unpause();\r
}\r
\r
// Set PenkBonus percentage (only owner)\r
function setPenkBonus(uint256 newBasisPoints) external onlyOwner {\r
require(newBasisPoints <= 1000, "PenkBonus cannot exceed 10%");\r
uint256 oldBasisPoints = penkBonusBasisPoints;\r
penkBonusBasisPoints = newBasisPoints;\r
emit PenkBonusUpdated(oldBasisPoints, newBasisPoints);\r
}\r
\r
// Set user refund time limit (only owner or verifier)\r
function setUserRefundTimeLimit(uint256 newTimeLimit) external {\r
require(msg.sender == owner() || msg.sender == verifierAddress, "Only owner or verifier can set time limit");\r
require(newTimeLimit > 0, "Time limit must be greater than 0");\r
require(newTimeLimit <= 86400, "Time limit cannot exceed 24 hours");\r
uint256 oldTimeLimit = userRefundTimeLimit;\r
userRefundTimeLimit = newTimeLimit;\r
emit UserRefundTimeLimitUpdated(oldTimeLimit, newTimeLimit);\r
}\r
\r
// Withdraw ETH (only owner)\r
function withdrawETH() external onlyOwner {\r
uint256 balance = address(this).balance;\r
require(balance > 0, "No ETH to withdraw");\r
payable(owner()).transfer(balance);\r
}\r
\r
// Withdraw tokens (only owner)\r
function withdrawToken(address tokenAddress) external onlyOwner {\r
uint256 balance = IERC20(tokenAddress).balanceOf(address(this));\r
require(balance > 0, "No tokens to withdraw");\r
IERC20(tokenAddress).transfer(owner(), balance);\r
}\r
\r
// Generate unique transaction ID using keccak256 hash\r
function _generateTxid(\r
address user,\r
uint256 amount,\r
address tokenAddress, \r
uint256 nonce,\r
uint256 timestamp\r
) internal pure returns (bytes32) {\r
return keccak256(abi.encodePacked(user, amount, tokenAddress, nonce, timestamp));\r
}\r
\r
// Receive function for ETH\r
receive() external payable {}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-23 19:38:54
Comments
Log in to comment.
No comments yet.