There are two steps for you to test your contracts.
[!Note|style:flat|label:Notice] The premise of contract testing is that both the original and target chains you want to test have been connected to the Poly Network. Otherwise, the test cannot be performed.
- Deploy your contract in the source chain and target chain (For safety reasons, it is recommended to run the test on the TestNet. If you have to run the test on the MainNet, please contact the
Poly team
via ). - Please submit the "method" (the input parameter of cross-chain function, i.e., the function of your contract called by target chain).
- The
Poly team
will add this "method" to the relayer whitelist to process the transactions automatically. Otherwise, the transaction cannot be processed on the Poly chain.
After the preparation, you can try to call the cross-chain function in your contract, and then query the steps of the cross-chain transaction here. Contract issues can be analyzed according to the step the transaction reached:
- The transaction has been completed on the source chain but has not completed on Poly:
[!Note|style:flat|label:Notice] The "toChainId" refers to the target chain ID registered on Poly, not the network ID. For details, see Chain ID. Please note that the IDs on the TestNet and the MainNet are different.
-
The transaction hasn't been completed on the target chain:
- Call the API
getmanualtxdata
with the Poly chain hash (the second transaction hash).
API
Testnet: https://bridge.poly.network/testnet/v1/getmanualtxdata Mainnet: https://bridge.poly.network/v1/getmanualtxdata
Parameter
/* @Polyhash: the transaction hash in Poly */
Example Request
curl --location --request POST 'https://bridge.poly.network/testnet/v1/getmanualtxdata' \ --header 'Content-Type: application/json' \ --data-raw '{ "polyhash": "", }'
Example Response
{ "data": "", "dst_ccm": "0x" }
- Get the response "data" as the input data to send a transaction to "dst_ccm" on the target chain.
- Call the API
[!Note|style:flat|label:Notice] This step is to call the
verifyHeaderAndExecuteTx
function of CCM on the target chain. The calling process is encapsulated in "data," so you only need to send a transaction with "data" to CCM on the target chain.
-
If you encounter an error submitting this transaction, there is something wrong with your contract on the target chain. Consider doing the following:
- Making sure the "method" (the function of your contract called by target chain) is allowed to be called by the CCM contract on the target chain.
- Checking that the txData (one of the input parameters of the cross-chain function) can be parsed correctly by the "method" on the target chain.
-
The transaction has been completed on the target chain:
- Congratulations! You have completed the cross-chain transaction.
[!Note|style:flat|label:Notice] During the test, you will have to send the target transactions manually. For projects, this may not be desirable. If you want to realize the process automatically, a relayer is required. Here is a relayer solution for you.
After all tests have been completed on the TestNet; you are ready to launch on the MainNet. The steps are as follows:
- First, deploy your contract on the MainNet;
- Next, submit the "method" and the source contract hash you have deployed;
- Then, launch your relayer (See here for steps).
When all is done, you can start your cross-chain journey.