# How to Deploy a Smart Contract

We recommend using an [online compiler](https://ethereum.github.io/browser-solidity/#optimize=false\&version=soljson-v0.5.7+commit.6da8b019.js) to compile smart contracts. If you want to test your smart contract, it’s better to deploy it on testnet first. You can install [Pchain testnet](https://github.com/pchain-org/pchain/wiki/How-to-sync-and-run-pchain's-testnet) and get [free tPI](https://testnet.pchain.org/vfaucet.html) from our testnet.

### Compile

Copy your code into it.

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

Click **Details** button.

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

Copy the Byte Code and ABI/JSON Interface

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

### Deploy

{% hint style="info" %}
You can only deploy smart contracts on the subchain.
{% endhint %}

Click on the "Contract" tab.

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

Copy your byte code and click "Deploy Contract" button.

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

Enter your password and send the transaction.

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

Wait for the contract address return and copy the address.

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

### Interact with Contract

Click "Interact with Contract" button, copy your ABI/JSON Interface into it and click "Access" button.

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pliangroup.gitbook.io/plian/using-the-blockchain/piwallet/how-to-deploy-a-smart-contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
