Code examples for building your own interface for Compound Protocol Governance. The COMP & Governance smart contracts are live on the Ethereum Main and Ropsten test networks.
Full Quick Start Tutorial on the Compound Medium Blog
Compound is an open-source, autonomous protocol built for developers, to unlock a universe of new financial applications. Interest and borrowing, for the open financial system. Learn more on the website:
The Compound protocol is upgraded and configured in a decentralized fashion. All changes (from supported assets, to system parameters) are decided by COMP token-holders using the voting system.
Community members can create proposals or vote on proposals to modify the protocol. This is made possible by the Compound Governance smart contract.
In order to participate in governance, users do not need to hold any COMP token in their Ethereum wallet. However, users need to have COMP delegated to their address. Delegation is a utility function in the COMP ERC-20 token contract.
Learn more in the Compound Protocol Governance Documentation.
The following code examples can be used in a Web3-enabled website.
There are examples for querying the Ethereum blockchain directly as well as examples that use the Compound REST API. Operations that get can be done using either implementation. However set operations must be performed by writing to the blockchain with Web3, which requires ETH to be spent on gas fees.
For latest contract addresses and ABIs, see the networks page in the docs.
- Example Web Page (Compound API)
- Example Web Page (Web3, Ropsten Only)
- Code Example (Compound API)
- Code Example (Web3 Only)
- Example Web Page (Compound API)
- Example Web Page (Web3, Ropsten Only)
- Code Example (Compound API)
- Code Example (Web3 Only)
- Example Web Page (Compound API)
- Example Web Page (Web3 Only)
- Code Example (Compound API)
- Code Example (Web3 Only)
- Example Web Page (Compound API)
- Example Web Page (Web3 Only)
- Code Example (Compound API)
- Code Example (Web3 Only)
- Delegate By Signature Web Page
- Delegate By Signature Code Example
- Cast Vote By Signature Web Page
- Cast Vote By Signature Code Example
- See the README for more context on signatures
Clone this repository. Use a Web3 enabled browser (like Brave, or install the MetaMask browser extension). Serve the files from an HTTP server; The HTML files will not work if you open them directly in your browser. The following command line commands includes an HTTP server, which is installed with Node.js and npm.
git clone git@github.com:compound-developers/compound-governance-examples.git
cd compound-governance-examples/
npm install -g http-server
http-server -p 8080
Then go to http://localhost:8080/api-examples/get_proposals in your web browser.