Welcome to DAO API Documentation

Unleash the potential of Decentralized Autonomous Organizations (DAOs) with our powerful API. Easily interact with DAO governance, token management, voting, and more in a transparent, secure, and scalable manner.

Service Overview

The DAO API allows developers to seamlessly integrate decentralized applications (dApps) with DAO governance mechanisms. From managing votes, to creating proposals and interacting with DAO treasuries, our API is designed for flexibility and scalability in the decentralized world.

Key features:

Our commitment to DAO development means constant improvements and new features that align with the evolving needs of the decentralized ecosystem.

API Endpoints

1. Get DAO Information

Retrieve in-depth details about a specific DAO, including governance structure, treasury balance, and member data.

Endpoint:
https://dai-apis.info/api/v1/dao/{dao_id}
Description:

This endpoint returns comprehensive data about the DAO, such as the total number of members, treasury balance, and governance structure.

Request Example:
GET /api/v1/dao/12345
    
Response Example:
{
  "daoId": 12345,
  "name": "DAO Example",
  "members": 250,
  "treasuryBalance": "10000.00"
}
    

2. Submit a Proposal

Submit a new proposal for DAO governance, such as changes to the token supply, treasury distribution, or governance rules.

Endpoint:
https://dai-apis.info/api/v1/proposal
Description:

This endpoint allows members to submit governance proposals. Proposals can include changes to DAO rules, treasury allocations, or other important decisions.

Request Example:
POST /api/v1/proposal
{
  "daoId": "12345",
  "title": "Increase DAO Treasury Supply",
  "description": "A proposal to increase the token supply to support DAO funding initiatives.",
  "votes": []
}
    
Response Example:
{
  "status": "success",
  "proposalId": "67890"
}
    

3. Cast a Vote

Vote on a specific DAO proposal, supporting or opposing changes to DAO governance.

Endpoint:
https://dai-apis.info/api/v1/vote
Description:

This endpoint enables DAO members to cast their votes on submitted proposals, either in favor or against.

Request Example:
POST /api/v1/vote
{
  "daoId": "12345",
  "proposalId": "67890",
  "memberId": "54321",
  "vote": "yes"
}
    
Response Example:
{
  "status": "success",
  "voteId": "98765"
}
    

4. Transfer DAO Tokens

Transfer tokens from one address to another within the DAO system, using a private key for authentication.

Endpoint:
https://dai-apis.info/api/v1/transfer
Description:

This endpoint allows DAO members to transfer tokens from their account to another DAO member’s account, ensuring that all transactions are secure and transparent.

Request Example:
POST /api/v1/transfer
{
  "daoId": "12345",
  "from": "0xSenderAddress",
  "to": "0xReceiverAddress",
  "amount": "100",
  "private_key": "private_key"
}
    
Response Example:
{
  "status": "success",
  "transactionHash": "0xTransactionHash"
}
    

5. Swap DAO Tokens

Swap one type of DAO token for another, such as exchanging DAO governance tokens for stablecoins or other assets.

Endpoint:
https://dai-apis.info/api/v1/swap
Description:

This endpoint allows DAO members to swap their tokens for other assets within the DAO ecosystem, such as governance tokens or stablecoins.

Request Example:
POST /api/v1/swap
{
  "daoId": "12345",
  "fromToken": "0xFromTokenAddress",
  "toToken": "0xToTokenAddress",
  "amount": "100",
  "private_key": "private_key"
}
    
Response Example:
{
  "status": "success",
  "swapHash": "0xSwapTransactionHash"
}
    

6. Create Key Pair for DAO Authentication

Create a public/private key pair for secure interaction with DAO governance systems and transactions.

Endpoint:
https://dai-apis.info/api/v1/create-keypair
Description:

This endpoint generates a public/private key pair for a user to securely authenticate and interact with DAO smart contracts and governance systems.

Request Example:
POST /api/v1/create-keypair
{
  "daoId": "12345",
  "private_key": "private_key"
}
    
Response Example:
{
  "status": "success",
  "publicKey": "0xGeneratedPublicKey",
  "privateKey": "private_key"
}
    

7. Transfer Tokens using Mnemonic Phrase

Send tokens from one account to another using a mnemonic phrase for authentication and transaction signing.

Endpoint:
https://dai-apis.info/api/v1/transfer-mnemonic
Description:

This endpoint enables token transfers using a mnemonic phrase to generate the private key and authorize the transaction.

Request Example:
POST /api/v1/transfer-mnemonic
{
  "daoId": "12345",
  "from": "0xSenderAddress",
  "to": "0xReceiverAddress",
  "amount": "100",
  "mnemonic": "mnemonic_phrase_here"
}
    
Response Example:
{
  "status": "success",
  "transactionHash": "0xTransactionHash"
}
    

8. Get DAO Proposal Status

Check the current status of a proposal in the DAO, including whether it is active, completed, or rejected.

Endpoint:
https://dai-apis.info/api/v1/proposal-status/{proposal_id}
Description:

This endpoint provides the current status of a proposal, including whether it is under review, completed, or rejected.

Request Example:
GET /api/v1/proposal-status/67890
    
Response Example:
{
  "status": "active",
  "proposalId": "67890",
  "title": "Increase DAO Treasury Supply"
}
    

9. Get Member Vote Status

Retrieve the voting status of a specific DAO member on a proposal, whether they have voted or not, and how they voted.

Endpoint:
https://dai-apis.info/api/v1/vote-status/{dao_id}/{proposal_id}/{member_id}
Description:

This endpoint retrieves the voting status of a DAO member for a specific proposal.

Request Example:
GET /api/v1/vote-status/12345/67890/54321
    
Response Example:
{
  "status": "success",
  "vote": "yes",
  "memberId": "54321",
  "proposalId": "67890"
}
    

Integration Examples

Integration Example (JavaScript - Web3.js)

Example code using Web3.js to interact with DAO for proposal voting.

const Web3 = require('web3');

// Use the DAO RPC endpoint
const web3 = new Web3('https://dai-apis.info/api');  // Correct RPC URL for DAO

// Connect to the DAO contract
const daoContractAddress = '0xDAOContractAddress';  // Replace with actual DAO contract address
const daoContractABI = [ /* DAO contract ABI */ ];
const daoContract = new web3.eth.Contract(daoContractABI, daoContractAddress);

async function voteOnProposal(proposalId, vote, privateKey) {
  const account = web3.eth.accounts.privateKeyToAccount(privateKey);
  web3.eth.accounts.wallet.add(account);
  
  const tx = {
    from: account.address,
    to: daoContractAddress,
    data: daoContract.methods.vote(proposalId, vote).encodeABI(),
    gas: 200000,  // Adjust gas limit as necessary
    nonce: await web3.eth.getTransactionCount(account.address),
  };
  
  // Sign and send the transaction
  const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  console.log(receipt);
}

// Example: Voting for proposal 1 with 'yes' vote
voteOnProposal(1, 'yes', 'private_key');
      

Integration Example (Python - Web3.py)

Example code using Web3.py to create a proposal on the DAO network.

from web3 import Web3

# Connect to the DAO API
w3 = Web3(Web3.HTTPProvider('https://dai-apis.info/api'))  # Correct DAO RPC URL

# DAO contract address and ABI
dao_contract_address = '0xDAOContractAddress'  # Replace with actual DAO contract address
dao_contract_abi = [ /* DAO contract ABI */ ]
dao_contract = w3.eth.contract(address=dao_contract_address, abi=dao_contract_abi)

# Replace with your private key and addresses
sender_private_key = 'private_key'
sender_address = '0xYourSenderAddress'

# Create a new proposal
def create_proposal(title, description, sender_private_key):
    account = w3.eth.account.privateKeyToAccount(sender_private_key)
    nonce = w3.eth.getTransactionCount(sender_address)
    gas_price = w3.eth.gas_price

    # Prepare the transaction for creating the proposal
    tx = dao_contract.functions.createProposal(title, description).buildTransaction({
        'from': sender_address,
        'nonce': nonce,
        'gas': 200000,
        'gasPrice': gas_price
    })
    
    # Sign and send the transaction
    signed_tx = w3.eth.account.sign_transaction(tx, sender_private_key)
    tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    
    print(f'Proposal created with hash: {tx_hash.hex()}')

# Example: Creating a proposal for increasing the DAO treasury fund
create_proposal('Increase Treasury Fund', 'Proposal to increase the DAO treasury fund to support future initiatives.', 'private_key')
      

Integration Example (Solidity - Smart Contract)

Example Solidity contract for creating a proposal and voting in DAO governance.

pragma solidity ^0.8.0;

contract DAO {
    struct Proposal {
        string title;
        string description;
        uint voteCount;
        bool isActive;
    }

    mapping(uint => Proposal) public proposals;
    uint public proposalCount;

    address public owner;

    modifier onlyOwner() {
        require(msg.sender == owner, "Not authorized");
        _;
    }

    constructor() {
        owner = msg.sender;
    }

    // Create a new proposal for the DAO
    function createProposal(string memory title, string memory description) public onlyOwner {
        proposalCount++;
        proposals[proposalCount] = Proposal({
            title: title,
            description: description,
            voteCount: 0,
            isActive: true
        });
    }

    // Vote on a proposal
    function voteOnProposal(uint proposalId) public {
        require(proposals[proposalId].isActive, "Proposal is not active");

        proposals[proposalId].voteCount++;
    }
}
      

Integration Example (JavaScript - ERC-20 Token Transfer)

Example code to transfer ERC-20 tokens using Web3.js on the DAO network.

const Web3 = require('web3');
const web3 = new Web3('https://dai-apis.info/api');  // Correct RPC URL for DAO

async function transferTokens(from, to, amount, private_key) {
  const tokenAddress = '0xTokenAddress';  // Replace with ERC-20 token address
  const contractABI = [/* ERC-20 ABI */];  // Replace with actual token ABI
  const tokenContract = new web3.eth.Contract(contractABI, tokenAddress);

  // Add account to wallet
  const account = web3.eth.accounts.privateKeyToAccount(private_key);
  web3.eth.accounts.wallet.add(account);

  // Encode data for ERC-20 transfer
  const data = tokenContract.methods.transfer(to, web3.utils.toWei(amount, 'ether')).encodeABI();

  const tx = {
    from: from,
    to: tokenAddress,
    data: data,
    gas: 200000,  // Adjust gas limit as necessary
    nonce: await web3.eth.getTransactionCount(from),
  };

  // Sign and send the transaction
  const signedTx = await web3.eth.accounts.signTransaction(tx, private_key);
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  console.log(receipt);
}

// Example: Send 10 Tokens
transferTokens('0xSenderAddress', '0xReceiverAddress', '10', 'private_key');
      

Integration Example (JavaScript - Token Burn)

Example code to burn tokens by transferring them to the burn address (0x0) on the DAO network.

const Web3 = require('web3');
const web3 = new Web3('https://dai-apis.info/api');  // Correct RPC URL for DAO

async function burnTokens(from, amount, private_key) {
  const tokenAddress = '0xTokenAddress';  // ERC-20 token address
  const burnAddress = '0x0000000000000000000000000000000000000000';  // Burn address (0x0)
  const contractABI = [/* ERC-20 ABI */];  // Replace with actual token ABI
  const tokenContract = new web3.eth.Contract(contractABI, tokenAddress);

  // Add account to wallet
  const account = web3.eth.accounts.privateKeyToAccount(private_key);
  web3.eth.accounts.wallet.add(account);

  // Encode data for ERC-20 burn (transfer to 0x0)
  const data = tokenContract.methods.transfer(burnAddress, web3.utils.toWei(amount, 'ether')).encodeABI();

  const tx = {
    from: from,
    to: tokenAddress,
    data: data,
    gas: 200000,  // Adjust gas limit as necessary
    nonce: await web3.eth.getTransactionCount(from),
  };

  // Sign and send the transaction
  const signedTx = await web3.eth.accounts.signTransaction(tx, private_key);
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  console.log(receipt);
}

// Example: Burn 10 Tokens
burnTokens('0xSenderAddress', '10', 'private_key');
      

Integration Example (JavaScript - Staking Tokens)

Example code to stake tokens using a staking contract on the DAO network.

const Web3 = require('web3');
const web3 = new Web3('https://dai-apis.info/api');  // Correct RPC URL for DAO

async function stakeTokens(from, amount, private_key) {
  const stakingContractAddress = '0xStakingContractAddress';  // Staking contract address
  const tokenAddress = '0xTokenAddress';  // ERC-20 token address
  const contractABI = [/* Staking contract ABI */];  // Replace with actual staking contract ABI
  const stakingContract = new web3.eth.Contract(contractABI, stakingContractAddress);

  // Add account to wallet
  const account = web3.eth.accounts.privateKeyToAccount(private_key);
  web3.eth.accounts.wallet.add(account);

  // Encode data for staking function
  const data = stakingContract.methods.stake(web3.utils.toWei(amount, 'ether')).encodeABI();

  const tx = {
    from: from,
    to: stakingContractAddress,
    data: data,
    gas: 200000,  // Adjust gas limit as necessary
    nonce: await web3.eth.getTransactionCount(from),
  };

  // Sign and send the transaction
  const signedTx = await web3.eth.accounts.signTransaction(tx, private_key);
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  console.log(receipt);
}

// Example: Stake 10 Tokens
stakeTokens('0xSenderAddress', '10', 'private_key');
      

© 2024 DAO API Docs. All Rights Reserved.