Deposit
In regards to deposit
, anyone can deposit assets into a DAO. You don't need any specific permission
to do that.
Withdraw
Withdrawing of course is riskier, so permissions are needed.
The way you would withdraw is actually calling on the execute
function from the DAO.sol
contract. So in order to call it, the address needs the EXECUTE
permission.
You would then call something like this:
_dao.execute(
bytes32(_proposalId),
_actions,
_allowFailureMap
);
- If you want to simply transfer ETH, you would add an
action
like { to: recipientAddress, value: ethAmount, data: null }
- If you want to transfer an ERC20, you would add an
action
like { to: tokenContractAddress, value: 0, data: "<encoded-transfer(to, value)>"}
- If you want to send an NFT, same as above.
- If you want to swap Uniswap tokens, you would encode
{ to: uniswapPoolAddr, value: 0, data: "<encoded-swap(...)>" }
All of these actions you can encode and decode using the aragonOSx SDK (https://github.com/aragon/sdk).
Withdraw Examples
Here's an example of how to set it when you want to transfer funds upon a proposal approval:
proposal.actions = [
{ to: recipient, value }, // ETH
{ to: daiContract, value: 0, data: abiEncode(transfer, ...) }, // ERC20
// ...
];
Here's an example of how it can be set up within a plugin:
(Thank you @AbuUsama for the code snippet!)