LogoLogo
  • Introduction
    • Chain Info
    • Smart Contracts
    • About Onyx
  • DEVELOPERS
    • Building dApp
    • Estimating Gas
    • Development Framework
    • Web3 Toolkits
    • Onyx SDK
    • Run Full Node
  • GOVERNANCE
    • Overview
    • Governor
    • Security
    • Quorum Votes
    • Proposal Threshold
    • Proposal Max Operations
    • Voting Delay
    • Voting Period
    • Propose
    • Queue
    • Execute
    • Cancel
    • Get Action
    • Get Receipt
    • Proposal State
    • Cast Vote
    • Vote By Signature
    • Timelock
  • Points
    • Onyx Points
    • Earning Points
      • 🟢Passive Points
      • 🔜Activity Points
      • 🔜App Points
  • Whitelisted Assets
  • Onyx AI
    • AI Agent
    • Core Features
    • Wallet Infrastructure
    • 🔜Roadmap
  • API
    • Onyx Governance API
    • Core API Endpoints
    • GET: /proposal
    • GET: /proposal/:proposalId
    • GET: /voter/:proposalId
    • GET: /voter/accounts
    • GET: /voter/history/:address
  • RESOURCES
    • Terms of Service
    • Bug Bounty
Powered by GitBook
On this page
Export as PDF
  1. GOVERNANCE

Execute

Deploying an Onyx Improvement Propoal (OIP) via onchain activation.

The execute function is responsible for applying changes from a successfully approved and queued proposal to the designated target contracts within the Onyx protocol. Once a proposal has passed the governance process and completed the Timelock delay period, it can be executed, implementing the proposed modifications.

Function Implementation in CHNGovernance

The execute() function ensures that only successful and properly queued proposals can be executed, enforcing governance integrity and protocol security.

Function Signature

function execute(uint proposalId) public payable returns (uint)

Parameters

  • proposalId: The unique identifier of the proposal to be executed. This proposal must have successfully passed governance voting, been queued, and completed the Timelock delay period.

  • RETURN: The function does not return a value. If execution fails due to an invalid or non-queued proposal, it will revert with an error.

Example Solidity Implementation

To execute a proposal using Solidity, the execute()function can be called from an instance of the CHNGovernance contract:

CHNGovernance gov = CHNGovernance(0x123...); // Contract address of CHNGovernance
gov.execute(proposalId).value(999).gas(999)();

Web3.js Implementation (v1.2.6)

For interacting with the CHNGovernance contract using Web3.js, the following example demonstrates how to execute a proposal:

const tx = await gov.methods.execute(proposalId).send({ from: sender, value: 1 });

Technical Considerations

  • The execute() function is state-modifying and will incur gas costs.

  • A proposal must have been successfully queued and completed the Timelock delay period before it can be executed.

  • The function is payable, allowing the Timelock to invoke functions that require ETH transfers.

  • If an attempt is made to execute an invalid, unqueued, or pending proposal, the transaction will revert with an error.

  • The Timelock contract ensures security and decentralization, preventing immediate execution after proposal approval.

PreviousQueueNextCancel

Last updated 3 months ago