Setup Your Own Project

In this guide, we will show you how to setup the Story Protocol smart contract development environment in just a few minutes

Prerequisites

Creating a Project

  1. Run the following in a new directory of your choice: yarn init
  2. Set up foundry using the following command: forge init --force
  3. Once done, do some cleaning up on the dependency management side. Remove those conflicting with forge by running the following: rm -rf lib/ .github/
  4. Remove the placeholder test contracts: rm src/Counter.sol test/Counter.t.sol

Installing Dependencies

Now, we are ready to start installing our dependencies. To incorporate the Story Protocol core and periphery modules, run the following to have them added to your package.json. We will also install openzeppelin and erc6551 as a dependency for the contract and test.

# note: you can run them one-by-one, or all at once
yarn add @story-protocol/protocol-core@https://github.com/storyprotocol/protocol-core-v1#v1.0.0
yarn add @story-protocol/protocol-periphery@https://github.com/storyprotocol/protocol-periphery-v1#main
yarn add @openzeppelin/contracts
yarn add @openzeppelin/contracts-upgradeable
yarn add erc6551

Additionally, for working with Foundry's test kit, we also recommend adding the following devDependencies:

yarn add -D https://github.com/dapphub/ds-test
yarn add -D github:foundry-rs/forge-std#v1.7.6

Run yarn. Then, create a file in the root folder named remappings.txt and paste the following:

@openzeppelin/=node_modules/@openzeppelin/
@storyprotocol/core/=node_modules/@story-protocol/protocol-core/contracts/
@storyprotocol/periphery/=node_modules/@story-protocol/protocol-periphery/contracts/
erc6551/=node_modules/erc6551/
forge-std/=node_modules/forge-std/src/
ds-test/=node_modules/ds-test/src/

Now we are ready to build a simple test registration contract.