From 93cc73b655916f3882dd601d10e062500ea27bc1 Mon Sep 17 00:00:00 2001 From: httpjunkie Date: Wed, 18 Sep 2024 06:28:46 +0800 Subject: [PATCH 1/2] Update SDK supported features matrix/table --- wallet/connect/index.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/wallet/connect/index.md b/wallet/connect/index.md index a5fed8bc61..1f030e7fba 100644 --- a/wallet/connect/index.md +++ b/wallet/connect/index.md @@ -16,14 +16,10 @@ Compares the supported features of each connection option: | Feature | MetaMask SDK only | Third-party libraries with SDK | Wallet API only | |------------------------------------------------------------------------------------------------|:-----------------:|:------------------------------:|:---------------:| | Connect from a web dapp to the MetaMask extension | ✅ | ✅ | ✅ | -| Connect from a web dapp to MetaMask Mobile | ✅ | ✅ | ❌ | -| Connect from desktop, mobile, and gaming dapps to MetaMask Mobile | ✅ | ✅ | ❌ | +| Connect from a web dapp, desktop, mobile, and gaming dapps to MetaMask Mobile | ✅ | ✅ | ❌ | | Connect to MetaMask using the [EIP-6963 provider](../concepts/wallet-interoperability.md) | ✅ | ✅ | ✅ | | Connect to other wallets using the [EIP-6963 provider](../concepts/wallet-interoperability.md) | ❌ | ✅ | ✅ | -| Use custom RPC methods such as [`connectAndSign`](../how-to/sign-data/connect-and-sign.md) | ✅ | ✅ | ❌ | -| [Display custom modals](../how-to/display/display-custom-modals.md) in MetaMask | ✅ | ✅ | ❌ | -| [Make read-only requests](../how-to/make-read-only-requests.md) using the Infura API | ✅ | ✅ | ❌ | -| [Batch multiple RPC requests](../how-to/batch-json-rpc-requests.md) | ✅ | ✅ | ❌ | +| Custom RPC methods such as [`connectAndSign`](../how-to/sign-data/connect-and-sign.md), [display custom modals](../how-to/display/display-custom-modals.md), [read-only requests](../how-to/make-read-only-requests.md) using Infura API, and [batch RPC requests](../how-to/batch-json-rpc-requests.md) | ✅ | ✅ | ❌ | ## MetaMask SDK From bdbd1ccda01bc66e45ca7e8ac97efa9094b4bee5 Mon Sep 17 00:00:00 2001 From: httpjunkie Date: Wed, 18 Sep 2024 07:25:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Move=20"how=20to=20>=20Use=20MetaMask=20SDK?= =?UTF-8?q?"=20directory=20into=20"Connect"=20section=C2=A0and=20update=20?= =?UTF-8?q?`wallet-sidebar.js`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wallet-sidebar.js | 7 +- .../metamask-sdk}/gaming/index.md | 0 .../gaming/unity/connect-and-sign.md | 0 .../metamask-sdk}/gaming/unity/dweb.md | 0 .../metamask-sdk}/gaming/unity/index.md | 0 .../metamask-sdk}/gaming/unity/infura.md | 0 .../unity/smart-contracts/contract-factory.md | 0 .../smart-contracts/contract-interface.md | 0 .../smart-contracts/contract-provider.md | 0 .../smart-contracts/contract-proxy-class.md | 0 .../gaming/unity/smart-contracts/index.md | 0 .../metamask-sdk}/gaming/unreal-engine.md | 0 .../use-sdk => connect/metamask-sdk}/index.md | 0 .../metamask-sdk}/javascript/electron.md | 0 .../metamask-sdk}/javascript/index.md | 0 .../metamask-sdk}/javascript/nodejs.md | 0 .../javascript/other-web-frameworks.md | 0 .../metamask-sdk}/javascript/pure-js.md | 0 .../metamask-sdk}/javascript/react/index.md | 0 .../javascript/react/react-ui.md | 0 .../metamask-sdk}/mobile/android.md | 0 .../metamask-sdk}/mobile/index.md | 0 .../metamask-sdk}/mobile/ios.md | 0 .../metamask-sdk}/mobile/react-native.md | 0 wallet/connect/sdk.md | 113 ------------------ 25 files changed, 4 insertions(+), 116 deletions(-) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/connect-and-sign.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/dweb.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/infura.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/smart-contracts/contract-factory.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/smart-contracts/contract-interface.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/smart-contracts/contract-provider.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/smart-contracts/contract-proxy-class.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unity/smart-contracts/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/gaming/unreal-engine.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/electron.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/nodejs.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/other-web-frameworks.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/pure-js.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/react/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/javascript/react/react-ui.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/mobile/android.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/mobile/index.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/mobile/ios.md (100%) rename wallet/{how-to/use-sdk => connect/metamask-sdk}/mobile/react-native.md (100%) delete mode 100644 wallet/connect/sdk.md diff --git a/wallet-sidebar.js b/wallet-sidebar.js index 436b42e9ce..d87a9186ef 100644 --- a/wallet-sidebar.js +++ b/wallet-sidebar.js @@ -10,13 +10,14 @@ const sidebar = { link: {type: "doc", id: "connect/index"}, items: [ { - type: "doc", - id: "connect/sdk", + type: "category", + label: "MetaMask SDK", + link: {type: "doc", id: "connect/metamask-sdk/index"}, + items: [{ type: "autogenerated", dirName: "connect/metamask-sdk" }], }, { type: "category", label: "Third-party libraries", - collapsed: false, items: [{ type: "autogenerated", dirName: "connect/3rd-party-libraries" }], }, { diff --git a/wallet/how-to/use-sdk/gaming/index.md b/wallet/connect/metamask-sdk/gaming/index.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/index.md rename to wallet/connect/metamask-sdk/gaming/index.md diff --git a/wallet/how-to/use-sdk/gaming/unity/connect-and-sign.md b/wallet/connect/metamask-sdk/gaming/unity/connect-and-sign.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/connect-and-sign.md rename to wallet/connect/metamask-sdk/gaming/unity/connect-and-sign.md diff --git a/wallet/how-to/use-sdk/gaming/unity/dweb.md b/wallet/connect/metamask-sdk/gaming/unity/dweb.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/dweb.md rename to wallet/connect/metamask-sdk/gaming/unity/dweb.md diff --git a/wallet/how-to/use-sdk/gaming/unity/index.md b/wallet/connect/metamask-sdk/gaming/unity/index.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/index.md rename to wallet/connect/metamask-sdk/gaming/unity/index.md diff --git a/wallet/how-to/use-sdk/gaming/unity/infura.md b/wallet/connect/metamask-sdk/gaming/unity/infura.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/infura.md rename to wallet/connect/metamask-sdk/gaming/unity/infura.md diff --git a/wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-factory.md b/wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-factory.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-factory.md rename to wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-factory.md diff --git a/wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-interface.md b/wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-interface.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-interface.md rename to wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-interface.md diff --git a/wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-provider.md b/wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-provider.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-provider.md rename to wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-provider.md diff --git a/wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-proxy-class.md b/wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-proxy-class.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/smart-contracts/contract-proxy-class.md rename to wallet/connect/metamask-sdk/gaming/unity/smart-contracts/contract-proxy-class.md diff --git a/wallet/how-to/use-sdk/gaming/unity/smart-contracts/index.md b/wallet/connect/metamask-sdk/gaming/unity/smart-contracts/index.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unity/smart-contracts/index.md rename to wallet/connect/metamask-sdk/gaming/unity/smart-contracts/index.md diff --git a/wallet/how-to/use-sdk/gaming/unreal-engine.md b/wallet/connect/metamask-sdk/gaming/unreal-engine.md similarity index 100% rename from wallet/how-to/use-sdk/gaming/unreal-engine.md rename to wallet/connect/metamask-sdk/gaming/unreal-engine.md diff --git a/wallet/how-to/use-sdk/index.md b/wallet/connect/metamask-sdk/index.md similarity index 100% rename from wallet/how-to/use-sdk/index.md rename to wallet/connect/metamask-sdk/index.md diff --git a/wallet/how-to/use-sdk/javascript/electron.md b/wallet/connect/metamask-sdk/javascript/electron.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/electron.md rename to wallet/connect/metamask-sdk/javascript/electron.md diff --git a/wallet/how-to/use-sdk/javascript/index.md b/wallet/connect/metamask-sdk/javascript/index.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/index.md rename to wallet/connect/metamask-sdk/javascript/index.md diff --git a/wallet/how-to/use-sdk/javascript/nodejs.md b/wallet/connect/metamask-sdk/javascript/nodejs.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/nodejs.md rename to wallet/connect/metamask-sdk/javascript/nodejs.md diff --git a/wallet/how-to/use-sdk/javascript/other-web-frameworks.md b/wallet/connect/metamask-sdk/javascript/other-web-frameworks.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/other-web-frameworks.md rename to wallet/connect/metamask-sdk/javascript/other-web-frameworks.md diff --git a/wallet/how-to/use-sdk/javascript/pure-js.md b/wallet/connect/metamask-sdk/javascript/pure-js.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/pure-js.md rename to wallet/connect/metamask-sdk/javascript/pure-js.md diff --git a/wallet/how-to/use-sdk/javascript/react/index.md b/wallet/connect/metamask-sdk/javascript/react/index.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/react/index.md rename to wallet/connect/metamask-sdk/javascript/react/index.md diff --git a/wallet/how-to/use-sdk/javascript/react/react-ui.md b/wallet/connect/metamask-sdk/javascript/react/react-ui.md similarity index 100% rename from wallet/how-to/use-sdk/javascript/react/react-ui.md rename to wallet/connect/metamask-sdk/javascript/react/react-ui.md diff --git a/wallet/how-to/use-sdk/mobile/android.md b/wallet/connect/metamask-sdk/mobile/android.md similarity index 100% rename from wallet/how-to/use-sdk/mobile/android.md rename to wallet/connect/metamask-sdk/mobile/android.md diff --git a/wallet/how-to/use-sdk/mobile/index.md b/wallet/connect/metamask-sdk/mobile/index.md similarity index 100% rename from wallet/how-to/use-sdk/mobile/index.md rename to wallet/connect/metamask-sdk/mobile/index.md diff --git a/wallet/how-to/use-sdk/mobile/ios.md b/wallet/connect/metamask-sdk/mobile/ios.md similarity index 100% rename from wallet/how-to/use-sdk/mobile/ios.md rename to wallet/connect/metamask-sdk/mobile/ios.md diff --git a/wallet/how-to/use-sdk/mobile/react-native.md b/wallet/connect/metamask-sdk/mobile/react-native.md similarity index 100% rename from wallet/how-to/use-sdk/mobile/react-native.md rename to wallet/connect/metamask-sdk/mobile/react-native.md diff --git a/wallet/connect/sdk.md b/wallet/connect/sdk.md deleted file mode 100644 index f49276de4d..0000000000 --- a/wallet/connect/sdk.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -sidebar_label: MetaMask SDK -description: Connect to MetaMask using MetaMask SDK. -tags: - - JavaScript SDK ---- - -# Connect to MetaMask using the SDK - -Import MetaMask SDK into your dapp to enable your -users to easily connect to the MetaMask browser extension and MetaMask Mobile. - -The following instructions work for web dapps based on standard JavaScript. -You can also see instructions for other dapp platforms supported by the SDK: - -- [JavaScript](../how-to/use-sdk/javascript/index.md) -- [Mobile](../how-to/use-sdk/mobile/index.md) -- [Gaming](../how-to/use-sdk/gaming/index.md) - -## Prerequisites - -- A JavaScript project set up -- [MetaMask Mobile](https://github.com/MetaMask/metamask-mobile) version 5.8.1 or later -- [Yarn](https://yarnpkg.com/getting-started/install) or - [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - -## Steps - -### 1. Install the SDK - -In your project directory, install the SDK using Yarn or npm: - -```bash -yarn add @metamask/sdk -``` - -or - -```bash -npm i @metamask/sdk -``` - -### 2. Import the SDK - -In your project script, add the following to import the SDK: - -```javascript title="index.js" -import { MetaMaskSDK } from "@metamask/sdk" -``` - -### 3. Instantiate the SDK - -Instantiate the SDK using any [options](../reference/sdk-js-options.md): - -```javascript title="index.js" -const MMSDK = new MetaMaskSDK({ - dappMetadata: { - name: "JavaScript example dapp", - url: window.location.href, - }, - infuraAPIKey: process.env.INFURA_API_KEY, - // Other options. -}) - -// You can also access via window.ethereum. -const ethereum = MMSDK.getProvider() -``` - -- Use [`dappMetadata`](../reference/sdk-js-options.md#dappmetadata) to display information - about your dapp in the MetaMask connection modal. -- Use [`infuraAPIKey`](../reference/sdk-js-options.md#infuraapikey) to - [make read-only RPC requests](../how-to/make-read-only-requests.md) from your dapp. -- Use [`modals`](../reference/sdk-js-options.md#modals) to [customize the logic and UI of - the displayed modals](../how-to/display/display-custom-modals.md). - -### 4. Use the SDK - -Use the SDK by calling any [provider API methods](../reference/provider-api.md). -Always call [`eth_requestAccounts`](/wallet/reference/eth_requestaccounts) using -[`request()`](../reference/provider-api.md#request) first, since it -prompts the installation or connection popup to appear. - -```javascript -ethereum.request({ method: "eth_requestAccounts", params: [] }) -``` - -You can also call the SDK's [`connectAndSign`](../how-to/sign-data/connect-and-sign.md) method, and -[batch multiple JSON-RPC requests](../how-to/batch-json-rpc-requests.md) using the `metamask_batch` method. - -## Example - -You can copy the full JavaScript example to get started: - -```javascript title="index.js" -import { MetaMaskSDK } from "@metamask/sdk" - -const MMSDK = new MetaMaskSDK({ - dappMetadata: { - name: "Example JavaScript Dapp", - url: window.location.href, - }, - infuraAPIKey: process.env.INFURA_API_KEY, - // Other options. -}) - -// You can also access via window.ethereum. -const ethereum = MMSDK.getProvider() - -ethereum.request({ method: "eth_requestAccounts", params: [] }) -``` - -See the [example JavaScript dapps](https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples) -in the JavaScript SDK GitHub repository for more information.