DEV Community

Cover image for Interacting with the Hatch Action
Ivan Montiel
Ivan Montiel

Posted on • Updated on

Interacting with the Hatch Action

Introduction

We’ve implemented our new contract functionality for hatching a BabyChick NFT from a ChickEgg NFT. Now we’ll deploy our contract to the testnet and interact with it to hatch our own NFT on the testnet.

Deploying Our Contract

We can deploy our now updated contract to the testnet. As before, even through we are deploying an updated contract to our account, any tables and data that existed before will not be destroyed in this process.

Let’s unlock our wallet:

cd /wax
cleos wallet open -n testwallet
cleos wallet unlock -n testwallet --password="$(cat ./secrets)"
Enter fullscreen mode Exit fullscreen mode

No we will deploy our contract:

cleos -v -u https://testnet.wax.pink.gg set contract waxcourse123 ./babychicks/build/babychicks -p waxcourse123@active
Enter fullscreen mode Exit fullscreen mode

This command may give you an error if you do not have enough RAM purchased for your account to use:

Reading WASM from /wax/babychicks/build/babychicks/guestbook.wasm...
Publishing contract...
Error 3080001: Account using more than allotted RAM usage
Error Details:
account waxcourse123 has insufficient ram; needs 81572 bytes has 9592 bytes
Stack Trace:
resource_limits.cpp:235 verify_account_ram_usage
Enter fullscreen mode Exit fullscreen mode

In this case, we need to buy RAM for our account. This is a useful command to have bookmarked:

# Remember to change waxcourse123 to your account name
cleos -v -u https://testnet.wax.pink.gg \
  system buyram waxcourse123 waxcourse123 "500" --kbytes \
  -p waxcourse123@active
Enter fullscreen mode Exit fullscreen mode

If everything succeeded, you will see similar output to the following:

Successful result

In the next section, we’ll send the contract a ChickEgg NFT to test it.

Hatching an Egg

We’ll use AtomicHub for the Wax Testnet to test out our new contract functionality.

Here, we’ve minted and transferred a BabyChick to the account darkemblemts. You’ll want to create a separate account using https://waxsweden.org/create-testnet-account/ to test non-admin functionality and ensure your Smart Contract code works correctly in the context of non-admin users.

BabyChick NFT on AtomicHub

Scroll down a bit and you will see a section that says “Transfer”:

Transfer

Fill in the details for the transfer: To waxcourse123 and Memo hatch:

hatch memo

Once you confirm through Anchor, you will see this message:

AtomicHub Success

Once the wax-orng send a random value back to the contract, it will mint a BabyChick:

Hatched BabyChick

Conclusion

We’ve successfully implemented, deployed, and tested our NFT Smart Contract that lets users hatch their NFTs! The Smart Contract we’ve implemented in these last set of tutorials provides quite a bit of interactive functionality that you can build on to give your NFT collection its own unique properties to make it stand out.

Next post: Deploying WAX Smart Contracts to Production

E-book

Get this entire WAX tutorial as an e-book on Amazon.

Additional links

Top comments (0)