Mainnet Deployment Guide
This guide will get you started with the governance process of deploying and instantiating CosmWasm smart contracts on Injective Mainnet.
Submit a Code Upload Proposal
In this section, you will learn how to submit a smart contract code proposal and vote for it.
Injective network participants can propose smart contracts deployments and vote in governance to enable them. The wasmd authorization settings are by on-chain governance, which means deployment of a contract is completely determined by governance. Because of this, a governance proposal is the first step to uploading contracts to Injective mainnet.
Sample usage of injectived to start a governance proposal to upload code to the chain:
injectived tx wasm submit-proposal wasm-store artifacts/cw_controller.wasm
--title="Proposal Title" \
--summary="Proposal Summary" \
--instantiate-everybody true \
--broadcast-mode=sync \
--chain-id=injective-1 \
--node=https://sentry.tm.injective.network:443 \
--deposit=100000000000000000000inj \
--gas=20000000 \
--gas-prices=160000000inj \
--from [YOUR_KEY] \
--yes \
--output jsonThe command injectived tx gov submit-proposal wasm-store submits a wasm binary proposal. The code will be deployed if the proposal is approved by governance.
Let’s go through two key flags instantiate-everybody and instantiate-only-address, which set instantiation permissions of the uploaded code. By default, everyone can instantiate the contract.
Contract Instantiation (No Governance)
In most cases, you don’t need to push another governance proposal to instantiate. Simply instantiate with injectived tx wasm instantiate. You only need a governance proposal to upload a contract. You don’t need to go through governance to instantiate unless if the contract has the --instantiate-everybody flag to set to false, and --instantiate-only-address flag set to the governance module. The default value for --instantiate-everybody is true, and in this case you can permissionlessly instantiate via injectived tx wasm instantiate.
An example injectived tx wasm instantiate can look something like this:
Contract Instantiation (Governance)
As mentioned above, contract instantiation permissions on mainnet depend on the flags used when uploading the code. By default, it is set to permissionless, as we can verify on the genesis wasmd Injective setup:
However, if the --instantiate-everybody flag is set to false, then the contract instantiation must go through governance.
Contract Instantiation Proposal
Contract Migration
Migration is the process through which a given smart contract's code can be swapped out or 'upgraded'.
When instantiating a contract, there is an optional admin field that you can set. If it is left empty, the contract is immutable. If the admin is set (to an external account or governance contract), that account can trigger a migration. The admin can also reassign the admin role, or even make the contract fully immutable if desired. However, keep in mind that when migrating from an old contract to a new contract, the new contract needs to be aware of how the state was previously encoded.
A more detailed description of the technical aspects of migration can be found in the CosmWasm migration documentation.
Last updated
