This repository contains the source code for the Enterprise protocol smart contracts on the Terra blockchain.
You can find information about the usage and function of the smart contracts on the official Enterprise documentation site
Contract | Description |
---|---|
enterprise |
Represents a single DAO, containing all its code and treasury |
enterprise-factory |
Serves as a proxy to create DAOs, storing their addresses and global configurations |
enterprise-governance |
Serves as a wrapper for the poll-engine library that handles all voting-related logic |
funds-distributor |
A contract for distributing a DAO's funds to its stakers |
- Rust v1.44.1+
wasm32-unknown-unknown
target- Docker
-
Install
rustup
via https://rustup.rs/ -
Run the following:
rustup default stable
rustup target add wasm32-unknown-unknown
- Make sure Docker is installed
Each contract contains Rust unit and integration tests embedded within the contract source directories. You can run:
cargo test
After making sure tests pass, you can compile each contract with the following:
cargo wasm
For production builds, run the following:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.6
This performs several optimizations which can significantly reduce the final size of the contract binaries, which will be available inside the artifacts/
directory.
This assumes that you already have Yarn installed (https://yarnpkg.com/).
Once you clone the repository, you can do the following;
yarn install
We are using terrariums
to manage contract deployment. The terrarium.json
file allows the selection of a deployment script. Deployment scripts are located in the tasks
directory.
Terrariums synchronizes a refs.json
file, that contains the codeID
and address
of deployed contracts on the various networks. This refs.json
file can be synchronized to other locations by editing the copy_refs_to
property in the terrarium.json
file.
To run deployment scripts, you need to first generate your own terrarium.json
file using the provided terrarium-template.json
.
To do that, simply replace the pisco
and phoenix
signers' mnemonics to one of your wallets, for testnet and mainnet respectively.
After that, just rename terrarium-template.json
to terrarium.json
and you're ready to run the deployment scripts.
To deploy a contract, you can run the following command:
yarn deploy:<contract>
Enterprise factory testnet:
yarn deploy:enterprise-factory
Enterprise factory mainnet:
yarn deploy:enterprise-factory:mainnet
To migrate a contract, you can run the following command:
yarn migrate:<contract>
Enterprise factory testnet:
yarn migrate:enterprise-factory
Enterprise factory mainnet:
yarn migrate:enterprise-factory:mainnet
Enterprise is using the standard CW20 and CW721 contract implementations for tokens and NFTs. The versions of those contracts used in different Enterprise versions are as follows:
Enterprise contract code ID | Enterprise code version (internal incremental versioning scheme for DAOs) | CW20 version | CW721 version |
---|---|---|---|
1327 | 2 | 1.0.1 | 0.16.0 |
1372 | 3 | 1.0.1 | 0.16.0 |
1397 | 4 | 1.0.1 | 0.16.0 |
Copyright 2022 Enterprise Protocol
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.