The ultimate no-code smart contract workflow

No-code tools have become a staple of early product validation. Yet, for anything beyond the templates offered, it becomes essential to have coding knowledge or advanced expertise of the tool. With the advent of AI bots as multi-purpose tools that can assist with a myriad of tasks, the future of no-code tools is uncertain – will they be overshadowed or enhanced by them?

State of no-code smart contracts

Conducting a search for no-code smart contracts yields a wealth of products that generate NFT collections, mint coins, or deploy DAOs (Decentralised Autonomous Organisations) without coding. While this is great for those lacking a technical background, those with programming expertise may find the lack of customisation options to be lacking. When the goal is to quickly build a proof of concept to test an hypothesis, it becomes clear that many no-code tools don’t offer enough options to make this possible.

ChatGPT+Remix=💥

Enter ChatGPT, a large language model that, having evolved from InstructGPT and Codex, is able to comprehend objectives and produce executable code snippets. For the majority of cases, the code generated requires minor corrections to execute properly.
The other tool relevant for our use case is Remix IDE:

The Remix Project is a rich toolset which can be used for the entire journey of contract development by users of any knowledge level, and as a learning lab for teaching and experimenting with Ethereum.
remix-project.org

In practical terms, Remix allows anyone to develop, test and deploy smart contracts right from the browser (using a Metamask wallet) without having to install anything.
By leveraging ChatGPT’s text-to-code capabilities and Remix’s testing and deployment features, developers gain access to a powerful toolset for rapid prototyping and validation.

A practical example

Let’s outline the steps from idea to deployment on the blockchain. The goal is to create a smart contract that distributes a specific token to different wallets every day. The quantity of the token received is based on the score associated with each wallet (those with higher scores will get more tokens).

Our experience with ChatGPT suggests that it is more effective to start with the most basic version of a solution and gradually inquire ChatGPT to include more features. It is as if we were executing a condensed product roadmap in a few hours.

For the first prompt, we ask ChatGPT to “Code a solidity smart contract that distributes ETH into a list of wallets every day”. The response is as follows: “Sure, here’s a sample Solidity smart contract that distributes ETH into a list of wallets every day”

pragma solidity ^0.8.0;

contract DailyDistribution {
    address payable[] public recipients;
    uint256 public dailyAmount;
    uint256 public lastDistributionTime;
    
    constructor(address payable[] memory _recipients, uint256 _dailyAmount) {
        recipients = _recipients;
        dailyAmount = _dailyAmount;
        lastDistributionTime = block.timestamp;
    }
    
    function distribute() public payable {
        require(msg.value == 0, "Cannot send ETH to this function");
        require(block.timestamp >= lastDistributionTime + 1 days, "Cannot distribute more than once a day");
        
        uint256 contractBalance = address(this).balance;
        uint256 distributionAmount = dailyAmount / recipients.length;
        
        for (uint256 i = 0; i < recipients.length; i++) {
            recipients[i].transfer(distributionAmount);
        }
        
        lastDistributionTime = block.timestamp;
    }
}

As further iterations, we may inquire these questions that progressively incorporate additional features:

  • Can you make the dailyAmount be 0.1% of the total balance in the contract?
  • Instead of ETH I would like to transfer the token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 (address of the token)
  • Can you update the distribute function so that instead of sending the same value to everyone, the value is based on the score each address has? The score is always at least 1, but does not have an upper limit.

In parallel with the evolution of the contract in ChatGPT we can start testing (and deploying) the contract on Remix.
Open https://remix.ethereum.org, create a new file in the contracts folder, paste the code from ChatGPT and hit save. Errors will appear at the bottom if there are any; they can be copied and pasted back into ChatGPT for automated fixing.

Once ready to deploy, go to the “Deploy” tab, click “Environment” dropdown and select “Injected Provider - Metamask”, and click the deploy button 🚀
Using a testnet can be advantageous during development as gas fees will be free (e.g.: ethereum sepolia, polygon mumbai, gnosis chiado).
For faster code debugging, Remix can be used to call contract methods directly while working on the dApp frontend development.

Word of Caution

Though most of the development of this smart contract with ChatGPT progressed without issue, that was not always so. When we requested a feature to make the transfer amount dynamic, the result produced by ChatGPT was incorrect due to an error in its calculations (an experienced eye can quickly scan the code and investigate any abnormalities).
We can query ChatGPT directly with: “Why are you dividing by the approvedRecipients.length in the distributionAmount calculation?”. ChatGPT will gladly explain why and provide an example of the output values of the calculations:

For example, suppose there are two approved recipients:
Recipient A with score 2 and Recipient B with score 1.
If the total amount to be distributed per day is 100 tokens,
then the calculation for `distributionAmount` would be as follows:
- Recipient A: `(100 * 2) / 3 / 2 = 33.33 tokens`
- Recipient B: `(100 * 1) / 3 / 2 = 16.67 tokens`

Examining the example, we replied to ChatGPT: “we want to distribute 100 per day, but in that example we only distributed 50”, to which ChatGPT apologised and amended the code.

We are excited about the potential of tools such as ChatGPT to further enhance our workflows and deliver greater value at a faster pace. As technology advances, Remix may even soon be able to directly integrate with ChatGPT. The efficiency benefits that this could bring are immense and we look forward to what the future holds. Streamlined processes will allow us to provide customers with the value they need on time, at a higher quality, and tailored to their individual needs; thus, leading to superior products and greater customer satisfaction.