Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const config = {
markdown: {
mermaid: true,
hooks: {
onBrokenMarkdownLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
},
},
themes: ['@docusaurus/theme-mermaid'],
Expand Down
105 changes: 53 additions & 52 deletions sdk-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,76 +49,77 @@ const sdkSidebar = {
],
evm: [
'evm/index',
{
type: 'category',
label: 'Quickstart',
collapsible: false,
collapsed: false,
items: [
'evm/connect/quickstart/javascript',
'evm/connect/quickstart/wagmi',
'evm/connect/quickstart/rainbowkit',
'evm/connect/quickstart/connectkit',
'evm/connect/quickstart/react-native',
'evm/connect/quickstart/dynamic',
'evm/connect/quickstart/web3auth',
],
},
{
type: 'category',
label: 'Guides',
collapsible: false,
collapsed: false,
items: [
'evm/connect/guides/manage-user-accounts',
'evm/connect/guides/manage-networks',
{
type: 'category',
label: 'JavaScript',
label: 'Send transactions',
collapsible: true,
collapsed: true,
link: { type: "doc", id: "evm/connect/guides/javascript/index" },
link: { type: "doc", id: "evm/connect/guides/send-transactions/index" },
items: [
'evm/connect/guides/javascript/manage-user-accounts',
'evm/connect/guides/javascript/manage-networks',
{
type: 'category',
label: 'Send transactions',
collapsible: true,
collapsed: true,
link: { type: "doc", id: "evm/connect/guides/javascript/send-transactions/index" },
items: [
'evm/connect/guides/javascript/send-transactions/batch-transactions',
],
},
{
type: 'category',
label: 'Sign data',
collapsible: true,
collapsed: true,
link: { type: "doc", id: "evm/connect/guides/javascript/sign-data/index" },
items: [
'evm/connect/guides/javascript/sign-data/siwe',
],
},
'evm/connect/guides/javascript/batch-requests',
'evm/connect/guides/javascript/interact-with-contracts',
'evm/connect/guides/javascript/use-deeplinks',
'evm/connect/guides/javascript/display-tokens',
{
type: 'category',
label: 'Best practices',
collapsible: true,
collapsed: true,
items: [
'evm/connect/guides/javascript/best-practices/display',
'evm/connect/guides/javascript/best-practices/run-devnet',
'evm/connect/guides/javascript/best-practices/production-readiness',
],
},
'evm/connect/guides/send-transactions/batch-transactions',
],
},
{
type: 'category',
label: 'Wagmi',
label: 'Sign data',
collapsible: true,
collapsed: true,
link: { type: "doc", id: "evm/connect/guides/wagmi/index" },
link: { type: "doc", id: "evm/connect/guides/sign-data/index" },
items: [
'evm/connect/guides/wagmi/manage-user-accounts',
'evm/connect/guides/wagmi/manage-networks',
'evm/connect/guides/wagmi/send-transactions',
'evm/connect/guides/wagmi/interact-with-contracts',
'evm/connect/guides/sign-data/siwe',
],
},
'evm/connect/guides/rainbowkit',
'evm/connect/guides/connectkit',
'evm/connect/guides/react-native',
'evm/connect/guides/dynamic',
'evm/connect/guides/web3auth',
'evm/connect/guides/interact-with-contracts',
{
type: 'category',
label: 'MetaMask Exclusive',
collapsible: true,
collapsed: true,
items: [
'evm/connect/guides/batch-requests',
'evm/connect/guides/use-deeplinks',
'evm/connect/guides/display-tokens',
'evm/connect/guides/best-practices/display',
'evm/connect/guides/best-practices/run-devnet',
'evm/connect/guides/best-practices/production-readiness',
],
},
// {
// type: 'category',
// label: 'Wagmi',
// collapsible: true,
// collapsed: true,
// link: { type: "doc", id: "evm/connect/guides/wagmi/index" },
// items: [
// 'evm/connect/guides/wagmi/manage-user-accounts',
// 'evm/connect/guides/wagmi/manage-networks',
// 'evm/connect/guides/wagmi/send-transactions',
// 'evm/connect/guides/wagmi/interact-with-contracts',
// ],
// },
],
},
{
Expand All @@ -132,7 +133,7 @@ const sdkSidebar = {
label: "Create a wallet AI agent",
href: "/tutorials/create-wallet-ai-agent"
},
{
{
type: "link",
label: "Upgrade an EOA to a smart account",
href: "/tutorials/upgrade-eoa-to-smart-account"
Expand All @@ -152,7 +153,7 @@ const sdkSidebar = {
label: "JSON-RPC API",
collapsible: true,
collapsed: true,
link: { type: "doc", id: "evm/connect/reference/json-rpc-api/index" },
link: { type: "doc", id: "evm/connect/reference/json-rpc-api/index" },
items: [
"evm/connect/reference/json-rpc-api/wallet_sendCalls",
"evm/connect/reference/json-rpc-api/eth_signTypedData_v4",
Expand Down
Binary file modified sdk/evm/connect/_assets/personal_sign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sdk/evm/connect/_assets/signTypedData.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sdk/evm/connect/_assets/siwe-bad-domain-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sdk/evm/connect/_assets/siwe-bad-domain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sdk/evm/connect/_assets/siwe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ These requests can be contract calls or other JSON-RPC methods (for example, sig
Despite being batched into one HTTP request, each call still requires individual user approval, and if any request is rejected, the entire batch fails.

:::info
"Batching" can also refer to [Wagmi contract read batching](../wagmi/interact-with-contracts.md#batch-contract-reads) or
"Batching" can also refer to [Wagmi contract read batching](./wagmi/interact-with-contracts.md#batch-contract-reads) or
[sending atomic batch transactions](send-transactions/batch-transactions.md) in MetaMask.
:::

Expand All @@ -29,44 +29,44 @@ When using `metamask_batch`, keep in mind the following:

- Even though the requests are batched, each individual request still requires user approval.
- If any request in the batch is rejected, the entire batch will fail.
:::
:::

The following is an example of batching JSON-RPC requests using `metamask_batch`:

```js
import { createEVMClient } from "@metamask/connect/evm";
import { createEVMClient } from '@metamask/connect/evm'

const evmClient = createEVMClient();
const provider = evmClient.getProvider();
const evmClient = createEVMClient()
const provider = evmClient.getProvider()

async function handleBatchRequests() {
// Example batch: one personal_sign call and one eth_sendTransaction call.
const requests = [
{ method: "personal_sign", params: ["Hello from batch!", "0x1234..."] },
{ method: 'personal_sign', params: ['Hello from batch!', '0x1234...'] },
{
method: "eth_sendTransaction",
method: 'eth_sendTransaction',
params: [
{
from: "0x1234...",
to: "0xABCD...",
from: '0x1234...',
to: '0xABCD...',
// Additional transaction parameters.
},
],
},
];
]

try {
const results = await provider.request({
method: "metamask_batch",
method: 'metamask_batch',
params: [requests],
});
console.log("Batch Results:", results);
})
console.log('Batch Results:', results)
} catch (err) {
console.error("Batch request failed:", err);
console.error('Batch request failed:', err)
}
}

document.getElementById("batchBtn").addEventListener("click", handleBatchRequests);
document.getElementById('batchBtn').addEventListener('click', handleBatchRequests)
```

The following HTML displays a **Send Batch** button:
Expand All @@ -76,7 +76,8 @@ The following HTML displays a **Send Batch** button:
```

:::tip Tips

- For a better user experience, it's important to use reliable RPC providers instead of public nodes.
We recommend using services like [MetaMask Developer](https://developer.metamask.io/) to ensure better reliability and performance.
- Ensure that requests in a batch do not depend on one another's chain context, as mid-batch state changes can affect outcomes.
:::
:::
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ extension (not on mobile).
To prompt users to add an ERC-20 token, you can add something like the following to your project script:

```javascript
import { createEVMClient } from "@metamask/connect/evm";
import { createEVMClient } from '@metamask/connect/evm'

const evmClient = createEVMClient();
const provider = evmClient.getProvider();
const evmClient = createEVMClient()
const provider = evmClient.getProvider()

const tokenAddress = "0xd00981105e61274c8a5cd5a88fe7e037d935b513"
const tokenSymbol = "TUT"
const tokenAddress = '0xd00981105e61274c8a5cd5a88fe7e037d935b513'
const tokenSymbol = 'TUT'
const tokenDecimals = 18
const tokenImage = "http://placekitten.com/200/300"
const tokenImage = 'http://placekitten.com/200/300'

try {
// 'wasAdded' is a boolean. Like any RPC method, an error can be thrown.
const wasAdded = await provider.request({
method: "wallet_watchAsset",
method: 'wallet_watchAsset',
params: {
type: "ERC20",
type: 'ERC20',
options: {
// The address of the token.
address: tokenAddress,
Expand All @@ -68,9 +68,9 @@ try {
})

if (wasAdded) {
console.log("Thanks for your interest!")
console.log('Thanks for your interest!')
} else {
console.log("Your loss!")
console.log('Your loss!')
}
} catch (error) {
console.log(error)
Expand All @@ -83,7 +83,7 @@ We recommend [detecting the user's network chain ID](manage-networks.md) and
prompting them to switch chains, if necessary.
:::

For another example, [WatchToken](https://vittominacori.github.io/watch-token/create/) is a
For another example, [WatchToken](https://vittominacori.github.io/watch-token/create/) is a
live web dapp that lets you enter your token details and share them using a web link.

## Display NFTs
Expand All @@ -101,10 +101,10 @@ The add NFT interfaces look like the following:

<div class="imgRow">
<div class="imgCol">
<img src={require("../../_assets/watchasset-nft.png").default} alt="NFT confirmation" class="appScreen" />
<img src={require("../_assets/watchasset-nft.png").default} alt="NFT confirmation" class="appScreen" />
</div>
<div class="imgCol">
<img src={require("../../_assets/watchasset-nft-2.png").default} alt="Multiple NFTs confirmation" class="appScreen" />
<img src={require("../_assets/watchasset-nft-2.png").default} alt="Multiple NFTs confirmation" class="appScreen" />
</div>
</div>

Expand All @@ -114,30 +114,30 @@ To prompt users to add a single NFT, add something like the following to your pr
`wallet_watchAsset` supports both ERC-721 and ERC-1155 NFT standards.

```javascript
import { createEVMClient } from "@metamask/connect/evm";
import { createEVMClient } from '@metamask/connect/evm'

const evmClient = createEVMClient();
const provider = evmClient.getProvider();
const evmClient = createEVMClient()
const provider = evmClient.getProvider()

try {
// wasAdded is a boolean. Like any RPC method, an error can be thrown.
const wasAdded = await provider.request({
method: "wallet_watchAsset",
method: 'wallet_watchAsset',
params: {
type: "ERC721", // Or "ERC1155".
type: 'ERC721', // Or "ERC1155".
options: {
// The address of the token.
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
// ERC-721 or ERC-1155 token ID.
tokenId: "1",
tokenId: '1',
},
},
})

if (wasAdded) {
console.log("User successfully added the token!")
console.log('User successfully added the token!')
} else {
console.log("User did not add the token.")
console.log('User did not add the token.')
}
} catch (error) {
console.log(error)
Expand Down
Loading