Shipyard is a Forge template for smart contract development. See the tutorial for detailed instructions on using Shipyard or jump down to the usage section below for more info on how it works.
Shipyard comes with some batteries included
solc
remappings so you can jump into writing your own contracts right awayforge fmt
configured as the default formatter for VSCode projectsforge fmt --check
and forge test
on every push and PR
!fix
on the PRfoundry.toml
solc
compiler version for reproducible buildssolc
metadata for simpler Etherscan verification and deterministic cross-chain deploys via CREATE2.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.
To deploy an NFT contract to the Goerli testnet, fund an address with 0.1 Goerli ETH, open a terminal window, and run the following commands:
Create a directory and cd
into it:
mkdir my-shipyard-based-project &&
cd my-shipyard-based-project
Install the foundryup
up command and run it, which in turn installs forge, cast, anvil, and chisel:
curl -L https://foundry.paradigm.xyz | bash
Follow the onscreen instructions output by the previous command to make Foundryup available in your CLI (or else restart your CLI).
Install forge, cast, anvil, and chisel by running:
foundryup
Create a new Foundry project based on Shipyard, which also initializes a new git repository, in the working directory.
forge init --template projectopensea/shipyard
Install dependencies and compile the contracts:
forge build
Set up your environment variables (make sure to swap in the appropriate value for <your_pk>
):
export GOERLI_RPC_URL='https://eth-goerli.g.alchemy.com/v2/demo' &&
export MY_ACTUAL_PK_BE_CAREFUL='<your_pk>'
Run the script that deploys the example contract and mints an NFT:
forge script script/DeployAndMint.s.sol --private-key \
$MY_ACTUAL_PK_BE_CAREFUL --fork-url $GOERLI_RPC_URL --broadcast
Verify the contract on Etherscan:
forge verify-contract <the_target_contract> Dockmaster --watch \
--constructor-args $(cast abi-encode "constructor(string,string,address)" \
"Dockmaster NFT" "DM" "0x0000000000000000000000000000000000000000") --chain 5
Running this command merely deploys the unchanged example NFT contract to a testnet, but it's a good way to check for a properly functioning dev environment.
See the tutorial for more detail on modifying the example contract, writing tests, deploying, and more.
When working across branches with different dependencies, submodules may need to be reinitialized. Run
./reinit-submodules
If you plan on generating coverage reports, you'll need to install lcov
as well.
On macOS, you can do this with the following command:
brew install lcov
To generate reports, run
./coverage-report
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。