In this document, we will provide a step-by-step dapp development (deployment and call) on QuarkChain.
Please note that
- Current pyquarkchain 1.3 supports EVM Petersburg. We plan to support the latest EVM in future network upgrade.
- We assume the contract code is already ready. For illustration purpose, we use the code here MyToken.sol in the tutorial.
Note that the target EVM version is set to "Petersburg".
Switch to MyToken contract and save the ABI json file. This file will be used to access the contract. An example ABI of the code can be found here. Note that you need to switch to MyToken contract again to get the ABI file if the code is re-compiled.
Now, we deploy the code with totalSupply 10000 in remix.
The deployed code binary can be found on the bottom-right side of remix (and click the clipboard icon of "input"). An example binary of the code can be found here
Now, we are ready to deploy and run the code on QuarkChain mainnet. First, open the contract page on QuarkChain explorer. Switch to "Deploy" tab and paste the binary code in "Byte Code", and then sign and submit the deployment transaction. Note that the contract will be deployed on the chain of sender (e.g., chain 0 in the example). If you wish to deploy on different chain, simply switch to the chain id in Account tab.
From the figure, we could determine
- The contract is successfully deployed
- The contract address is 0x12e56566c7dE9bCaEf68dfeE846532f4c1F3481B0000D31C
Now we are able to read/write the contract in the "Interact" tab in QuarkChain explorer.
The tab will accept two parameters:
- The contract address after the successful deployment
- The contract ABI, which is obtained from remix in Step 3 The following shows an example that read the totalSupply from the contract.
A: This is most likely that the transaction does not have sufficient gas, and you need to retry with greater gas. Note that you could also determine the gas of deployment in remix.
Q: After submitting the transaction in "Contract" page, the page returns "Sending transaction failed"
A: This is most likely that the gas limit is too high. Current QuarkChain suppports up to 6M gas limit per block, and thus any transaction with more than 6M gas limit will be failed.