Skip to main content
MAIN CHAIN

Building Governance Tools

This guide is for developers building governance dashboards, voting interfaces, or indexers on top of the ELA main chain. You'll use the JSON-RPC interface (port 20336 on mainnet) for all queries and transaction submission.

Prerequisites: A running ELA node or access to a public RPC endpoint. See Network Endpoints for URLs.

Querying DAO State

Council Members

// List all candidates
{ "method": "listcrcandidates", "params": { "start": 0, "limit": 25, "state": "all" } }

// List seated council members
{ "method": "listcurrentcrs", "params": { "start": 0, "limit": 25 } }

// List next term's council members
{ "method": "listnextcrs", "params": {} }

// Get current governance stage (voting period, committee state, next election height)
{ "method": "getcrrelatedstage", "params": {} }

Proposals

// List proposal states
{ "method": "listcrproposalbasestate", "params": { "start": 0, "limit": 25, "state": "all" } }

// Get specific proposal details (status, budgets, vote results, tracking)
{ "method": "getcrproposalstate", "params": { "proposalhash": "abc123..." } }

// Get proposal draft document
{ "method": "getproposaldraftdata", "params": { "drafthash": "abc123..." } }

// Get available DAO funds
{ "method": "getcommitteecanuseamount", "params": {} }

BPoS Validators

// List all validators
{ "method": "listproducers", "params": { "start": 0, "limit": 100, "state": "all" } }

// Get current validator set (active, candidates, on-duty)
{ "method": "getarbitersinfo", "params": {} }

// Get voting status for an address
{ "method": "votestatus", "params": { "address": "EXxxxx..." } }

// Get producer deposit
{ "method": "getdepositcoin", "params": { "ownerpublickey": "03abc..." } }

// Get council member deposit
{ "method": "getcrdepositcoin", "params": { "id": "icJ4z2..." } }

BPoS Staking

// Detailed v2 vote info
{ "method": "getalldetaileddposv2votes", "params": { "address": "EXxxxx..." } }

// Get voter's rights
{ "method": "getvoterights", "params": { "address": "EXxxxx..." } }

// BPoS voter reward info
{ "method": "dposv2rewardinfo", "params": { "address": "EXxxxx..." } }

Submitting Transactions

// Broadcast a signed transaction
{ "method": "sendrawtransaction", "params": { "data": "<hex-encoded-signed-tx>" } }

// Build an unsigned transaction
{ "method": "createrawtransaction", "params": {
"inputs": [{ "txid": "abc...", "vout": 0 }],
"outputs": [{ "address": "EXxxxx...", "amount": "1.0" }]
} }

// Sign a transaction
{ "method": "signrawtransactionwithkey", "params": {
"data": "<hex-unsigned-tx>",
"codes": ["<hex-redeem-script>"],
"privkeys": ["<private-key>"]
} }

Transaction Structure

Every ELA governance transaction follows this format:

FieldTypeDescription
Versionuint8Transaction format version
TxTypeuint8Type code (0x21, 0x25, etc.)
PayloadVersionuint8Payload format version
PayloadbytesType-specific payload (serialized)
Inputs[]InputUTXO inputs (for fees)
Outputs[]OutputUTXO outputs
Programs[]ProgramSignature scripts

Building a Council Vote Transaction

  1. Query UTXOs: listunspent { "addresses": ["EXxxxx..."] }
  2. Construct a TransferAsset (type 0x02) with an OTVote output
  3. Set VoteType to CRC (0x02) and list candidates with vote amounts
  4. Sign with your P-256 private key
  5. Broadcast: sendrawtransaction { "data": "<hex>" }

Key Constants

ConstantValue
ELA Asset IDa3d0eaa466df74983b5d7c543de6904f4c9418ead5ffd6d25814234a96db37b0
1 ELA100,000,000 sela
Main chain signaturesP-256 curve
ESC/EID signaturessecp256k1

Indexing Governance Data

For historical governance data, the Elastos.ORG.API.Misc service provides a blockchain indexer:

EndpointPurpose
/api/1/history/{addr}Transaction history for an address
/api/1/dpos/producer/{producer}/{height}Producer stats at a given height
/api/1/dpos/address/{address}Voter stats for an address
/api/1/dpos/rank/height/{height}Producer rankings at a height
/api/1/dpos/vote/height/{height}Total votes at a height

Monitoring

The Elastos.ELA.Monitor (Python) provides alerting scripts:

ScriptMonitors
warn_node_height.pyBlock height stalls
warn_producer_state.pyProducer becomes inactive/illegal
warn_onduty.pyValidator duty rotation issues
warn_tx_pool.pyTransaction pool overflow

SDKs and Libraries

LanguageComponentRepository
GoMain chain nodeelastos/Elastos.ELA
TypeScriptElection serviceelastos/Elastos.Service.Election
TypeScriptGovernance portalCyberRepublic/CyberRepublic
SolidityStaking NFTs (ESC)elastos/Elastos.ELA.StakeTicket.Solidity
PythonNode monitoringelastos/Elastos.ELA.Monitor
GoBlockchain indexerelastos/Elastos.ORG.API.Misc