DAO smart contract creation - General - Algorand

DAO smart contract creation

post by isha on Jan 30, 2022

Hi all.

I am actually planning to make a dao smart contract and dao token in Algorand is there any reference git link or video anything that anyone can share.

post by fabrice on Jan 31, 2022

Have you looked at algo-builder/examples/dao at master · scale-it/algo-builder · GitHub

post by isha on Feb 2, 2022

Great thanks a lot @fabrice

post by isha on Mar 16, 2022

Hi,

In my dapp I am putting all the stake collected by voting in a staking account.

Now I want to distribute this collected stake to all the yes voters based on how much they had staked.

How can I do that? Will I have to save the addresses of all the voters for the?

post by fabrice on Mar 16, 2022

The simplest solution is to store, for each user, how much they stake and the vote they made in their local storage.

Then to distribute the stake to all the yes voters, you will need to ask each yes voter to make a transaction to get back their stake. The smart contract will check their local storage and verify they voted yes. They will compute the amount to distribute using the amount they staked and the total amount staked (that you need to store in global storage).

Note: since global storage is limited to 64 key/value pairs, you cannot store all the addresses there; instead, you need to use local storage of each user. If you don’t know what “local storage” and “global storage” mean, please read Smart contract details - Algorand Developer Portal

post by isha on Mar 16, 2022

Okay I will try this.

Thanks a lot!

post by isha on Mar 21, 2022

Hi.

I am facing some issue in token transfer for the dao can anyone please check this If what I have done makes sense.


If((Btoi(Txn.application_args[2]) >= App.globalGet(min_stake_per_address))).Then(
            Seq(
            If((Btoi(Txn.application_args[2]) <= App.globalGet(max_stake_per_address))).Then(
             If(Btoi(Txn.application_args[1]) == Int(1)).Then(
                 Seq(
                App.globalPut(Bytes("Yes_count"), yes_count.load() + Btoi(Txn.application_args[2]))

InnerTxnBuilder.Begin(),
                InnerTxnBuilder.SetFields(
                    {
                    TxnField.type_enum: TxnType.AssetTransfer,
                    TxnField.xfer_asset: token_ID,
                    TxnField.sender: Global.current_application_address(),
                    TxnField.asset_receiver: App.globalGet(staking_account),
                    TxnField.asset_amount: App.globalGet(proposal_amount),
                    }
                ),
                InnerTxnBuilder.Submit(),
                )
            ),
        .Else(
            App.globalPut(Bytes("No_count"), no_count.load() + Btoi(Txn.application_args[2]))
        )
            ),
            )
        ),
        Approve(),
    )

Is there any other better way to do it?

post by fabrice on Mar 21, 2022

Here are some comments:


Seq([
   Assert(Btoi(Txn.application_args[2]) >= App.globalGet(min_stake_per_address)),
   Assert(Btoi(Txn.application_args[2]) <= App.globalGet(max_stake_per_address)),
   ...

post by isha on Mar 22, 2022

Hi.

Okay I’ll try with ‘Assert’.

Also is there any limit on how many asserts can be used?

post by fabrice on Mar 22, 2022

No limits apart from the program size and cost limits.

See The Algorand Virtual Machine (AVM) and TEAL. - Algorand Developer Portal and Algorand parameter tables - Algorand Developer Portal

post by isha on Mar 23, 2022

Great thanks!

I’ll try that!