🕹️Deploy WASM Smart Contract
How to deploy WASM binary file on Titan Chain
Note: This process require some advanced knowledge. This tutorial focuses on smart contract deployment using command line tool. You can explore other methods by yourself.
Step 1: Prepare the WASM contract file
Compile your WASM contract, and generate the binary with name
<project_name>.wasm
Step 2: Upload the WASM file to Titan Chain
Execute the upload command:
<account>
is your account name. Please replace it with your actual account name.
Check if the transaction is on chain and get the code id:
<tx_hash>
is the transaction hash generated from your upload, used for query the transaction status.
Or get the code id using the following command:
Using list-code command, you can view all uploaded contracts and their code id.
Step 3: Instantiate the WASM contract
Instantiate the contract:
<code_id>
is the code id you get in Step 2
<json_encoded_init_args>
is the parameter required for contract initiation, which should be coded in JSON format.
<label>
is the contract label
Check if the transaction is on chain and get the contract address:
If successful, you can get the contract address for further operations.
Step 4: Query the contract state
Using the command to query cantract state:
<contract_address>
is the contract address you get in Step 3.
<query_args>
is the required parameter for the query, which should be coded in JSON format.
View contract state using Titan blockchain browser:
You can also use Titan blockchain browser to view your contract status: Titan Blockchain Browser
Key in the contract address in the browser and you can see the details and state of your contract.
Step 5: Execute the contract
Execute the contract call:
<exec_args>
is the required parameter for contract execution, which should be coded in JSON format.
Hints:
<...> in every step should be replaced by your actual value
Check the parameters in the command carefully before execute each step to ensure correct deployment and operation of the contract.
最后更新于