Secure & Reliable Smart Contracts
BlockATM's smart contracts are transparent and have passed security verification by the auditing platform Cyberscope
Ensure 100% security for your assets
Contract Code
1/*
2 * Function: deposit
3 * Purpose: User pays tokens into the payout contract and records the transaction.
4 * @notice The function records the number of deposits to calculate the total fee amount.
5 * @notice The function emits a Deposit event to log detailed information.
6 */
7function deposit(
8 address tokenAddress,
9 uint256 amount,
10 string calldata orderNo
11)
12 public
13 checkTokenAddress(tokenAddress)
14 returns (bool)
15{
16 // Required parameter and state validation
17 ...
18
19 // Call ERC20 token transfer
20 uint256 finalAmount = super.transferCommon(tokenAddress, address(this), amount);
21
22 // Update the deposit count for the token address, used for fee calculation
23 transferMap[tokenAddress] += 1;
24
25 // Emit Deposit event to log the deposit details
26 emit Deposit(msg.sender, address(this), tokenAddress, finalAmount, orderNo);
27
28 return true;
29}
30
31
32/**
33 * Function: withdraw
34 * Purpose: Merchant batch withdraws assets from the contract.
35 * Restriction: onlyFinance - Only finance roles are allowed to call this function, ensuring that only authorized personnel can perform withdrawals.
36 * @param recipientAddress The withdrawal address must be the merchant’s fixed address and cannot be changed to prevent misdirected funds.
37 * @param withdrawRequests Array of withdrawal requests, supporting batch withdrawal of multiple token types.
38 * @notice Each withdrawal will calculate fees and send them to the specified fee collection address.
39 * @notice Emits a Withdraw event to record the withdrawal details for audit and tracking purposes.
40 */
41function withdraw(
42 bool isSafeTransfer,
43 Withdraw[] calldata withdrawRequests,
44 address recipientAddress
45)
46 public
47 onlyFinance
48 returns (bool)
49{
50 // Restrict withdrawal address to a fixed preset address
51 require(recipientAddress == FIXED_WITHDRAW_ADDRESS, "Withdrawal address must be fixed and cannot be changed");
52
53 // Other withdrawal parameter safety checks
54 ...
55
56 // Iterate through withdrawal requests
57 for (uint256 i = 0; i < requestCount;) {
58
59 // Withdrawal amount and fee calculation
60 ...
61 // Execute withdrawal transfer
62 super.withdrawCommon(isSafeTransfer, request.tokenAddress, recipientAddress, userAmount);
63
64 // Execute fee transfer
65 super.withdrawCommon(isSafeTransfer, request.tokenAddress, feeCollector, fee);
66 }
67
68 // Emit Withdraw event for BlockATM event monitoring
69 emit Withdraw(msg.sender, recipientAddress, withdrawRequests, feeAmounts, feeCollector);
70
71 // Return true to indicate successful withdrawal
72 return true;
73}
74
75
76/**
77 * Function: constructor
78 * Purpose: When deploying the payout contract, the merchant sets the withdrawal addresses, finance personnel addresses, and administrator.
79 * @param newWithdrawList List of withdrawal addresses, which cannot be modified after deployment.
80 * @param newFinanceList List of finance personnel addresses, which cannot be modified after deployment.
81 * @notice This constructor initializes the key contract parameters and permission settings.
82 * @notice Withdrawal and finance address lists must not be empty to ensure proper permission configuration at initialization.
83 * @notice The fee gateway address handles fee-related logic to ensure transparency in system revenue and fee deductions.
84 */
85constructor(
86 bool safe,
87 uint256 id,
88 address[] memory newWithdrawList,
89 address[] memory newFinanceList,
90 address newFeeGateway
91) {
92 // Parameter safety checks
93 ...
94
95 // Set withdrawal addresses
96 processList(newWithdrawList, withdrawMap);
97 withdrawList = newWithdrawList;
98
99 // Set finance addresses
100 processList(newFinanceList, financeMap);
101 financeList = newFinanceList;
102
103 // Other parameter settings
104 ...
105
106 // Set contract owner
107 owner = msg.sender;
108}
109
Contract Audit
Smart contract audited by Cyberscope, overall score: 8.2/10, security rating: Low Risk
Data from Cyberscope
82%/100%
Low Risk
Real On-Chain Contracts (Partial display only)
Contract Address
Network
Version
Deployment Time