Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
cleanup and softening intro
Browse files Browse the repository at this point in the history
  • Loading branch information
djviau committed Sep 22, 2023
1 parent e26cb0b commit 78ea690
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

[Shipyard](https://github.com/ProjectOpenSea/shipyard) is a Forge template for smart contract development.

This repository is a basic example of how to use shipyard, along with [an accompanying tutorial](shipyardDocs/exampleNFTTutorial/Overview.md) for getting set up.
This repository is a basic example of how one might use Shipyard, along with [an accompanying tutorial](exampleNFTTutorial/Overview.md) for getting set up.

The idea is to clone this repo, play around with it a bit, take a pass through the tutorial, and discard it for a clean start with [Shipyard](https://github.com/ProjectOpenSea/shipyard). In other words, start with `git clone [email protected]:ProjectOpenSea/shipyard-example-project.git`, but once familiar with the patterns, be ready to `forge init --template projectopensea/shipyard` from scratch. More detail on that later.

## Installation

Shipyard requires Foundry. You can find specific install instructions [here](https://book.getfoundry.sh/getting-started/installation#using-foundryup).
Both Shipyard and this tutorial require Foundry. You can find specific install instructions [here](https://book.getfoundry.sh/getting-started/installation#using-foundryup).

But most likely, you can install Foundry with the following commands:

Expand All @@ -27,26 +28,18 @@ brew install lcov
```

## Overview
Shipyard comes with some batteries included

- [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts), [Solady](https://github.com/Vectorized/solady), and Shipyard-core smart contracts as dependencies, ready with [`solc` remappings](https://docs.soliditylang.org/en/latest/path-resolution.html#import-remapping) so you can jump into writing your own contracts right away
- `forge fmt` configured as the default formatter for VSCode projects
- Github Actions workflows that run `forge fmt --check` and `forge test` on every push and PR
- A separate action to automatically fix formatting issues on PRs by commenting `!fix` on the PR
- A pre-configured, but still minimal `foundry.toml`
- high optimizer settings by default for gas-efficient smart contracts
- an explicit `solc` compiler version for reproducible builds
- no extra injected `solc` metadata for simpler Etherscan verification and [deterministic cross-chain deploys via CREATE2](https://0xfoobar.substack.com/p/vanity-addresses).
- a separate build profile for CI with increased fuzz runs for quicker local iteration, while still ensuring your contracts are well-tested
### Shipyard proper
Shipyard can be used as a starting point or a toolkit in a wide variety of circumstances. In general, if you're building something NFT related, you're likely to find something useful here. For more info on [Shipyard](https://github.com/ProjectOpenSea/shipyard), check out its repository.

## Usage
### Shipyard tutorial
The tutorial covers the process of deploying an NFT contract, ranging from [ERC721 concepts](exampleNFTTutorial/ERC721Concepts.md), [setting up a dev environment](exampleNFTTutorial/EnvironmentSetup.md), [running tests](exampleNFTTutorial/Testing.md), [customizing the behavior of an NFT contract](exampleNFTTutorial/CustomNFTFunctionality.md), to [deploying](exampleNFTTutorial/Deploying.md).

Shipyard can be used as a starting point or a toolkit in a wide variety of circumstances. In general, if you're building something NFT related, you're likely to find something useful here. For the sake of exploring some of what Shipyard has to offer in concrete terms, here's a guide on how to deploy an NFT contract.
### Quick Deploy Guide
The table of contents and a brief intro can be found [here](exampleNFTTutorial/Overview.md).

To deploy an NFT contract to the Goerli testnet, fund an address with 0.25 Goerli ETH, swap in the appropriate values for `<your_key>` and `<your_pk>` in this command, open a terminal window, and run the following:
## Quick Deploy Guide

TODO: update this to do the template thing. And add a bit about staying up to date with the latest.
To deploy an NFT contract to the Goerli testnet, fund an address with 0.25 Goerli ETH, swap in the appropriate value `<your_pk>` in this command, open a terminal window, and run the following:

```
mkdir my-shipyard-based-project &&
Expand Down Expand Up @@ -119,7 +112,6 @@ Run
```

### Useful Aliases

```
alias gm="foundryup"
alias ff="forge fmt"
Expand Down
2 changes: 0 additions & 2 deletions exampleNFTTutorial/ERC721Concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Feel free to skip this section if you've already read about ERC-721 or perused t

There's nothing like going straight to the source: [https://eips.ethereum.org/EIPS/eip-721#specification](https://eips.ethereum.org/EIPS/eip-721#specification). The ERC-721 spec outlines the bare minimum interface and behavior that a contract needs to implement in order to be recognized and treated as an ERC-721 contract by the rest of the web 3 ecosystem (such as OpenSea, block explorers, etc.). There are only a half dozen operative "MUST"s in there, so we've got a lot of leeway. Eventually, we're going to deploy a snazzy, gas-optimized ERC721 with some bonus features. But for now, let's take a look at the stock version, [OpenZeppelin's example ERC721](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol)

TODO (blocked): update with links within the repo throughout.

OpenZeppelin's contracts show a straightforward, battle-tested, minimal implementation of the ERC-721 spec. For example, the ERC-721 spec states that `safeTransferFrom` "Throws if `_from` is not the current owner." And we can see that the required functionality is implemented on [lines 148-150](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L148-L150) of OpenZeppelin's ERC721:

```
Expand Down
2 changes: 1 addition & 1 deletion exampleNFTTutorial/EnvironmentSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ But hold out, it's not time yet! Or go ahead, we're not the deploy police. But y

Anyway, let's take a look at the portion of the `sample.env` file that's pertinent to testing.

The `FOUNDRY_PROFILE='tutorial'` line selects the `tutorial` profile from shipyard's `foundry.toml` file, which will allow you to run shipyard-core's tests from the shipyard directory.
The `FOUNDRY_PROFILE='tutorial'` line selects the `tutorial` profile from Shipyard's `foundry.toml` file, which will allow you to run shipyard-core's tests from the Shipyard directory.

`FOUNDRY_VERBOSITY=3` is like running your tests with the `-vvv` flag all the time. It's usually the exact sweet spot. When tests pass, they're not going to spam you with stack traces, but when they fail, you'll likely have all the info you need to debug.

Expand Down
2 changes: 0 additions & 2 deletions test-ffi/Dockmaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { Base64 } from "solady/utils/Base64.sol";
import { Test } from "forge-std/Test.sol";
import { Dockmaster } from "src/Dockmaster.sol";

import "forge-std/console.sol";

struct Attribute {
string attrType;
string value;
Expand Down

0 comments on commit 78ea690

Please sign in to comment.