Skip to content

Commit 0ec16da

Browse files
Merge pull request 0xPolygon#490 from 0xPolygon/devtools/docs-189
Dev tools: Tidying up the wallet section
2 parents bad1932 + 79a67b6 commit 0ec16da

File tree

18 files changed

+123
-516
lines changed

18 files changed

+123
-516
lines changed
-91.1 KB
Binary file not shown.
-74.5 KB
Binary file not shown.
-83.5 KB
Binary file not shown.
-144 KB
Binary file not shown.
-37.4 KB
Binary file not shown.

docs/tools/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ hide:
1515
<h1 class="hero-heading">Developer tools</h1>
1616
<p class="hero-subtext">This section describes some of the in-house and third-party tools that are used by developers to work with Polygon products and services.</p>
1717
<p class="hero-subtext">Find out how to access data, code against blockchain networks, use oracles, and much more. </p>
18+
<i><p class="hero-subtext">All third-party content in this section is covered by our <a href="https://github.com/0xPolygon/polygon-docs/blob/main/CONTENT_DISCLAIMER.md">content disclaimer</a>.</i>
19+
1820
</div>
1921
</div>
2022
<div class="grid-container">
2123
<div class="grid-item">
2224
<a href="./dApp-development/launchpad/intro">
2325
<div class="product-list-item-header">
24-
<div class="feature-card-heading">dApp Launchpadd</div>
26+
<div class="feature-card-heading">dApp Launchpad</div>
2527
</div>
2628
<p class="feature-paragraph">Automated CLI tool for initializing, creating, and deploying fully-integrated, web3 dApp projects.</p>
2729
</a>

docs/tools/wallets/fortmatic.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/tools/wallets/metamask/add-polygon-network.md

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@ comments: true
33
---
44

55
!!! warning "Content disclaimer"
6-
76
Please view the third-party content disclaimer [here](https://github.com/0xPolygon/polygon-docs/blob/main/CONTENT_DISCLAIMER.md).
87

9-
!!! tip "Installing MetaMask"
10-
11-
Please make sure you have already installed **[Metamask](https://metamask.io/)**!
12-
138
To track your assets and send transactions on any of the Polygon networks using MetaMask, you need to add the respective network configurations to the wallet.
149

1510
In this doc, we demonstrate a few ways to do this for Polygon PoS testnet (Amoy) and mainnet. You can use the same methods to add Polygon zkEVM to your MetaMask wallet.
1611

17-
- [Using ChainList](../metamask/add-polygon-network.md#using-chainlist)
18-
- [Using Polygonscan](../metamask/add-polygon-network.md#using-polygonscan)
19-
- [Adding a network manually](../metamask/add-polygon-network.md#add-a-network-manually)
20-
- [Importing other tokens](../metamask/add-polygon-network.md#importing-other-tokens)
21-
22-
## Using ChainList
12+
## ChainList
2313

2414
1. Depending on the network profile that you want to add to your MetaMask wallet, use one of the following links to navigate to the respective ChainList page.
2515

@@ -30,75 +20,73 @@ In this doc, we demonstrate a few ways to do this for Polygon PoS testnet (Amoy)
3020

3121
2. Select the **Add to Metamask** option on the page. This brings up your MetaMask wallet.
3222

23+
<center>
3324
![chainlist-1](../../../img/tools/wallet/metamask/chainlist-1.png){width=50%}
25+
</center>
3426

3527
3. Select the **Approve** option. This lets ChainList add the network configuration such as the network RPC URL, the chain ID, etc., to your MetaMask wallet.
3628

29+
<center>
3730
![chainlist-2](../../../img/tools/wallet/metamask/chainlist-2.png){width=50%}
31+
</center>
3832

3933
4. Finally, select **Switch network** to switch to Amoy testnet in MetaMask.
4034

35+
<center>
4136
![chainlist-3](../../../img/tools/wallet/metamask/chainlist-3.png){width=50%}
37+
</center>
4238

4339
5. You can now see your MATIC balance on Amoy. You can also switch between Amoy and other networks directly from the drop-down menu in the top-left corner.
4440

41+
<center>
4542
![chainlist-4](../../../img/tools/wallet/metamask/chainlist-4.png){width=50%}
43+
</center>
4644

47-
## Using Polygonscan
45+
## Polygonscan
4846

4947
1. Navigate to the [Polygonscan website](https://polygonscan.com/).
5048
2. Select the network you want to add to your MetaMask wallet from the drop-down list in the top-right corner of the home page.
5149

50+
<center>
5251
![polygonscan-1](../../../img/tools/wallet/metamask/polygonscan-1.png){width=50%}
52+
</center>
5353

5454
3. The explorer window refreshes and loads the explorer home page for the network you selected.
5555
4. Next, scroll down to the bottom of the page, and select the button in the bottom-left corner prompting you to add the network to your MetaMask wallet. For instance, in the case of Amoy testnet, the button says **Add Polygon Amoy Network**.
5656

57+
<center>
5758
![polygonscan-2](../../../img/tools/wallet/metamask/polygonscan-2.png){width=50%}
59+
</center>
5860

5961
5. Select **Approve** from the MetaMask window. This allows the explorer to add the network configuration to your wallet.
6062

63+
<center>
6164
![polygonscan-3](../../../img/tools/wallet/metamask/polygonscan-3.png){width=50%}
65+
</center>
6266

6367
6. Finally, click on **Switch network** to switch to your selected network.
6468

69+
<center>
6570
![polygonscan-4](../../../img/tools/wallet/metamask/polygonscan-4.png){width=50%}
71+
</center>
6672

6773
7. You can now see your MATIC balance on Amoy. You can also switch between Amoy and other networks directly from the drop-down menu in the top-left corner.
6874

75+
<center>
6976
![polygonscan-5](../../../img/tools/wallet/metamask/chainlist-4.png){width=50%}
77+
</center>
7078

7179
## Add a network manually
7280

73-
MetaMask gives you the option to add a network profile manually. Let's look at how to input the valid network RPC URL, chain ID, and other information for the network you want to add to the wallet. The following table contains the mainnet and testnet network configurations for Polygon PoS and zkEVM.
81+
MetaMask gives you the option to add a network profile manually.
82+
83+
Follow the [MetaMask guide to add a custom network](https://support.metamask.io/networks-and-sidechains/managing-networks/how-to-add-a-custom-network-rpc/).
84+
85+
The following table contains the mainnet and testnet network configurations for Polygon PoS and zkEVM.
7486

7587
| Network | RPC URL | Chain ID | Native token | Explorer URL |
7688
| :---------------------: | :--------------------------------------: | :------: | :----------: | :-----------------------------------: |
7789
| PoS mainnet | https://polygon-mainnet.infura.io | 137 | MATIC | https://polygonscan.com/ |
7890
| PoS Amoy (testnet) | https://rpc-amoy.polygon.technology | 80002 | MATIC | https://amoy.polygonscan.com |
7991
| zkEVM mainnet | https://zkevm-rpc.com | 1101 | ETH | https://zkevm.polygonscan.com |
80-
| zkEVM Cardona (testnet) | https://etherscan.cardona.zkevm-rpc.com/ | 2442 | ETH | https://cardona-zkevm.polygonscan.com |
81-
82-
1. Start by selecting the drop-down menu from the top-left corner in MetaMask.
83-
84-
![manual-1](../../../img/tools/wallet/metamask/manual-1.png){width=50%}
85-
86-
2. Select **Add network** option at the bottom of the drop-down list.
87-
88-
![manual-2](../../../img/tools/wallet/metamask/manual-2.png){width=50%}
89-
90-
3. This brings up the MetaMask settings page in your browser. Select the **Add a network manually** option at the bottom of the page.
91-
92-
![manual-3](../../../img/tools/wallet/metamask/manual-3.png)
93-
94-
4. This takes you to a form with multiple fields. Enter the network configuration (as highlighted in [the table above](#add-the-polygon-network-manually)) for the network you want to add to your MetaMask wallet. The following image shows the entries for PoS Amoy testnet. Fill in the network config and select **Save**.
95-
96-
![manual-4](../../../img/tools/wallet/metamask/manual-4.png){width=50%}
97-
98-
5. This adds the network profile to your MetaMask wallet. Select the prompt to switch to your newly added network. You can now switch between your added network and other networks from the drop-down list on the wallet main page.
99-
100-
![manual-5](../../../img/tools/wallet/metamask/manual-5.png){width=50%}
101-
102-
## Importing other tokens
103-
104-
Looking for a token that didn't show up in the list once you switched networks? Check out MetaMask's guide on [importing tokens to the token list](https://support.metamask.io/managing-my-tokens/custom-tokens/how-to-display-tokens-in-metamask/).
92+
| zkEVM Cardona (testnet) | https://etherscan.cardona.zkevm-rpc.com/ | 2442 | ETH | https://cardona-zkevm.polygonscan.com |

docs/tools/wallets/metamask/custom-tokens.md

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 8 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,15 @@
11
!!! caution "Content disclaimer"
22
Please view the third-party content disclaimer [here](https://github.com/0xPolygon/polygon-docs/blob/main/CONTENT_DISCLAIMER.md).
33

4-
[MetaMask](https://metamask.io/) is a crypto wallet that can be used in a web browser and on mobile devices to interact with the Ethereum blockchain. It allows you to run Ethereum Dapps (Decentralized Apps) right in your browser without running a full Ethereum node.
4+
[MetaMask](https://metamask.io/) is a crypto wallet for web browsers and mobile devices that interacts with the Ethereum blockchain. It allows you to run Ethereum dApps in your browser without running a full Ethereum node.
55

6-
**Type**: Non-custodial/HD <br/>
7-
**Private Key Storage**: User’s local browser storage <br/>
8-
**Communication to Ethereum Ledger**: Infura <br/>
9-
**Private key encoding**: Mnemonic <br/>
6+
- Type: Non-custodial/HD
7+
- Private key storage: User local browser storage
8+
- Ethereum connection: Infura
9+
- Private key encoding: Mnemonic
1010

1111
!!! warning
12-
Please Backup your **Secret Recovery Phrase**. If your device breaks, is lost, stolen, or has data corruption, there is no other way to recover it. The Secret Recovery Phrase is the only way to recover your MetaMask accounts. Check more **[Basic Safety and Security Tips for MetaMask](https://metamask.zendesk.com/hc/en-us/articles/360015489591-Basic-Safety-and-Security-Tips-for-MetaMask)**.
12+
- Backup your **Secret Recovery Phrase**.
13+
- If your device breaks, is lost, stolen, or has data corruption, there is no other way to recover it.
14+
-The Secret Recovery Phrase is the only way to recover your MetaMask accounts. Check more **[Basic Safety and Security Tips for MetaMask](https://metamask.zendesk.com/hc/en-us/articles/360015489591-Basic-Safety-and-Security-Tips-for-MetaMask)**.
1315

14-
## Guide to set up MetaMask for Polygon
15-
16-
* [Download & install MetaMask](create-metamask-wallet.md).
17-
* [Configure Polygon on MetaMask](add-polygon-network.md).
18-
* [Config custom tokens](custom-tokens.md).
19-
* [Create & import accounts](multiple-accounts.md).
20-
21-
### 1. Set up Web3
22-
23-
#### Step 1.1
24-
25-
Install the following in your DApp:
26-
27-
```sh
28-
npm install --save web3
29-
```
30-
31-
Create a new file, name it `web3.js` and insert the following code in it:
32-
33-
```javascript
34-
import Web3 from 'web3';
35-
36-
const getWeb3 = () => new Promise((resolve) => {
37-
window.addEventListener('load', () => {
38-
let currentWeb3;
39-
40-
if (window.ethereum) {
41-
currentWeb3 = new Web3(window.ethereum);
42-
try {
43-
// Request account access if needed
44-
window.ethereum.enable();
45-
// Acccounts now exposed
46-
resolve(currentWeb3);
47-
} catch (error) {
48-
// User denied account access...
49-
alert('Please allow access for the app to work');
50-
}
51-
} else if (window.web3) {
52-
window.web3 = new Web3(web3.currentProvider);
53-
// Acccounts always exposed
54-
resolve(currentWeb3);
55-
} else {
56-
console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');
57-
}
58-
});
59-
});
60-
61-
export default getWeb3;
62-
```
63-
64-
The above file exports a function called `getWeb3()` - the purpose of which is to request MetaMask account’s access via detecting a global object (`ethereum` or `web3`) injected by Metamask.
65-
66-
According to [Metamask’s API documentation](https://docs.metamask.io/guide/ethereum-provider.html#upcoming-provider-changes):
67-
68-
> MetaMask injects a global API into websites visited by its users at window.ethereum. This API allows websites to request users' Ethereum accounts, read data from blockchains the user is connected to, and suggest that the user sign messages and transactions. The presence of the provider object indicates an Ethereum user.
69-
70-
In simpler terms, it basically means that having Metamask’s extension/add-on installed in your browser, you’d have a global variable defined, called `ethereum` (`web3` for older versions), and using this variable we instantiate our web3 object.
71-
72-
#### Step 1.2
73-
74-
Now, in your client code, import the above file:
75-
76-
```js
77-
import getWeb3 from '/path/to/web3';
78-
```
79-
80-
and call the function:
81-
82-
```js
83-
getWeb3()
84-
.then((result) => {
85-
this.web3 = result;// we instantiate our contract next
86-
});
87-
```
88-
89-
### 2. Set up account
90-
91-
Now to send transactions (specifically those that alter the state of the blockchain) we’ll need an account to sign those transactions. We instantiate our contract instance from the web3 object we created above:
92-
93-
```js
94-
this.web3.eth.getAccounts()
95-
.then((accounts) => {
96-
this.account = accounts[0];
97-
})
98-
```
99-
100-
The `getAccounts()` function returns an array of all the accounts on user’s MetaMask, and `accounts[0]` is the one currently selected by the user.
101-
102-
### 3. Instantiate your contracts
103-
104-
Once we have our `web3` object in place, we’ll next instantiate our contracts, assuming you have your contract ABI and address already in place:
105-
106-
```js
107-
const myContractInstance = new this.web3.eth.Contract(myContractAbi, myContractAddress)
108-
```
109-
110-
### 4. Call functions
111-
112-
Now for any function you’d want to call from your contract, we directly interact with our instantiated contract object (which is `myContractInstance` declared in Step 2).
113-
114-
!!! tip
115-
- Functions that alter the state of the contract are called `send()` functions.
116-
- Functions that do not alter the state of the contract are called `call()` functions.
117-
118-
#### Calling `call()` Functions
119-
120-
```js
121-
this.myContractInstance.methods.myMethod(myParams)
122-
.call()
123-
.then (
124-
// do stuff with returned values
125-
)
126-
```
127-
128-
#### Calling `send()` Functions
129-
130-
```js
131-
this.myContractInstance.methods.myMethod(myParams)
132-
.send({
133-
from: this.account,gasPrice: 0
134-
})
135-
.then (
136-
(receipt) => {
137-
// returns a transaction receipt}
138-
)
139-
```

0 commit comments

Comments
 (0)