logo
banner-background

安全可靠的 智能合约

BlockATM 智能合约公开透明,并且通过了合约审计平台 Cyberscope 的安全验证保证您的资产100%安全

合约代码

1/* 2 * 函数:deposit 3 * 功能:用户将代币支付到收款合约中,并记录交易。 4 * @notice 函数会记录充值次数,用来计算手续费总额 5 * @notice 函数会触发 Deposit 事件,记录详情。 6 */ 7function deposit( 8 address tokenAddress, 9 uint256 amount, 10 string calldata orderNo 11) 12 public 13 checkTokenAddress(tokenAddress) 14 returns (bool) 15{ 16 // 必须的参数和状态检测 17 ... 18 19 // 调用ERC20代币转账 20 uint256 finalAmount = super.transferCommon(tokenAddress, address(this), amount); 21 22 // 更新该代币地址的充值次数,用于计算手续费 23 transferMap[tokenAddress] += 1; 24 25 // 触发 Deposit 事件,记录充值详情 26 emit Deposit(msg.sender, address(this), tokenAddress, finalAmount, orderNo); 27 28 return true; 29} 30 31 32 33/** 34 * 函数: withdraw 35 * 功能: 商户批量提取合约中资产 36 * 限定:onlyFinance 该函数仅允许财务角色调用,确保只有授权人员可以执行提现操作。 37 * @param recipientAddress 提币地址必须为商户提币固定地址,无法更改,防止资金被错误发送到其他地址。 38 * @param withdrawRequests 提现请求数组,支持多种代币批量同时提取。 39 * @notice 每次提现会计算手续费,并将手续费发送到指定的手续费地址。 40 * @notice 触发 Withdraw 事件,记录提现详情,便于审计和追踪。 41 */ 42function withdraw( 43 bool isSafeTransfer, 44 Withdraw[] calldata withdrawRequests, 45 address recipientAddress 46) 47 public 48 onlyFinance 49 returns (bool) 50{ 51 // 限定提币地址只能为设定的固定地址 52 require(recipientAddress == FIXED_WITHDRAW_ADDRESS, "提币地址必须为固定地址,无法更改"); 53 54 // 其他提币参数安全检查 55 ... 56 57 // 遍历循环处理提币请求 58 for (uint256 i = 0; i < requestCount;) { 59 60 //提币金额和手续费计算 61 ... 62 //执行提币转账 63 super.withdrawCommon(isSafeTransfer, request.tokenAddress, recipientAddress, userAmount); 64 65 //执行手续费转账 66 super.withdrawCommon(isSafeTransfer, request.tokenAddress, feeCollector, fee); 67 } 68 69 // 触发提现事件,用于BlockATM事件监听 70 emit Withdraw(msg.sender, recipientAddress, withdrawRequests, feeAmounts, feeCollector); 71 72 // 返回 true 表示提现成功 73 return true; 74} 75 76 77 78/** 79 * 函数:constructor 80 * 功能:商户在部署收款合约时,在合约部署时设定提现地址、财务人员地址、管理员等 81 * @param newWithdrawList 提现地址列表,在合约部署时写入后不可修改 82 * @param newFinanceList 财务人员地址列表,在合约部署时写入后不可修改 83 * @notice 该构造函数用于初始化合约的关键参数和权限设置。 84 * @notice 提现地址列表和财务地址列表不能为空,确保合约初始化时具备必要的权限配置。 85 * @notice 手续费网关地址用于处理与费用相关的逻辑,确保系统收益和费用扣除的透明性。 86 */ 87constructor( 88 bool safe, 89 uint256 id, 90 address[] memory newWithdrawList, 91 address[] memory newFinanceList, 92 address newFeeGateway 93) { 94 95 //参数安全性检查 96 ... 97 98 // 设置提币地址 99 processList(newWithdrawList, withdrawMap); 100 withdrawList = newWithdrawList; 101 102 // 设置财务地址 103 processList(newFinanceList, financeMap); 104 financeList = newFinanceList; 105 106 //其他参数设置 107 .... 108 109 // 设置合约owner 110 owner = msg.sender; 111}

合约审计

智能合约通过审计平台 Cyberscope 验证,综合评分:8.2/10 安全评级:低风险

数据来自 Cyberscope

safe

82%/100%

低风险

即刻创建专属智能合约

blockchain