Crowdfunding App

Deploying a crowdfunding App using the Andromeda CLI.

We have covered earlier the App contract and its messages. We briefly discussed the steps to deploying an App. In this section we will be providing an example of how to deploy an App using the Andromeda CLI.

circle-exclamation

The Steps of Deploying an App

We already have an ADODB contract with saved code IDs of the ADOs and Kernel ADO deployed. These addresses can be found in Deployed Contracts section. This means that to deploy an App we only need to instantiate it through the CLI.

circle-exclamation

Defining our App

For this example we will be building a simple crowdfunding app. We will be creating NFTs that are sold in a crowdfund and then the proceeds are distributed to a sepcified address. If the crowdfund does not reach the threshold of minimum tokens sold, the money is refunded to the buyers.

Defining the Instantiation Messages

For this example, our App needs to have 5 components/ADOs:

circle-exclamation

Let us first start by representing the instantiation message for each of our ADOs:

circle-exclamation

CW721

circle-exclamation

The JSON message in our case is the following as Base64:

Crowdfund

As Base64:

App

circle-exclamation

There are several components found here. A simple name for the app, the components of the app itself and a reference to the “Kernel”. Each component of the app provides two values: a name used for referencing for other components within the app, and the base64 encoded instantiation message.

Instantiating the App

If you do not have the CLI downloaded, go to the Introduction to Apps section to get the latest version.

First, let us open the CLI by running andr in our terminal. We then need to choose the chain we want to deploy on. Run "chain use" in the CLI and select the testnet that you want to deploy on. For this example I will be using the Andromeda test-net Galileo-3.

circle-exclamation

We have already uploaded the App ADO to the Andromeda testnet. A simple way to check the latest code id for the App ADO is to query it from the ADODB using the chain you want to use.

In the CLI, while connected to the chain of choice, run:

The code Id to use will be returned.

Now we can instantiate our App. We will be using our wasm command to instantiate our app:

circle-exclamation

Upon instantiation, we will get a link to the explorer where we can check the transaction. Also the contract address of the App is displayed:

Transactionarrow-up-right

Open the explorer link where you can see that the instantiation was a success. Three contracts were instantiated in total which are the App and the 2 components we used.

Interacting with the App

circle-exclamation

Crowdfund

Now that the App has been created and we have ownership over all the components, we can proceed with minting the tokens for the crowdfund.

Minting the NFTs

We will be minting three new tokens using the crowdfund component.

circle-exclamation

Let us run the execute:

circle-exclamation

Transactionarrow-up-right

In this message multiple tokens are minted and their mint messages are proxied to the “tokens” contract found within the app. No owner is provided, although one can be declared, so the crowdfund contract is assigned as the owner of the tokens for the duration of the sale.

Since we have minted our tokens, we can now start the crowdfund sale.

Starting The Sale

We call the StartSale message to start the crowfunding sale on the NFTs we minted.

circle-exclamation
circle-exclamation

Let us run the execute:

Transaction arrow-up-right

This message commences a sale, listing each token for 10000uandr with a minimum of 0 and expires at time 1726223089000 . The recipient defined in this message will be the receiver of the funds after the sale has ended. In this case the recipient is another address.

Let's query the balance of the recipient before purchasing the NFTs. We run the following command::

Result:

The sale has started, time to purchase our minted tokens.

Purchase the NFTs

triangle-exclamation

For purchasing the tokens I will be using some addresses representing buyers.

Purchase token 1arrow-up-right

Purchase token 2arrow-up-right

Purchase token 3arrow-up-right

End The Sale

Now that the tokens have been sold the sale can be ended:

circle-exclamation
circle-exclamation

We have successfully:

  1. Minted tokens for the crowdfund

  2. Started a sale to sell the tokens

  3. Purchased the tokens for 1000 uandr each

  4. Ended the sale

Since each of the tokens was sold for 10000 uandr we should have 30000uandr sent to the recipient address that we specified in the StartSale message. To make sure of the results, let us check the balance again:

We can see that 30000uandr has been added to the balance.

You can also use the OwnerOf query to check who owns the NFTs now. It should correspond to your buyers.

Conclusion

This example serves as a small tutorial for building an Andromeda app using the CLI. We will have many more examples like this coming soon representing the different apps that we can build using our ADOs. These tutorials are mostly made for developers looking to use and build using our ADOs. All what we did here and more can be done using our user friendly web-app with a few clicks.

Last updated

Was this helpful?