|
1 | | -import { createMetadata, DocImage, Grid, SDKCard, FeatureCard } from "@doc"; |
2 | | -import PayOverviewImage from "./assets/pay-overview.png"; |
3 | | -import SupportedChains from "../_images/supported-chains.png"; |
4 | | -import {RocketIcon, ArrowLeftRightIcon, WalletIcon, PencilIcon, ShieldCheckIcon, PiggyBankIcon, GlobeIcon, ComponentIcon, CodeIcon, ApiIcon, WebhookIcon} from "lucide-react"; |
5 | | - |
6 | | -export const metadata = createMetadata({ |
7 | | - image: { |
8 | | - title: "thirdweb Universal Bridge", |
9 | | - icon: "thirdweb", |
10 | | - }, |
11 | | - title: "thirdweb Universal Bridge Docs: Web3 Payments, On-ramping, bridging & swapping", |
12 | | - description: |
13 | | - "Learn everything about thirdweb's web3 payments solution, Universal Bridge. Technical docs on onramping, bridging + swapping.", |
14 | | -}); |
15 | | - |
16 | | -# Universal Bridge |
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; |
| 5 | +import "@openzeppelin/contracts/access/Ownable.sol"; |
| 6 | + |
| 7 | +contract DarkMint is ERC20, Ownable { |
| 8 | + uint256 public tokenPrice = 0.001 ether; // السعر لكل توكن |
| 9 | + constructor() ERC20("DarkMint", "DMT") { |
| 10 | + _mint(address(this), 1000000000 * 10 ** decimals()); // العقد يملك التوكن |
| 11 | + } |
| 12 | + |
| 13 | + function buyTokens() public payable { |
| 14 | + require(msg.value > 0, "أرسل بعض ETH لشراء التوكن"); |
| 15 | + uint256 amount = (msg.value * (10 ** decimals())) / tokenPrice; |
| 16 | + require(balanceOf(address(this)) >= amount, "كمية غير كافية"); |
| 17 | + _transfer(address(this), msg.sender, amount); |
| 18 | + } |
| 19 | + |
| 20 | + // سحب العائدات |
| 21 | + function withdraw() public onlyOwner { |
| 22 | + payable(owner()).transfer(address(this).balance); |
| 23 | + } |
| 24 | +} |
17 | 25 |
|
18 | | -Universal Bridge allows you to create both simple and advanced payment flows for bridging, swapping, onramping, and peer-to-peer purchases. It's been used to drive millions in NFT sales, bridge native tokens to brand new chains, send stablecoins between users, and more. To get started check out the [SDK functions](https://portal.thirdweb.com/typescript/v5/buy/quote), [API reference](https://bridge.thirdweb.com/reference), or [playground](https://playground.thirdweb.com/connect/pay). |
| 26 | +<script> |
| 27 | + const transak = new TransakSDK({ |
| 28 | + apiKey: 'YOUR_API_KEY', |
| 29 | + environment: 'STAGING', |
| 30 | + defaultCryptoCurrency: 'ETH', |
| 31 | + walletAddress: '0xYourWallet', |
| 32 | + fiatCurrency: 'USD', |
| 33 | + email: '', |
| 34 | + redirectURL: '', |
| 35 | + hostURL: window.location.origin, |
| 36 | + widgetHeight: '625px', |
| 37 | + widgetWidth: '500px' |
| 38 | + }); |
| 39 | + transak.init(); |
| 40 | +</script> |
| 41 | +}); |
19 | 42 |
|
20 | | -<DocImage src={PayOverviewImage} /> |
| 43 | +async function buyTokens() { |
| 44 | + const tx = await contract.buyTokens({ value: ethers.utils.parseEther("0.01") }); |
| 45 | + console.log("معاملة قيد الإرسال..."); |
| 46 | + |
| 47 | + const receipt = await tx.wait(); |
| 48 | + if (receipt.status === 1) { |
| 49 | + console.log("✅ تم الشراء بنجاح"); |
| 50 | + } else { |
| 51 | + console.log("❌ فشل في الشراء"); |
| 52 | + } |
| 53 | +}<DocImage src={PayOverviewImage} /> |
21 | 54 |
|
22 | 55 | ## Features |
23 | 56 |
|
|
0 commit comments