By using the command below, a Wasm binary to be published on Wasm Minitia is compiled.
RUSTFLAGS='-C link-arg=-s'cargowasm
When compiling is completed, target/wasm32-unknown-unknown/release/cw_nameservice.wasm file will be generated.
Step 1-1: Compile with rust-optimizer (Advanced)
Docker must be installed in order to use rust-optimizer.
Wasm binary file must be as small as possible in order to reduce gas costs for both the deployment and for every interaction with the deployed contract. The rust-optimizer is a tool which can be used to make the binary size as small as possible while ensuring that all contract features are still working.
By running the above command, the binary file will be generated within artifacts/cw_nameservice.wasm.
Step 2: Store a contract
Let's store cw_nameservice.wasm contract created in the previous step onto the Minitia.
Step 3: Instantiate a contract
In this step, we will instantiate a new contract using the stored code in the previous step.
First, codeId is required in order to instantiate the stored cw_nameservice.wasm contract. codeID can be fetched with the command line below.
Let's instantiate a new wasm contract using the stored code.
Step 4: Interact with a contract
We are now ready to interact with the instantiated CosmWasm contract.
Contract address is required in order to interact with the instantiated contract. The contract address can be found by using the below command:
Execute a contract function
In this example, we will use the register function from the published contract, to register test as a name service domain.
Query Results
Once the register function is successfully executed, we can confirm the name that was registered through a contract query.