Andromeda
Ask or search…
K
Comment on page

Marketplace App

Deploying a marketplace App with modules using the Andromeda CLI.
If unfimailar with the steps of deploying an app, go back to the first example where we explain in detail all the different parts of deploying an App.
If any of the messages in this example do not work, you might want to cross reference the messages with the ADO specific section which always contains the latest ADO versions to make sure they are correct. Other than that the logic will remain the same.
Make sure to read the Introduction to Apps before going through building an app.

Defining our App

For this App, we will be selling NFTs using the Marketplace ADO. We will also be showcasing two of our modules by adding rates and an address list to the marketplace. The steps that will be performed:
  • Mint NFTs
  • Setup the marketplace with modules attached
  • Send the NFTs to the markeplace to be sold
  • Check that all the results are as expected

Defining the Messages

The components/ADOs we would need:
Although not necessary, if you are unfamiliar with these ADOs, it is suggested to read through each of the them before deploying an app.
Let us first start by representing the instantiation message for each of our ADOs:
Keep in mind that the app takes these messages as base64 encoded.

CW721

Make sure to set the minter as your own address.
{
"name":"MarketplaceNFTs",
"symbol":"MNFT",
"minter":"<your-address>",
"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"
}
As base64:
eyJuYW1lIjoiTWFya2V0cGxhY2VORlRzIiwic3ltYm9sIjoiTU5GVCIsIm1pbnRlciI6ImFuZHIxZzBjMHk4cHJraHdybmZmcnc4YWZ3ZHBsdjl3bTV3Z3Q5aGR2N3UiLCJrZXJuZWxfYWRkcmVzcyI6ImFuZHIxNTlsbHc3eGtwdDIwbGx4cW1qZWdzZWdmbjU0OHE1bDZqcjJ4N3JoN3N5N3NhbDM5c3lmczN0bHZtbSJ9

Rates

We will add 10% royalties to the NFTs that will be received by another address.
We set is_additive to false to indicate that the rate is a royalty.
Use one of your testnet addresses as a recipient to the rates. You can check the balance of the address before and after the sale of the NFT to ensure the rates where distributed properly.
{
"rates":[
{
"rate":{
"percent":{
"percent":"0.1"
}
},
"is_additive":false,
"recipients":[{"address":"<one-of-your-addresses>"}]
}
],
"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"
}
As base64:
eyJyYXRlcyI6W3sicmF0ZSI6eyJwZXJjZW50Ijp7InBlcmNlbnQiOiIwLjEifX0sImlzX2FkZGl0aXZlIjpmYWxzZSwicmVjaXBpZW50cyI6W3siYWRkcmVzcyI6ImFuZHIxY3A5dnh2cGxnamY1MDh0aHRhY3Z4ZWg2cXhxc3g2N2dzZXFjZDUifV19XSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ==

Address List

The address list can be used to either whitelist or blacklist addresses from interacting with the marketplace ADO. I will blacklist one address for this example:
{
"is_inclusive": false,
"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"
}
As base64:
eyJpc19pbmNsdXNpdmUiOiBmYWxzZSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ==

Marketplace

We will attach the two modules to the marketplace ADO.
{
"modules":[
{
"name":"address-list",
"address":"./blacklist",
"is_mutable": false
},
{
"name":"rates",
"address":"./royalties",
"is_mutable":false
}
],
"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"
}
As base64:
eyJtb2R1bGVzIjpbeyJuYW1lIjoiYWRkcmVzcy1saXN0IiwiYWRkcmVzcyI6Ii4vYmxhY2tsaXN0IiwiaXNfbXV0YWJsZSI6IGZhbHNlfSx7Im5hbWUiOiJyYXRlcyIsImFkZHJlc3MiOiIuL3JveWFsdGllcyIsImlzX211dGFibGUiOmZhbHNlfV0sImtlcm5lbF9hZGRyZXNzIjoiYW5kcjE1OWxsdzd4a3B0MjBsbHhxbWplZ3NlZ2ZuNTQ4cTVsNmpyMng3cmg3c3k3c2FsMzlzeWZzM3Rsdm1tIn0=

App

The Kernel address used here might be outdated in the future. Check our deployed contracts to get the latest Kernel or run "chain config" in CLI which will also display the address.
{
"name": "Marketplace App",
"app_components": [
{
"name": "NFTs",
"ado_type": "cw721",
"component_type":{
"new":"eyJuYW1lIjoiTWFya2V0cGxhY2VORlRzIiwic3ltYm9sIjoiTU5GVCIsIm1pbnRlciI6ImFuZHIxZzBjMHk4cHJraHdybmZmcnc4YWZ3ZHBsdjl3bTV3Z3Q5aGR2N3UiLCJrZXJuZWxfYWRkcmVzcyI6ImFuZHIxNTlsbHc3eGtwdDIwbGx4cW1qZWdzZWdmbjU0OHE1bDZqcjJ4N3JoN3N5N3NhbDM5c3lmczN0bHZtbSJ9"
}
},
{
"name": "royalties",
"ado_type": "rates",
"component_type":{
"new":"eyJyYXRlcyI6W3sicmF0ZSI6eyJwZXJjZW50Ijp7InBlcmNlbnQiOiIwLjEifX0sImlzX2FkZGl0aXZlIjpmYWxzZSwicmVjaXBpZW50cyI6W3siYWRkcmVzcyI6ImFuZHIxY3A5dnh2cGxnamY1MDh0aHRhY3Z4ZWg2cXhxc3g2N2dzZXFjZDUifV19XSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ=="
}
},
{
"name": "blacklist",
"ado_type": "address-list",
"component_type":{
"new":"eyJpc19pbmNsdXNpdmUiOiBmYWxzZSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ=="
}
},
{
"name": "marketplace",
"ado_type": "marketplace",
"component_type":{
"new":"eyJtb2R1bGVzIjpbeyJuYW1lIjoiYWRkcmVzcy1saXN0IiwiYWRkcmVzcyI6Ii4vYmxhY2tsaXN0IiwiaXNfbXV0YWJsZSI6IGZhbHNlfSx7Im5hbWUiOiJyYXRlcyIsImFkZHJlc3MiOiIuL3JveWFsdGllcyIsImlzX211dGFibGUiOmZhbHNlfV0sImtlcm5lbF9hZGRyZXNzIjoiYW5kcjE1OWxsdzd4a3B0MjBsbHhxbWplZ3NlZ2ZuNTQ4cTVsNmpyMng3cmg3c3k3c2FsMzlzeWZzM3Rsdm1tIn0="
}
}
],
"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"
}
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.
If this is the first time using the CLI make sure to run "wallet add <wallet-name>"in order to create a wallet. Then go to that chain's faucet (usually located in their discord) and request tokens.
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:
ado db getcodeid app-contract
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:
Do not copy and paste the command below as it will not work. Make sure to make the appropriate changes before running the command.
Replace the <code_id> with the returned code-id for the app ADO.
wasm instantiate <app-code-id> '{"name": "Marketplace App","app_components": [{"name": "NFTs","ado_type": "cw721","component_type":{"new":"eyJuYW1lIjoiTWFya2V0cGxhY2VORlRzIiwic3ltYm9sIjoiTU5GVCIsIm1pbnRlciI6ImFuZHIxZzBjMHk4cHJraHdybmZmcnc4YWZ3ZHBsdjl3bTV3Z3Q5aGR2N3UiLCJrZXJuZWxfYWRkcmVzcyI6ImFuZHIxNTlsbHc3eGtwdDIwbGx4cW1qZWdzZWdmbjU0OHE1bDZqcjJ4N3JoN3N5N3NhbDM5c3lmczN0bHZtbSJ9"}},{"name": "royalties","ado_type": "rates","component_type":{ "new":"eyJyYXRlcyI6W3sicmF0ZSI6eyJwZXJjZW50Ijp7InBlcmNlbnQiOiIwLjEifX0sImlzX2FkZGl0aXZlIjpmYWxzZSwicmVjaXBpZW50cyI6W3siYWRkcmVzcyI6ImFuZHIxY3A5dnh2cGxnamY1MDh0aHRhY3Z4ZWg2cXhxc3g2N2dzZXFjZDUifV19XSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ=="}},{"name": "blacklist","ado_type": "address-list","component_type":{ "new":"eyJpc19pbmNsdXNpdmUiOiBmYWxzZSwia2VybmVsX2FkZHJlc3MiOiJhbmRyMTU5bGx3N3hrcHQyMGxseHFtamVnc2VnZm41NDhxNWw2anIyeDdyaDdzeTdzYWwzOXN5ZnMzdGx2bW0ifQ=="}},{"name": "marketplace","ado_type": "marketplace","component_type":{ "new":"eyJtb2R1bGVzIjpbeyJuYW1lIjoiYWRkcmVzcy1saXN0IiwiYWRkcmVzcyI6Ii4vYmxhY2tsaXN0IiwiaXNfbXV0YWJsZSI6IGZhbHNlfSx7Im5hbWUiOiJyYXRlcyIsImFkZHJlc3MiOiIuL3JveWFsdGllcyIsImlzX211dGFibGUiOmZhbHNlfV0sImtlcm5lbF9hZGRyZXNzIjoiYW5kcjE1OWxsdzd4a3B0MjBsbHhxbWplZ3NlZ2ZuNTQ4cTVsNmpyMng3cmg3c3k3c2FsMzlzeWZzM3Rsdm1tIn0="}}],"kernel_address":"andr159llw7xkpt20llxqmjegsegfn548q5l6jr2x7rh7sy7sal39syfs3tlvmm"}'
You will be using the contract addresses that were instantiated for you instead of the ones in this tutorial.

Interacting with the App

Andromeda contracts assign the original instantiator as contract owners. Due to how instantiation via a submessage operates in CosmWasm contracts, we must claim ownership of the components in order to execute messages that have authorization restrictions (owner restricted).
You can also use proxy messages to execute through the app ADO itself, but for these examples we will be claiming ownership.

Claim Components

{
"claim_ownership":{}
}
wasm execute <app-contract-address> '{"claim_ownership":{}}'

Add Address to the address-list

We have instantiated the address list but have yet to add an address to blacklist. Let us do it before interacting with the marketplace.
{
"add_address":{
"address": "<address-to-blacklist>"
}
}
wasm execute <address-list-address> '{"add_address": {"address": "<address-to-blacklist>"}}'

Mint NFTs

Now we need to mint an NFT to send to the marketplace.
{
"mint": {
"token_id":"1",
"owner":"<your-address>",
"token_uri":"https://gateway.pinata.cloud/ipfs...",
"extension": {
"publisher": "Andromeda"
}
}
}
wasm execute <cw721-contract-address> '{"mint": {"token_id":"1","owner":"andr1g0c0y8prkhwrnffrw8afwdplv9wm5wgt9hdv7u","token_uri":"https://gateway.pinata.cloud/ipfs...","extension": {"publisher": "Andromeda"}}}'

Send NFT to Marketplace to be Sold

In order to start a sale on the NFT, we need to send it to the marketplace ADO.
{
"send_nft": {
"contract": "<marketplace-contract-address>",
"token_id": "1",
"msg": "eyJzdGFydF9zYWxlIjp7InByaWNlIjogIjEwMDAwIiwiY29pbl9kZW5vbSI6InVhbmRyIn19"
}
}
The attached message is a start_sale message to start the auction when the NFT is sent.
{
"start_sale":{
"price": "10000",
"coin_denom":"uandr"
}
}
wasm execute <cw721-contract-address> '{"send_nft": {"contract": "<marketplace-contract-address>","token_id": "1","msg": "eyJzdGFydF9zYWxlIjp7InByaWNlIjogIjEwMDAwIiwiY29pbl9kZW5vbSI6InVhbmRyIn19"}}'

Buy the NFT

Now let us buy the NFT. First, I will try to buy it using the blacklisted address to make sure that our address-list module is working as intended. On the CLI:
guides is my wallet name for the blacklisted address.
wallets use guides
{
"buy":{
"token_id":"1",
"token_address":"<cw721-contract-address>"
}
}
Make sure to attach funds to the message equal to the listed price of the NFT which is 1000uandr in our case.
wasm execute <marketplace-contract-address> '{"buy":{"token_id":"1","token_address":"<cw721-contract-address>"}}'
Using the blacklisted address we get the following error:
Query failed with (18): failed to execute message; message index: 0: Generic error: Querier contract error: codespace: wasm, code: 9: execute wasm contract failed: invalid request
Use the --help flag for help
Now I will switch to another wallet and try buying the NFT again:
Make sure to use a wallet other than the owner of the NFT as the owner cannot buy the NFT.
wallets use test2

Conclusion

We have seen in this example how we can sell NFTs using our marketplace ADO and how to use the Andromeda modules to extend the ADOs by adding an address list and royalties to the marketplace. This is just one of many use cases that are possible using our ADOs and modules.