Smart Contracts (CosmWasm)
Getting Started
If you're new to CosmWasm and Smart Contracts, we recommend starting with the CW-Template repository. This template will help you understand the basic interfaces and models of CosmWasm smart contracts.
When you're ready to deploy your smart contract, you’ll need a local build of the chain core. This will allow you to store your code on-chain and submit governance proposals to instantiate it.
Installation Steps
Clone the Rujira core repository:
Deployment
Now that you've set up the environment, you're ready to store your code on-chain.
Step 1: Optimize the Code
To optimize your contract's code, run the following command:
Step 2: Create a Local Account
You’ll need a local account to handle transactions.
This will generate a seed phrase and an associated Kujira address for your account. Make sure to store the seed phrase safely. You’ll also need to fund this address with KUJI tokens before proceeding to the next step.
Step 3: Store Code on Chain
To store the optimized code on-chain, run the following:
Upon successful execution, logs will be generated. These logs contain the code_id
of your contract, which will look something like this:
Instantiation
Your code is now stored on-chain and behaves similarly to a class in an object-oriented language. Next, you need to instantiate the contract so you can interact with it.
On Kujira, instantiation must be done via a governance proposal. This ensures the quality and security of code and dApps on the network.
Step 1: Submit a Governance Proposal
Run the following command to submit an instantiation proposal:
This creates a proposal at the funding stage. You can then visit Rujira Governance to deposit funds and open it for voting.
Step 2: Retrieve Contract Address
After the proposal passes and the contract is instantiated, the contract will have its own unique address. You can find the contract address with the following query:
Once the contract is instantiated, you're ready to move on to building the UI for your newly deployed smart contract.
Last updated