This site requires Javascript to be enabled.

Deployment and interaction

You now have the wasm binary ready. It's time to deploy it to the Archway (Constantine) testnet and begin interacting with your smart contract. You can use the archwayd CLI, Archway Developer CLI, or the arch3.js, depending on your preference.

Deploy contract

In the Compile Contract page, we generated a wasm binary executable. You can upload the code to the blockchain, and once the process is complete, you can download the bytecode for verification purposes.

Deploy using archwayd

Now you will store the wasm bytecode of the cw_namespace contract on chain and obtain the code id. This code id will be used later to create an instance of the cw_namespace contract.

Change mywallet to the name of the wallet you created in the Setting up environment page. Execute the following commands to store the contract on chain:



RES=$(archwayd tx wasm store artifacts/cw_nameservice.wasm --from mywallet --node --chain-id archway-1 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3 -y --output json -b block)

The response contains the Code Id of the uploaded wasm binary:

echo $RES

The following is an easier way to get the Code Id from the response

CODE_ID=$(echo $RES | jq -r '.logs[0].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
echo $CODE_ID

You can see the list of contracts instantiated using the CODE_ID generated above by executing the following command:



archwayd query wasm list-contract-by-code $CODE_ID --node --output json

The response should be an empty list since no contracts have been instantiated yet.


Before you instantiate a contract using the Code Id and interact with it, let's verify if the code stored on the blockchain is indeed the cw_namespace.wasm binary you uploaded.

Download the wasm binary from the chain and compare it to the original one:



archwayd query wasm code $CODE_ID --node download.wasm --chain-id archway-1

The two binaries should be identical:

diff artifacts/cw_nameservice.wasm download.wasm

If the diff command yields an empty output, this indicates that the two files being compared are identical.

Deploy using archway developer cli

If your contract was created using the archway new command, you can deploy the contract using the following command:

archway store

For details on how to create a CosmWasm project with the Archway Developer CLI, see Creating a project.

Instantiating the contract

You can now create an instance of the wasm contract. After instantiation, you can make queries and execute transactions.

Instantiate using archwayd



# Prepare the instantiation messageINIT='{"purchase_price":{"amount":"100","denom":"aconst"},"transfer_price":{"amount":"999","denom":"aconst"}}'# Instantiate the contractarchwayd tx wasm instantiate $CODE_ID "$INIT" --from mywallet --label "name service" --node --chain-id archway-1 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3 -y --no-admin# Check the contract details and account balancearchwayd query wasm list-contract-by-code $CODE_ID --node --output jsonCONTRACT=$(archwayd query wasm list-contract-by-code $CODE_ID --node --output json | jq -r '.contracts[-1]')echo $CONTRACT# See the contract detailsarchwayd query wasm contract $CONTRACT --node --chain-id archway-1# Check the contract balancearchwayd query bank balances $CONTRACT --node --chain-id archway-1# Upon instantiation the cw_nameservice contract will store the instatiation message data in the contract's storage with the storage key "config".# Query the entire contract statearchwayd query wasm contract-state all $CONTRACT --node --chain-id archway-1

Contract Interaction

Now that the contract is instantiated, you can register a name and transfer it to another address by paying the transfer fee.

Interact using archwayd



# Register a name for the wallet addressREGISTER='{"register":{"name":"fred"}}'archwayd tx wasm execute $CONTRACT "$REGISTER" --amount 100aconst --from mywallet --node --chain-id archway-1 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3 -y# Query the owner of the name recordNAME_QUERY='{"resolve_record": {"name": "fred"}}'archwayd query wasm contract-state smart $CONTRACT "$NAME_QUERY" --node  --chain-id archway-1 --output json# {"data":{"address":"archway1hlsd2tgjxalap5gslxz4g4t0f0yr9nwne98uyu"}}# Transfer the ownership of the name record to wallet2 (change the "to" address to wallet2 address generated during environment setup)archwayd keys listTRANSFER='{"transfer":{"name":"fred","to":"archway1htum43he4n46gdmvuzr72ahsyvau4ummdgeytv"}}'archwayd tx wasm execute $CONTRACT "$TRANSFER" --amount 999aconst --from mywallet --node --chain-id archway-1 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node '' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3 -y# Query the record owner again to see the new owner address:NAME_QUERY='{"resolve_record": {"name": "fred"}}'archwayd query wasm contract-state smart $CONTRACT "$NAME_QUERY" --node --output json# {"data":{"address":"archway1htum43he4n46gdmvuzr72ahsyvau4ummdgeytv"}}