Guides

Smart Post End to End Guide

In this tutorial you will be create a Smart Post and integrate it into a front-end Lens application using the Smart Post CLI.

The codebase for this CLI is located here.

Prerequisites

To follow along, you will need to install Foundry. Installation steps below, or for more detailed instructions see the documentation https://book.getfoundry.sh/getting-started/installationhere.

# first install foundry
curl -L https://foundry.paradigm.xyz | bash

# once it's installed, run the following command
foundryup

Project setup

This app will contain two main codebases - a smart contract directory and a front end.

Scaffold the Smart Post project by running the following command:

npx create-smart-post

Deploy the contracts

  1. Switch to contracts directory (cd contracts) and setup environment variables: copy .env.example to .env, input deployment values in .env, and run source .env (or equivalent on your OS)
  2. Run script to deploy HelloWorld.sol and HelloWorldOpenAction.sol to Mumbai: forge script script/HelloWorld.s.sol:HelloWorldScript --rpc-url $MUMBAI_RPC_URL --broadcast --verify -vvvv

Run the Frontend

To run locally, switch to frontend directory and install the dependencies using npm, yarn, or bun.

Configure smart contract address in frontend/src/constants.ts

The frontend/src/layout components Create, Act, and Events contain code to create a post with this action, execute this action on a post, and display HelloWorld.sol events respectively.