# PMetamask

PMetamask is a web browser plug-in wallet.&#x20;

Currently, Plian is compatible with any EVM developer tools like Metamask, Remix, etc.  So we suggest you directly [use Metamask to deploy smart contract on Plian](https://pliangroup.gitbook.io/plian/for-developers/how-to-deploy-smart-contract-on-plian-via-metamask-+-remix).

### Installation

First, download PMetamask installation package from [here](https://github.com/pchain-org/pmetamask/releases/download/v0.0.1/Pmetamask-chrome-0.0.1.zip). Then open Chrome and input chrome://extensions/ to enter extensions page:

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FK3WWmJ3OjfAb9KJkYWla%2F485187661166194776.jpg?alt=media&#x26;token=53307a53-750d-4771-aae2-105a76f182f5" alt=""><figcaption></figcaption></figure>

Switch to Developer mode on top right of the explorer and drag the PMetamask installation package into it to install the plug-in.

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FICODSq29RhqxtlNLcTRm%2F208740695410463633.jpg?alt=media&#x26;token=6794892c-6f4f-4ca1-83cf-454c07a01c60" alt=""><figcaption></figcaption></figure>

After create or import address by following the guide of PMetamask，you can see something look like this:

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2F96aPjTbDJ9OS4wS6784L%2F1.jpg?alt=media&#x26;token=9a04de0d-fa4a-492a-894e-d035fc2bd79d" alt=""><figcaption></figcaption></figure>

Plian's smart contract can only be deployed on subchain. We choose the subchain 1 on Plian testnet to deploy smart contract. You can get free tPI on this subchain from [here](https://testnet.pchain.org/vfaucet.html).

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FmU7hTpyRi5gJVJTJO8Ob%2F2.jpg?alt=media&#x26;token=2ca041ca-c417-4ffa-a58a-4714fd853847" alt=""><figcaption></figcaption></figure>

### Connect Remix and PMetamask

Keep PMetamask opening，open Remix【[http://remix.ethereum.org](http://remix.ethereum.org/)】 the page is look like this：

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FgR0rfXmb8MsWPzosTlrx%2F4.jpg?alt=media&#x26;token=973a4499-6206-4994-9573-9c24780fa2b2" alt=""><figcaption></figcaption></figure>

Under Remix’s ‘Run’ menu，select the Environment as ‘Injected Web3’:

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FYWPMXejgPbVgS61gblHQ%2F5.jpg?alt=media&#x26;token=2c217fd8-ac9c-4ccd-b74e-a1487acb87c7" alt=""><figcaption></figcaption></figure>

Click ‘connect’ on the popup PMetamask Notification dialog

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FB8VrRJS3jaF7z2GC5ORY%2F6.jpg?alt=media&#x26;token=cf725071-af22-4b76-a51d-d464c12b7131" alt=""><figcaption></figcaption></figure>

After that，the default account’s address in PMetamask will shown in ‘Account’ field automatically.

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2F42Pdipt9BWgeqNBQt4EI%2F7.jpg?alt=media&#x26;token=e53f458b-9de6-483d-a0f1-46b69ab38073" alt=""><figcaption></figcaption></figure>

### Deploy and interact with smart contract

Edit smart contract in Remix，e.g：

```
pragma solidity ^ 0.4.23 ;
contract PCHAINTest{

  uint public value = 0;
  function inc(uint v) public {
    value += v;
  }
}
```

select the proper version to compile（here we take version 0.4.23 as an example）：

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2F9jcyonJidtNQacoAyS17%2F8.jpg?alt=media&#x26;token=cb6a3059-eb43-448d-b8ea-9b9a311cd0f8" alt=""><figcaption></figcaption></figure>

compile smart contract

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2Fbcb5140NFQduWLjws7rw%2F9.jpg?alt=media&#x26;token=ae792a3f-1062-4adb-9542-4470de8237aa" alt=""><figcaption></figcaption></figure>

Click the ‘Deploy’ button under ‘Run’ menu to deploy the smart contract just complied

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FatYpj3ks0c2ObKM4qRn8%2F10.jpg?alt=media&#x26;token=1f9bdda2-60e6-4263-b229-8275ab3fcbc0" alt=""><figcaption></figcaption></figure>

After click the ‘deploy’ button，click the ‘confirm’ button on PMetamask Notification dialog：

![](https://pchaindoc.readthedocs.io/en/latest/_images/confirm.png)

After deployed successfully, you can debug the contract If there are operations need to spend Gas, you may need confirm in the pop-up PMetamask dialog or in PMetamask directly.If the transaction failed, you can try to resend it or change the gas fee according to the returned error.

<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FXxcRJwMjcJTPYvE5temg%2F11.jpg?alt=media&#x26;token=982ff264-fca9-4dcc-b292-aa8c570c78fc" alt=""><figcaption></figcaption></figure>



<figure><img src="https://3714373443-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRCF092Z3_9ouKsNgIF-3369173170%2Fuploads%2FLhvVrbC05OLgMAqKqEbR%2F13.jpg?alt=media&#x26;token=52c4055c-25e5-470f-bf07-8accef6981ea" alt=""><figcaption></figcaption></figure>
