Phat Contract Console
On the homepage, click Connect Wallet in the right top corner, and select the wallet you are using. An Authorize window will pop up, Click Yes to continue. Then you can connect to one of your accounts in the Select Account window.
Clicking the green dot beside your account will tell you the information about the current chain you are connected to.
You can connect to other chains by filling in the RPC Endpoint and clicking Connect. The UI will automatically read the cluster information from the chain and fill in the PRuntime for you, but you can always set it to other workers manually.
Why two endpointsUnlike other blockchains like Ethereum where you have to call your contracts through on-chain transactions, Phat Contracts are deployed to off-chain Workers so you can interact with them directly without submitting any transactions. The UI will ask for two endpoints, one to connect to the blockchain and another to the worker directly.
To connect to our mainnet or your local testnet, you need to specify two endpoints here:
- An RPC endpoint to connect to one of the Phala blockchain nodes to read the chain state and send transactions;
Once the account is connected, you can find the Get Test-PHA button on the right side of the page and request 100 test tokens by clicking it. The operations below require tokens as the transaction fee.
Uploadand locate your
phat_hello.contractfile that you downloaded. The UI will load the metadata of your contract and list all the constructor functions in the
After you click the
Submit, the UI will ask for your permission to upload the contract WASM to the blockchain through a transaction. Click "Approve" to continue.
What happenedYour contract code is uploaded to the blockchain via a transaction, hence the request for your signature. The code is public, together with your instantiation arguments, so that everyone can verify the initial state of the contract.The blockchain will automatically push the contract code to the workers belonging to the cluster you choose and instantiate it.
After the successful instantiation, you will see the metadata of the deployed contract.
You can also expand the lower bar to see the raw events when deploying the contract.
Scrolling down the page, you can see all the interfaces of your contract, with their function names, types, and descriptions.
The interfaces are divided into two types, labeled by
QUERYrespectively. This contract only contains one
QUERYhandler. The phat-hello contract has only one
Click the run icon to send a request to the contract. For example, we can invoke the
get_eth_balance()to get the current balance of a specific ETH address. The Polkadot.js extension will ask for your permission in the first click to encrypt your following traffic to the contract.
What happenedEvery transaction or query to the contract is encrypted and thus needs your signature. We implement a certificate mechanism to keep your query signature valid for 15 minutes.
QUERYreturns immediately since it involves no on-chain transactions. Click the bottom status bar to see the execution result.
Congrats🎉! You have finished the basic tutorial of Phat Contract!