Cover photo

Osmosis mainnet guide

At long last, CronCat is launching on CosmWasm chains, both permissionless and permissioned ones. The CronCat team is especially grateful for Osmosis and the OGP, who have been instrumental in helping fund critical milestones like the security audit of the smart contracts. (See security audit results in the link below)

https://github.com/oak-security/audit-reports/tree/master/CronCat

Permissioned CosmWasm chains have different approaches for going live on mainnet. Let’s cover the needs for Osmosis, which may be a helpful resource for future projects coming to Osmosis.

1. Commonwealth

Create a detailed Commonwealth proposal including details of the project. You may follow the CronCat post here:

https://commonwealth.im/osmosis/discussion/11352-allow-croncat-contracts-to-be-uploaded

This initial proposal should be broadcast to the Osmosis community through various social media means and sit for at least three days. Proposers are expected to answer questions from the community.

2. Set up an Osmosis multisig

If all concerns have been addressed in the first step, and there’s signal that an on-chain governance proposal has the likelihood of passing, it’s time for the next step.

As of the time of this writing, Osmosis is offering a multisig approach for projects that may have multiple contracts to deploy. This approach offers improved experience, whereas some projects might otherwise need several on-chain governance proposals, which is both expensive and may cause unnecessary effort for the voting community.

In the cw-plus repository, there exist a couple multisignature smart contracts. In particular, the cw-fixed-multisig is a good option.

https://docs.rs/cw3-fixed-multisig/latest/cw3_fixed_multisig/index.html

There’s a handy tool created by the community, offering a simple user interface for creating a multisig on Osmosis mainnet. Kudos to the Apollo team!

https://safe.apollo.farm/

Update the Commonwealth proposal with the multisig address.

3. Create on-chain governance proposal

On-chain proposals generally have a bond associated with it, meaning you have to attach some amount of native tokens to create a proposal. These will be returned to the proposer unless the proposal fails with a “no with veto” vote from the community.

Here’s a helpful script from Osmosis for this part:

{
    "title": "Allow CronCat contracts to be uploaded",
    "description": "This proposal gives the address osmo15wna5dwylkuzvljsudyn6zfsd4zl0rkg5ge888mzk4vtnjpp0z5q4e9w58 the ability to upload CosmWasm contracts to Osmosis without seeking further governance approval for each upload. \nThis address is a multisig administered by the CronCat cofounders. \n\nCronCat uses a modular factory architecture for security, and after talking internally with the Osmosis team, agreed this would be the optimal path to ship the CronCat contracts and allow for new versions of a handful of CronCat contracts to be stored. \n\nCronCat has been graciously awarded a grant by the Osmosis team and are excited to bring trustless automation to one of the most monumental app-chains in Cosmos history. \n\nA helpful, and somewhat technical blog we wrote with the Osmosis team from last year. \n[https://medium.com/osmosis/osmosis-ecosystem-spotlight-croncat-cd52862790d2](https://medium.com/osmosis/osmosis-ecosystem-spotlight-croncat-cd52862790d2)\n\nWebsite: [https://cron.cat](https://cron.cat)\nTestnet website: [https://testnet.cron.cat](https://testnet.cron.cat)\nDocumentation: [https://docs.cron.cat/docs](https://docs.cron.cat/docs)\nCronCat Agent daemon: [https://github.com/CronCats/croncat-rs](https://github.com/CronCats/croncat-rs)\nSecurity audit: [https://github.com/oak-security/audit-reports/tree/master/CronCat](https://github.com/oak-security/audit-reports/tree/master/CronCat)\nLeverage CronCat automation in you CosmWasm contracts: [https://docs.cron.cat/docs/integration](https://docs.cron.cat/docs/integration)\nDM us on Twitter: [https://twitter.com/croncats](https://twitter.com/croncats)\nJoin our Discord: [https://discord.gg/GJY7QBsDft](https://discord.gg/GJY7QBsDft)\nThank you to Osmosis and the Osmosis community, for the support.\n\n**Commonwealth Thread**:[https://commonwealth.im/osmosis/discussion/11352-allow-croncat-contracts-to-be-uploaded](https://commonwealth.im/osmosis/discussion/11352-allow-croncat-contracts-to-be-uploaded)",
    "changes": [
        {
            "subspace": "wasm",
            "key": "uploadAccess",
            "value": { "permission": "AnyOfAddresses", "addresses": ["osmo1cd4nn8yzdrrsfqsmmvaafq8r03xn38qgqt8fzh","osmo1wl59k23zngj34l7d42y9yltask7rjlnxgccawc7ltrknp6n52fps94qsjd","osmo19vxp8vq8qm368dr026qxh8v82satwaf79y235lfv6wmgpwxx8dtskedaku","osmo1e0x2hnhhwyek7eq3kcxu2x6pt77wdnwz0lutz9fespdr9utq963qr0y5p5","osmo14n3a65fnqz9jve85l23al6m3pjugf0atvrfqh5","osmo15wna5dwylkuzvljsudyn6zfsd4zl0rkg5ge888mzk4vtnjpp0z5q4e9w58"]}
        }
        ],
    "deposit": "1600000000uosmo"
}

Note: towards the end there’s an AnyOfAddresses that you’ll want to coordinate with the Osmosis team about before submitting.

As you can see from the final deposit key, you’ll need to have that much OSMO available to bond.

You’ll save the JSON above to a file and submit with a command similar to this:

osmosisd tx gov submit-proposal param-change my_file.json --gas auto --gas-prices 0.1uosmo --gas-adjustment 1.7 --from mike

4. Wait for voters

🧘

5. Authorize storing code (via authz)

If your proposal passes, great! Your multisig will be added to a list that is allowed to perform special actions like storing CosmWasm code.

However, there’s a couple problems.

  • It’s likely that your multisig is associated with one or more hardware wallets, and the payload required to sign the /cosmwasm.wasm.v1.MsgStoreCode message includes the smart contract’s bytecode, which likely exceeds limitations of such devices.

  • At the time of this writing, WasmMsg doesn’t have the variant to store code.

    https://docs.rs/cosmwasm-std/1.2.5/cosmwasm_std/enum.WasmMsg.html

The approach, therefore, is to temporarily grant authz permissions to an externally-owned address. Authz is a very powerful Cosmos SDK module, and this tutorial is particularly helpful:

https://tutorials.cosmos.network/tutorials/8-understand-sdk-modules/1-authz.html

If you look through previous transactions using a block explorer, you’ll see that some teams will grant authz that only lasts for a handful of days, while the team organizes and executes the deployment.

In order to grant authz permissions to another address, we’ll need to propose this to the multisig we’ve created.

Here is a utility created by a CronCat team member to assist in crafting this message:

https://github.com/mikedotexe/prost-dot-exe

This will allow you to enter your multisig address, EOA, and number of days for the authz grant and it’ll output helpful JSON like this:

JSON used to create an authz grant proposal on a cw3 fixed multisig
JSON used to create an authz grant proposal on a cw3 fixed multisig

Then, the other members of the multisig can vote and execute the proposal, which grants the EOA access to store code.

Send the proposal to your multisig, copying the JSON:

osmosisd tx wasm execute osmo15wna5dwylkuzvljsudyn6zfsd4zl0rkg5ge888mzk4vtnjpp0z5q4e9w58 '<place JSON here>' --gas auto --gas-prices 0.1uosmo --gas-adjustment 1.7 --from mike

6. Generate the store code transaction

Using osmosisd as a CLI, you can add the flag --generate-only to create a JSON file. When crafting this command, you set the --from flag to the multisig’s address, because the EOA will be using authz’s special execute message for our needs.

Generate the JSON:

osmosisd tx wasm store artifacts/croncat_factory.wasm --from osmo15wna5dwylkuzvljsudyn6zfsd4zl0rkg5ge888mzk4vtnjpp0z5q4e9w58 --instantiate-anyof-addresses osmo1yhqft6d2msmzpugdjtawsgdlwvgq3samajy9jq --generate-only > store-factory-contract.json

Remember to include the --instantiate-anyof-addresses so only the intended addresses can instantiate it. In this example above, we’ve added an EOA and the multisig itself. (Your application may have different needs here.)

7. Execute the authz message

Finally, use authz execute to broadcast the transaction from the EOA, but executing it on behalf of the multisig:

osmosisd tx authz exec store-factory-contract.json --gas auto --gas-prices 0.1uosmo --gas-adjustment 1.7 --from mike

Outro

It’s likely that in coming years, permissioned chains try different approaches for projects launching on their platforms. This post covers a current approach for Osmosis in early summer of 2023.

Best to reach out to the Osmosis team if there are any questions.

#gmeow