# Introduction
CsomWasm proves the potential of a smart contract container at the heart of the Cosmos Hub.
One of the promises of CosmWasm is to enable flexible smart contract execution on Cosmos Hub. With CosmWasm on the Hub, network participants can propose to deploy smart contracts, vote in governance to enable them.
In this section you will learn all the knowledge required to experience smart contract on the hub. If you are interested in smart contract development, digest the Getting Started documentation.
# Wasmd Authorization Settings
CosmWasm provides on-chain smart contract deployment authorization mechanisms that can be configured many ways:
- Free for all, meaning fully without an admin. Anyone can deploy.
- Fully permissioned, meaning only an admin can deploy.
- By on-chain governance. Deployment of a contract is determined by governance votes.
- By owner, contract by contract basis.
# Enable Governance Proposals at Compile Time
As gov proposals bypass the existing authorization policy they are disabled and require to be enabled at compile time.
If you are using gaiaflex
binary executable you don't need to build using flags above since it is already included in
the binary build.
# Init Parameters Via Genesis
Initial authorization configuration is in genesis file:
These configurations in gaiaflex testnet means only governance can upload and init smart contracts.
# Available configurations
code_upload_access
- who can upload a wasm binary:Nobody
,Everybody
,OnlyAddress
. Needs to be defined in the genesis. can be changed later by governance votes.instantiate_default_permission
- platform default, who can instantiate a wasm binary when the code owner has not set it In this tutorial, we will show you deploying a smart contract on a governed network.
CosmWasm extends Cosmos SDK governance module to enable deployment of smart contracts after proposals.
# Get Sample cw-subkeys Contract
There are two options to get the sample contract:
Download source code (opens new window), and compile it your self.
Download pre-compiled binary (opens new window).
# Submit Proposal
Deployment command is down below:
If you run wasmcli tx gov submit-proposal wasm-store -h
, you will notice two more important flags:
By default, the first flag is enabled. If you want only one address to be able to initiate the contract,
set the instantiate-only-address
flag.
If either of these flags are set, the voting committee should decide if that is acceptable for the given contract. Instantiate-everybody might make sense for a multisig (everyone makes their own), but not for creating a new token.
# Vote
After the proposal creation, it needs to be approved by governance voting.
# Instantiate
After the proposal passes the code will be deployed. Now you can instantiate the contract.
# Interact
If you have admin access to the contract you can add or remove admins by running the command:
Subkey allowances can execute send token transaction using the command: