How to interact with external contracts from your DAO

The Smart Contract Composer in the Aragon App gives you the ability to interact with external contracts directly from your DAO. You can compose a series of actions that become executable if a vote passes. This means your DAO can connect to almost any application in web3! 

For example, with the Smart Contract Composer you can….

  • Swap tokens in your DAO treasury 
  • Mint an NFT to your DAO 
  • Stake ETH from your DAO treasury (available soon)
  • Mint a post on Lens (available soon)

In this guide, we’ll cover the steps of interacting with an external contract from your DAO. We’ll use a Uniswap token swap as our example.

Let’s dive in!

1: Start from the DAO dashboard and click “new proposal”

To compose smart contracts that initiate a series of actions from your DAO, you’ll need to create and pass a proposal. If the proposal passes, the actions become executable. From the DAO Dashboard, click "New proposal." Or, go to the Governance tab and create a proposal from there.

2: Write the title, summary, and description of the proposal

Write a concise title that explains what your proposal is about and add a summary so voters can get a sense of what your proposal contains quickly. Then, write the full text of the proposal in the text box below. You can also add links to relevant resources, like a link to the original proposal on your DAO forum or to a tweet thread where voters can share it.

3: Choose the start and end time for your vote

In this step, you’ll set when the vote will start and how long it will last. You can choose to start the vote now or at a specific date and time in the future. The duration will be automatically set to the minimum duration you chose when you created your DAO. You can increase the duration if you’d like.

4: Click “Add Action” and “Smart Contract Composer”

You can withdraw assets, mint tokens, or connect to any external contract using the Smart Contract Composer. Click “Add action” and choose “interact with a contract.” 

 

5: Click “Connect smart contract” and paste the address 

Now it’s time to connect a smart contract to your DAO. Click “Connect smart contract.” 

A smart contract is a self-executing digital contract that is written with code and stored on a blockchain. It automatically executes predefined actions and enforces the terms and conditions agreed upon by the involved parties without the need for intermediaries.

Paste in the address of the smart contract you would like to interact with.

6. Validate the address and click “create action”

This is a security step to ensure you’re interacting with the contract you believe you are. After you paste ion the address, click “Validate contract address.”

Contract validation/verification is the process of evaluating a smart contract to ensure it operates as intended and meets the specified requirements. It involves analyzing the contract's functionality, conducting thorough testing, and verifying its compliance with predefined rules and logic.

Once the contract has been successfully verified by one source, click “Create action.”

In our example:

Now, because we’re interacting with two contracts in this example, we’re going to repeat steps 5 and 6 to connect the Uniswap V2 Router. You can add as many contracts as you need to interact with to complete your desired action. If you’re just interacting with one contract, you will not need to repeat these steps and can proceed to step 7.

When we’ve completed steps 5 and 6 for our second contract, we’ll have both the Uni and UniwswapV2 Router contracts available to interact with. 

7: Open the contract, choose an action, and fill out the information

Click into the contract on the lefthand side. You'll see all the actions that you can complete listed below it. Choose the action you want, which will open up information fields to complete.

When you're done filling out the fields, click "Add action."

In our example:

Open the Uni contract and choose the "approve" function. Fill in the following fields:

  • Spender: the UniswapV2 Router address: 0x1b02da8cb0d097eb8d57a175b88c7d8b47997506
  • RawAmount: we will swap 1 UNI, so we set the RawAmount to more than 1 UNI, let’s set it to 2 UNI. It is a token with 18 decimals so it becomes: 2000000000000000000

8: Add other actions if needed

Now, you can see that one action has been created and added to your proposal. If the proposal passes, the action will be executable, meaning any wallet can approve it.

You may want to complete just one action. In that case, click "Next" to add this action to your proposal and prepare the proposal for vote.

If you want to add more actions, click "Add action" to open up the Smart Contract Composer again.

In our example:

To complete this swap, we’re going to add another action: interacting with the Uniswap V2 Router. 

Click “Add action” to open up the Smart Contract Composer again.

Click “Interact with a contract” then open the Uniswap V2 Router contract. Scroll down and choose “swapExacttokensforEth.”

Fill in the following fields:

  • AmountIn: we will swap 1 UNI, so we set theAmountIn to 1 UNI. It is a token with 18 decimals so it becomes: 1000000000000000000
  • AmountOutMin: according to market value 1 UNI can be swapped for around 0.036 ETH. ETH is a token with 18 decimals, so it becomes: 36000000000000000
  • Path: here we input the contract address of UNI followed by the contract address of Wrapped Ether (WETH) which is used in the conversion: ["0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"]
  • To: paste in your DAO Contract address, which you can find under Finance > New Transfer > Deposit. In the case of this example it is: 0x1ba90aebe0e75b91f17d339264ab41f358e51ab8 (do NOT use the ENS address)
  • Deadline: for this we need to convert the current time +20 minutes to a Unix Timestamp. Go to https://www.unixtimestamp.com/ , add 20 minutes to the current time, and press “Convert” Copy/ paste the Unix Timestamp, which in this case is: 1684936793

When these steps are complete, click “Add action.”

9: Publish the proposal

Once you're done adding actions in the Smart Contract Composer, you can publish the proposal! Review the actions and click “Next.”

Review the proposal and click “Publish proposal.”

10: Wait for members to cast their votes

If the proposal passes, the actions will be available to execute. All you need to do then is click "Execute" and the tokens swapped in your DAO treasury!

If the proposal does not pass and you still want to execute the action, you’ll need to start the process again with a new proposal. 

Stay tuned for more guides and videos on performing specific actions in the App!

Get started on the Aragon App!

Launch your DAO on the Aragon App to start using the Smart Contract Composer and the other powerful tools in the App!

Discover the Aragon App, the no-code way to build your DAO.
Get help starting your DAO from a DAO Expert.
Stay up to date with our weekly newsletter.

Explore more guides

Need Help? Find an Expert
Hire the DAO expertise you need and connect with DAO experts to build your DAO, your way.