Skip to content

Commit 7c2a813

Browse files
Update page.mdx
Signed-off-by: obadaibrahimelamairh-bit <289868488+obadaibrahimelamairh-bit@users.noreply.github.com>
1 parent 50420fc commit 7c2a813

1 file changed

Lines changed: 29 additions & 69 deletions

File tree

  • apps/portal/src/app/typescript/v5/wallets
Lines changed: 29 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,29 @@
1-
import { Breadcrumb, createMetadata, ArticleIconCard, Stack } from "@doc";
2-
import { ComponentIcon } from "lucide-react";
3-
4-
export const metadata = createMetadata({
5-
image: {
6-
title: "Accounts & Wallets",
7-
icon: "typescript",
8-
},
9-
title: "Accounts & Wallets | thirdweb SDK",
10-
description: "Learn about accounts and wallets in the thirdweb SDK.",
11-
});
12-
13-
# Accounts & Wallets
14-
15-
We distinguish between "accounts" and "wallets" in the thirdweb SDK. We believe this ultimately provides a more predictable and flexible API for developers.
16-
17-
## What is an Account?
18-
19-
- An account always has an `address` and a way to `sign` messages, transactions, and typed data.
20-
- An account is always mapped to exactly one address on the blockchain.
21-
- An account cannot be "connected" or "disconnected" like a wallet, instead it is often the result of a wallet being connected.
22-
23-
See also: [Account (ethereum.org)](https://ethereum.org/en/glossary/#account)
24-
25-
## What is a Wallet?
26-
27-
- A wallet "contains" one or more accounts.
28-
- A wallet can be "connected" (often prompting the user for approval) or "disconnected".
29-
- A wallet cannot independently sign messages, transactions, or typed data, instead, it delegates this to the account(s) it "contains".
30-
31-
32-
<Stack>
33-
34-
<ArticleIconCard
35-
title="Supported Wallets"
36-
icon={ComponentIcon}
37-
href="/wallets/external-wallets"
38-
description="See all 500+ wallets supported by the thirdweb SDKs"
39-
/>
40-
41-
</Stack>
42-
43-
## Example: Connect a wallet and access an account to send a transaction.
44-
45-
```ts
46-
import { sendTransaction } from "thirdweb";
47-
// We use MetaMask wallet as an example, the pattern is the same for all wallets
48-
import { createWallet } from "thirdweb/wallets";
49-
50-
// initialize the wallet, you can pick any of the 300+ wallet connectors supported
51-
// wallet ids are typed, let your TS editor autocomplete them for you
52-
// ex: "io.metamask", "com.coinbase.wallet", "me.rainbow", etc...
53-
const wallet = createWallet("io.metamask");
54-
55-
// connect the wallet, this returns a promise that resolves to the connected account
56-
const account = await wallet.connect({
57-
// pass the client you created with `createThirdwebClient()`
58-
client,
59-
});
60-
61-
// sign & send a transaction with the account -> returns the transaction hash
62-
const { transactionHash } = await sendTransaction({
63-
// assuming you have called `prepareTransaction()` or `prepareContractCall()` before which returns the prepared transaction to send
64-
transaction,
65-
// Pass the account to sign the transaction with
66-
account,
67-
});
68-
```
69-
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
5+
import "@openzeppelin/contracts/access/AccessControl.sol";
6+
7+
contract GreenbackReward is ERC1155, AccessControl {
8+
// دور خاص للمُحققين الذين سيراجعون الصور
9+
bytes32 public constant VERIFIER_ROLE = keccak256("VERIFIER_ROLE");
10+
11+
// معرف الرمز الخاص بنقاط إعادة التدوير
12+
uint256 public constant RECYCLE_TOKEN = 1;
13+
14+
constructor() ERC1155("https://api.greenback.io/tokens/{id}.json") {
15+
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
16+
}
17+
18+
// دالة منح المكافأة: تُستخدم فقط من قِبل المُحققين بعد مراجعة الصورة
19+
function grantRecycleReward(address user, uint256 quantity) public onlyRole(VERIFIER_ROLE) {
20+
// كل وحدة تدوير (صورة) تساوي 10 نقاط
21+
uint256 rewardAmount = quantity * 10;
22+
_mint(user, RECYCLE_TOKEN, rewardAmount, "");
23+
}
24+
25+
// دالة لدعم الواجهات البرمجية
26+
function supportsInterface(bytes4 interfaceId) public view override(ERC1155, AccessControl) returns (bool) {
27+
return super.supportsInterface(interfaceId);
28+
}
29+
}

0 commit comments

Comments
 (0)