-
Notifications
You must be signed in to change notification settings - Fork 671
Update page.mdx #8793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
obadaibrahimelamairh-bit
wants to merge
1
commit into
thirdweb-dev:main
Choose a base branch
from
obadaibrahimelamairh-bit:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−69
Open
Update page.mdx #8793
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,29 @@ | ||
| import { Breadcrumb, createMetadata, ArticleIconCard, Stack } from "@doc"; | ||
| import { ComponentIcon } from "lucide-react"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| image: { | ||
| title: "Accounts & Wallets", | ||
| icon: "typescript", | ||
| }, | ||
| title: "Accounts & Wallets | thirdweb SDK", | ||
| description: "Learn about accounts and wallets in the thirdweb SDK.", | ||
| }); | ||
|
|
||
| # Accounts & Wallets | ||
|
|
||
| We distinguish between "accounts" and "wallets" in the thirdweb SDK. We believe this ultimately provides a more predictable and flexible API for developers. | ||
|
|
||
| ## What is an Account? | ||
|
|
||
| - An account always has an `address` and a way to `sign` messages, transactions, and typed data. | ||
| - An account is always mapped to exactly one address on the blockchain. | ||
| - An account cannot be "connected" or "disconnected" like a wallet, instead it is often the result of a wallet being connected. | ||
|
|
||
| See also: [Account (ethereum.org)](https://ethereum.org/en/glossary/#account) | ||
|
|
||
| ## What is a Wallet? | ||
|
|
||
| - A wallet "contains" one or more accounts. | ||
| - A wallet can be "connected" (often prompting the user for approval) or "disconnected". | ||
| - A wallet cannot independently sign messages, transactions, or typed data, instead, it delegates this to the account(s) it "contains". | ||
|
|
||
|
|
||
| <Stack> | ||
|
|
||
| <ArticleIconCard | ||
| title="Supported Wallets" | ||
| icon={ComponentIcon} | ||
| href="/wallets/external-wallets" | ||
| description="See all 500+ wallets supported by the thirdweb SDKs" | ||
| /> | ||
|
|
||
| </Stack> | ||
|
|
||
| ## Example: Connect a wallet and access an account to send a transaction. | ||
|
|
||
| ```ts | ||
| import { sendTransaction } from "thirdweb"; | ||
| // We use MetaMask wallet as an example, the pattern is the same for all wallets | ||
| import { createWallet } from "thirdweb/wallets"; | ||
|
|
||
| // initialize the wallet, you can pick any of the 300+ wallet connectors supported | ||
| // wallet ids are typed, let your TS editor autocomplete them for you | ||
| // ex: "io.metamask", "com.coinbase.wallet", "me.rainbow", etc... | ||
| const wallet = createWallet("io.metamask"); | ||
|
|
||
| // connect the wallet, this returns a promise that resolves to the connected account | ||
| const account = await wallet.connect({ | ||
| // pass the client you created with `createThirdwebClient()` | ||
| client, | ||
| }); | ||
|
|
||
| // sign & send a transaction with the account -> returns the transaction hash | ||
| const { transactionHash } = await sendTransaction({ | ||
| // assuming you have called `prepareTransaction()` or `prepareContractCall()` before which returns the prepared transaction to send | ||
| transaction, | ||
| // Pass the account to sign the transaction with | ||
| account, | ||
| }); | ||
| ``` | ||
|
|
||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.20; | ||
|
|
||
| import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; | ||
| import "@openzeppelin/contracts/access/AccessControl.sol"; | ||
|
|
||
| contract GreenbackReward is ERC1155, AccessControl { | ||
| // دور خاص للمُحققين الذين سيراجعون الصور | ||
| bytes32 public constant VERIFIER_ROLE = keccak256("VERIFIER_ROLE"); | ||
|
|
||
| // معرف الرمز الخاص بنقاط إعادة التدوير | ||
| uint256 public constant RECYCLE_TOKEN = 1; | ||
|
|
||
| constructor() ERC1155("https://api.greenback.io/tokens/{id}.json") { | ||
| _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); | ||
| } | ||
|
|
||
| // دالة منح المكافأة: تُستخدم فقط من قِبل المُحققين بعد مراجعة الصورة | ||
| function grantRecycleReward(address user, uint256 quantity) public onlyRole(VERIFIER_ROLE) { | ||
| // كل وحدة تدوير (صورة) تساوي 10 نقاط | ||
| uint256 rewardAmount = quantity * 10; | ||
| _mint(user, RECYCLE_TOKEN, rewardAmount, ""); | ||
| } | ||
|
|
||
| // دالة لدعم الواجهات البرمجية | ||
| function supportsInterface(bytes4 interfaceId) public view override(ERC1155, AccessControl) returns (bool) { | ||
| return super.supportsInterface(interfaceId); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Documentation page replaced with unrelated Solidity contract code.
This PR replaces the TypeScript SDK wallet documentation (
/typescript/v5/wallets) with a Solidity smart contract. This is problematic for several reasons:.mdxfile meant for documentation. Raw Solidity code will cause MDX parsing errors.send/page.mdx,migrate/page.mdx) link to this route expecting wallet documentation.typescript/v5/wallets/page.mdxis clearly for TypeScript SDK documentation, not a Solidity contract.This change should be reverted. If the
GreenbackRewardcontract is intended to be added to the repository, it belongs in a different location (likely a contracts directory with a.solextension).🤖 Prompt for AI Agents