// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract MintContract {
address public owner;
mapping(address => uint256) mintMainMap; //平臺主幣種認(rèn)購數(shù)目
mapping(address => uint256) banlanceMap; //平臺主幣種余額數(shù)目
event BatchMintWithEther(
string indexed code,
uint256 indexed mainNum,
uint256 mainTotal,
uint256 currentNum
);
constructor() {
owner = msg.sender;
}
//使用modifile判斷權(quán)限是不是某個人
modifier onlyOwner() {
require(owner == msg.sender, "only owner can call the function");
_;
}
//獲取主幣種余額
function getMainTokenBalance() public view returns (uint256) {
return address(msg.sender).balance;
}
function getContractAddressBalance() public view returns (uint256) {
return address(this).balance;
}
//獲取合約的余額
function getContractOwnerBalance() public view onlyOwner returns(uint256) {
return address(owner).balance;
}
function getContractAddress() public view returns (address) {
return address(this); //0xd9145CCE52D386f254917e481eB44e9943F39138
}
// //向合約發(fā)送主幣要在該函數(shù)添加payable關(guān)鍵字 a給b轉(zhuǎn)賬
function batchMintWithEther(string memory code,address receiveAddress, uint256 mintNum)
external
payable
{
require(msg.value > 0, "the balnace value must be more than 0");
uint256 amount = address(msg.sender).balance; //獲取當(dāng)前地址
require(amount > msg.value, "your wallet balance not enough");
//a給b轉(zhuǎn)賬 基于合約轉(zhuǎn)平臺幣種
address payable receiveAdd = payable(receiveAddress); //拿到拉起錢包的人
//https://www.cnblogs.com/x-poior/p/10511583.htmlv
receiveAdd.transfer(msg.value);
banlanceMap[receiveAddress] += msg.value;
mintMainMap[msg.sender] += mintNum;
//可以轉(zhuǎn)賬
emit BatchMintWithEther(
code,
mintNum,
mintMainMap[msg.sender],
msg.value
);
}
}
2023-12-28 solidity 平臺幣種轉(zhuǎn)賬
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 帕金森病是一種慢性、進(jìn)行性和神經(jīng)遞質(zhì)缺乏的疾病,常常影響到患者的運動能力和生活質(zhì)量。雖然還沒有能夠完全治愈帕金森病...
- 昨天下午五點多收到七天學(xué)堂的信息,本月月考成績出來了,我沒有看,看到信息還挺煩,自從上次孩子考了52名,級部100...