Write a Smart Contract

Learn how to write your first Aiken script, with a simple redeemer

Write your first smart contract in Aiken

In this section, we will walk you through the process of writing a simple smart contract in Aiken.

We will use the Visual Studio Code editor for this tutorial. You can use any other editor of your choice, but we recommend using Visual Studio Code for its rich feature set and support for Aiken.

First, we create a new Aiken project within this project folder:

Remember to check your Aiken project by running aiken check after creating a new project and as you develop the contract.

Write the smart contract

Let's create file for our validator, validators/hello_world.ak:

The validator checks for two conditions:

  • The redeemer message is Hello, World!
  • The transaction is signed by the owner

If both conditions are met, the validator returns true. Otherwise, it returns false.

Compile and build

Let's compile the smart contract with the Aiken CLI:

This command will compile the smart contract and generate theplutus.json file in the root folder. This file is a CIP-0057 Plutus blueprint, blueprint describes your on-chain contract and its binary interface.