Support us on Product Hunt!
valid until March, 15 2021
PRODUCTHUNT
Features
Database and API-builderBack-end scenariosWeb-page builderBlockchain and web3Integrations
Why Directual
For developersFor product ownersFor freelancers and agenciesFor startups
Resources
PricingBlogMerchDocumentationDiscord group
Legal
Terms of servicePrivacy policyBrand assets

Execute operations with NFTs using no-code on Directual

← Back to other posts

Full-on web3 functionality is now at the tip of your fingers. Discover all about smart contracts, NFTs, and how to build complete blockchain projects yourself leveraging Directual no-code (sometimes – low-code) approach.

Lo and behold, the moment has come, and not a moment too soon. Now that you know how Directual can help you create dApps with no-code, let’s take a look at how Directual can now process smart contracts—using NFTs as an example. 

What are smart contracts?

Imagine smart contracts to be real-world paper contracts for a moment. Now think of said papers bearing legitimacy without any enforcing party. That’s smart contracts. 

Basically, it’s a program with a set of procedures that cannot be altered once deployed. Any instructions within the smart contract will be executed without any third party enforcing any of the clauses or room for disputes.

Speaking of Ethereum smart contracts, there is a couple of tokens with a notable difference: ERC-20 (Ethereum Request-for-Comments #20) and ERC-721 (Ethereum Request-for-Comments #721). ERC-20 is a fungible token (more on that below), which is a common token used for cryptocurrency as well. ERC-721, on the other hand, is non-fungible - an NFT, so it’s unique.

Smart contracts can be incredibly complex—entire programs can be written as one. They can be run continuously as the logic for an entire platform. For instance, the OasisDEX cryptocurrency exchange is just one big smart contract. You can trust that if you pay for something, you will get it. 

On top of that, they are a fundamental part of decentralized finance and NFTs.

Bored Ape Yacht Club (BAYC) managed to strike it big by minting NFTs, and guess how? Smart contracts and hype.

Speaking of which. 

What are NFTs?

NFT is a non-fungible token. What does “fungible” even mean? In short, fungibility means something you can replace with something equivalent without any problem. You drop a can of coke and it explodes – you get another one just like it and it costs the same. It’s fungible!

Not-fungible is something you cannot replace. There’s this wool hat your grandma made for you a long time ago. There’s no other hat like it, and there won’t be ever again. It carries memories of someone very important in your life. Sure you can buy a hat that may look similar, but it won’t be the same. 

But how does it work with digital media? 

Technically digital media is all infinitely fungible unless it’s a JPEG image that will age due to compression creep anyway. Hence the memes: just screenshot an NFT, and you’ve got the goods! It is pretty funny but fails to capture the real point behind NFTs.

This here is the first tweet ever. Sold as an NFT at a charity auction for $2.5 million. 

Ownership. That’s why blockchain is needed here: it helps to keep track of who owns what. You can have a limited edition of 200 e-books, and having them minted as NFTs will provide all the owners with true ownership of the originals. You can copy a digital item, but you can’t copy its value. Thus, the copy you own is special and unique. 

NFTs can be created by anyone, and it’s an incredibly interesting technology not just for arts, but soon for many other things. Your movie ticket can be an NFT, for instance.

Anyway, that’s enough education. Let’s get to buildin’.

Example: NFT gift airdrop for the first 10 subscribers!

In case you’d like to see the whole thing in action, we’ve prepared a handy video for you that goes over the process of creating an NFT gift airdrop for the first 10 subscribers.

If you prefer to read, go ahead:

Step-by-step instruction

We’ll need to create our own NFT collection to get started. This can easily be achieved with the help of various services, such as:

  • Rarible (the interface is lovely, own opinion)
  • Appypie (wouldn’t work for me personally somehow)
  • Autominter (simple but gets the job done)

Step 1: Generating the NFT collection

Let’s use Autominter for the sake of simplicity. Generate the NFTs and don’t forget to mint them to your own wallet. Then, press on the View on Etherscan button and select Token Tracker—we need to know the address of our NFT after all.

What we can see here is that the NFTs we’ve minted just now are all in our wallet. 

The tokenID ranges from 0 to 9 here, and the contract address is 0xf6cb5BDaD75356D65E57060EF56bB79aE2806c1F.

Step 2: Transferring the data into Directual

Now this data should be a part of your database in Directual. That’s how we will be able to automate the token distribution logic. To get started with this, we’ll create a table called nft_airdrop with fields contract_address, token_id, and is_owner.

…and fill it out!

Then, we can create a page with user authorization via MetaMask. To do this, let’s connect the MetaMask module:

And configure access for authorized users only at our home page:

Step 3: It’s raining NFTs!

Finally, we need to configure a scenario that will distribute NFTs upon user registration. To do so, we need to connect the NFT plugin. Then, we assemble this simple scenario that will trigger during any new events appearing in the AppUser table.

Now, all new users registering on our platform will be a part of this scenario and receive the goodies — until we run out of NFTs.

Here’s how the scenario works:

  1. Searches the nft_airdrop structure entries with condition is_owner == true (so we know whom to gift the stuff)
  2. Checks if all parameters are met
  3. Take the first element of the array to send out after the search is done
  4. Transfer NFT to WebUser user (duh), to their wallet ID
  5. Mark this NFT in nft_airdrop is_owner = false (the NFT is gifted, so we won’t be looking for it again)

And that really is it!

How Directual interacts with smart contracts

You may skip this part, if you don't want to deal with any coding :)

Directual was already a great choice for dApp developers, and now, you can call any blockchain function (on Ethereum or Polygon, for instance) by using the SDK module. 

Here is a short example of transferring a USDT token from one wallet to another. That’s basically a transfer function execution based on the ERC-20 standard:

Afterword

Our beloved community has been requesting smart contracts for a while, and we are so happy to finally deliver. Make the best out of Web3 functionality with your dApp! In case of questions, send us a message at hello@directual.com. Always happy to hear from fellow no-coders!

Nikita Navalikhin
November 21, 2022
← Back to other posts

Have questions? Visit our facebook group.

Give Directual a try

Directual is the only no-code development platform which combines flexibility and scalability of traditional coding with modern visual-development approach.