Skip to content

NADA304/BMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

<title>مشروع الاكتتاب BMS</title> <script src="https://cdn.jsdelivr.net/npm/web3@1.6.1/dist/web3.min.js"></script> <style> body { font-family: Arial, sans-serif; } .container { width: 50%; margin: auto; text-align: center; } button { padding: 10px 20px; margin: 20px; background-color: #ff7f00; color: white; border: none; cursor: pointer; } button:hover { background-color: #e06c00; } #walletAddress { margin-top: 20px; } </style>

الاكتتاب لعملة BMS

اتصل بـ MetaMask

اشترك في الاكتتاب

شراء عملة BMS

<script>
    const contractAddress = '0xYourContractAddress'; // استبدل بعنوان عقدك الذكي
    const contractABI = [ /* ABI الخاصة بعقد BMS */ ];

    let web3;
    let userAccount;
    let bmsContract;

    // الاتصال بـ MetaMask
    async function connectMetaMask() {
        if (typeof window.ethereum !== 'undefined') {
            web3 = new Web3(window.ethereum);
            await window.ethereum.request({ method: 'eth_requestAccounts' });
            const accounts = await web3.eth.getAccounts();
            userAccount = accounts[0];
            bmsContract = new web3.eth.Contract(contractABI, contractAddress);
            document.getElementById('walletAddress').innerText = عنوان المحفظة: ${userAccount};
            checkBalance();
        } else {
            alert("يرجى تثبيت MetaMask أولاً!");
        }
    }

    // شراء عملة BMS
    async function buyTokens() {
        const amountInEth = document.getElementById('amount').value;
        if (amountInEth > 0) {
            const amountInWei = web3.utils.toWei(amountInEth, 'ether');
            try {
                await bmsContract.methods.buyTokens().send({ from: userAccount, value: amountInWei });
                alert('تم شراء عملة BMS بنجاح');
            } catch (error) {
                console.error("خطأ في المعاملة:", error);
                alert("حدث خطأ أثناء شراء العملة");
            }
        } else {
            alert('الرجاء إدخال مبلغ صالح');
        }
    }

    // التحقق من رصيد المستخدم
    async function checkBalance() {
        const balance = await web3.eth.getBalance(userAccount);
        const balanceInEth = web3.utils.fromWei(balance, 'ether');
        document.getElementById('balance').innerText = رصيدك من ETH: ${balanceInEth} ETH;
    }
</script>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages