• Stars
    star
    305
  • Rank 132,620 (Top 3 %)
  • Language
    Solidity
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 9 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Note: This repo has been recently updated for Sepolia

Foundry Starter Kit


Chainlink Foundry logo


Open in Gitpod

Foundry Starter Kit is a repo that shows developers how to quickly build, test, and deploy smart contracts with one of the fastest frameworks out there, foundry!

Getting Started

Requirements

Please install the following:

  • Git
    • You'll know you've done it right if you can run git --version
  • Foundry / Foundryup
    • This will install forge, cast, and anvil
    • You can test you've installed them right by running forge --version and get an output like: forge 0.2.0 (f016135 2022-07-04T00:15:02.930499Z)
    • To get the latest of each, just run foundryup

And you probably already have make installed... but if not try looking here.

Quickstart

git clone https://github.com/smartcontractkit/foundry-starter-kit
cd foundry-starter-kit
make # This installs the project's dependencies.
make test

Testing

make test

or

forge test

Deploying to a network

Deploying to a network uses the foundry scripting system, where you write your deploy scripts in solidity!

Setup

We'll demo using the Sepolia testnet. (Go here for testnet sepolia ETH.)

You'll need to add the following variables to a .env file:

  • SEPOLIA_RPC_URL: A URL to connect to the blockchain. You can get one for free from Infura account
  • PRIVATE_KEY: A private key from your wallet. You can get a private key from a new Metamask account
    • Additionally, if you want to deploy to a testnet, you'll need test ETH and/or LINK. You can get them from faucets.chain.link.
  • Optional ETHERSCAN_API_KEY: If you want to verify on etherscan

Deploying

make deploy-sepolia contract=<CONTRACT_NAME>

For example:

make deploy-sepolia contract=PriceFeedConsumer

This will run the forge script, the script it's running is:

@forge script script/${contract}.s.sol:Deploy${contract} --rpc-url ${SEPOLIA_RPC_URL}  --private-key ${PRIVATE_KEY} --broadcast --verify --etherscan-api-key ${ETHERSCAN_API_KEY}  -vvvv

If you don't have an ETHERSCAN_API_KEY, you can also just run:

@forge script script/${contract}.s.sol:Deploy${contract} --rpc-url ${SEPOLIA_RPC_URL}  --private-key ${PRIVATE_KEY} --broadcast 

These pull from the files in the script folder.

Working with a local network

Foundry comes with local network anvil baked in, and allows us to deploy to our local network for quick testing locally.

To start a local network run:

make anvil

This will spin up a local blockchain with a determined private key, so you can use the same private key each time.

Then, you can deploy to it with:

make deploy-anvil contract=<CONTRACT_NAME>

Similar to deploy-sepolia

Working with other chains

To add a chain, you'd just need to make a new entry in the Makefile, and replace <YOUR_CHAIN> with whatever your chain's information is.

deploy-<YOUR_CHAIN> :; @forge script script/${contract}.s.sol:Deploy${contract} --rpc-url ${<YOUR_CHAIN>_RPC_URL}  --private-key ${PRIVATE_KEY} --broadcast -vvvv

Security

This framework comes with slither parameters, a popular security framework from Trail of Bits. To use slither, you'll first need to install python and install slither.

Then, you can run:

make slither

And get your slither output.

Contributing

Contributions are always welcome! Open a PR or an issue!

Thank You!

Resources

TODO

[ ] Add bash scripts to interact with contracts using cast

[ ] Make deploying contracts to anvil simpler

More Repositories

1

full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
11,705
star
2

full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
10,629
star
3

chainlink

node of the decentralized oracle network, bridging on and off-chain computation
Go
6,693
star
4

hardhat-starter-kit

A repo for boilerplate code for testing, deploying, and shipping chainlink solidity code.
JavaScript
1,179
star
5

chainlink-mix

Working with smart contracts with eth-brownie, python, and Chainlink.
Solidity
484
star
6

defi-minimal

This repo is dedicated to making minimal repos of existing defi primatives.
JavaScript
459
star
7

documentation

https://docs.chain.link The Chainlink developer documentation website for Smart Contract Devs and Node Operators
MDX
360
star
8

external-adapters-js

Monorepo containing JavaScript implementation of external adapters
TypeScript
264
star
9

truffle-starter-kit

An example smart contract utilizing Chainlink
JavaScript
258
star
10

starter-kits

A repo of starter kits for working with various languages and frameworks across the smart contract ecosystem.
228
star
11

foundry-starter-kit-old

Solidity
207
star
12

chainlink-brownie-contracts

A repository for automatically using the latest chainlink repo from the core chainlink repo.
Solidity
168
star
13

solana-starter-kit

Example code for using Chainlink on Solana
JavaScript
166
star
14

chainlink-ruby

Easily connect your applications to blockchains
Ruby
157
star
15

smart-contract-examples

Example and sample projects
TypeScript
150
star
16

chainlink-polkadot

Go
141
star
17

functions-hardhat-starter-kit

JavaScript
138
star
18

LinkToken

LINK Token Contracts for the Chainlink Network
Solidity
131
star
19

ccip

Cross Chain Interoperability Protocol
Go
105
star
20

huff-starter-kit

A template repo to work with huff smart contracts and learn about low level EVM opcodes. Also Horse β™˜.
Solidity
100
star
21

apeworx-starter-kit

A repo dedicated to showing how to make smart contracts in a purely pythonic environment
Python
85
star
22

blockchain-developer-hub

Dive into blockchain and smart contract development.
JavaScript
79
star
23

chainlink-solana

Go
72
star
24

chainlink-fullstack

Full stack starter project showcasing Chainlink products on Ethereum (EVM)
TypeScript
68
star
25

hardhat-chainlink

Integrates Chainlink into Hardhat projects. This package is currently in the BETA testing phase and is not recommended for production usage yet.
TypeScript
64
star
26

solidity-cborutils

A library for encoding CBOR in Solidity.
Solidity
64
star
27

dapptools-starter-kit

Solidity
61
star
28

libocr

libocr consists of a Go library and a set of Solidity smart contracts that implement the Chainlink Offchain Reporting Protocol
Go
60
star
29

ccip-read

TypeScript
59
star
30

chainlink-testing-framework

A testing framework for smart contracts and Chainlink nodes
Go
56
star
31

ccip-starter-kit-foundry

This project demonstrates a couple of basic Chainlink CCIP use cases
Solidity
55
star
32

chainlink-starknet

Go
52
star
33

foundry-chainlink-toolkit

A plugin to use Chainlink products/services in Foundry
Solidity
51
star
34

ccip-cross-chain-nft

This project demonstrates how to mint an NFT on one blockchain from another blockchain using Chainlink CCIP
TypeScript
44
star
35

ccip-starter-kit-hardhat

This project demonstrates a couple of basic Chainlink CCIP use cases
TypeScript
42
star
36

smart-contract-db

This repository is an archive. This project has been superseded by blockchain.education https://github.com/smartcontractkit/blockchain-developer-hub
TypeScript
42
star
37

external-initiator

Initiate Chainlink job runs from external sources
Go
40
star
38

chainlink-solana-demo

Showing how to deploy a Solana program using Chainlink Price Feeds
TypeScript
37
star
39

prediction-game

Rugby prediction game using Chainlink Functions, Automation, and CCIP.
TypeScript
36
star
40

chainlink-automation-templates

Real-world sample projects using Chainlink Automation
Solidity
34
star
41

ccip-defi-lending

CCIP Launch Defi Demo
JavaScript
32
star
42

usechainlinkfunctions

TypeScript
28
star
43

near-protocol-contracts

Rust
26
star
44

functions-deepdive-constellation2023

Deepdive Workshop For Constellation 2023 Hackathon
JavaScript
24
star
45

chainlink-cosmos

Go
24
star
46

functions-toolkit

An NPM package with collection of tools that can be used for working with Chainlink Functions.
TypeScript
23
star
47

wasp

Protocol-agnostic load testing library for Go
Go
23
star
48

devnet

An Ethereum development network with preset configs for easy testing.
Makefile
22
star
49

run-functions-dapp

Demo dApp using Chainlink Functions to bring web2 data on-chain.
TypeScript
22
star
50

env-enc

TypeScript
22
star
51

chainlink-common

SDK for building Chainlink Services and Plugins
Go
20
star
52

chainlink-local

The Chainlink CCIP Local Simulator, visit documentation by clicking the link below:
Solidity
19
star
53

Blockchain-RPC-Exporter

Prometheus exporter for EVM compatible RPC endpoints.
Python
18
star
54

schemas

specification for offering and requesting off-blockchain services
17
star
55

paypal-adapter

TypeScript
17
star
56

chainlink-github-actions

Common action to run chainlink-testing-framework based tests in github ci
TypeScript
16
star
57

wei_watchers

A service for push notifications of Ethereum logs and account balances.
Ruby
15
star
58

arbitrum-quickstart

JavaScript
14
star
59

chainlink-env

Chainlink k8s environment library
Go
14
star
60

risk-management-network

Rust
14
star
61

solc-api

minimal Solidity compiler service
JavaScript
14
star
62

ccip-owner-contracts

A set of smart contracts used for administering Chainlink contracts, most notably CCIP
Solidity
13
star
63

chainlink-functions-demo-app

TypeScript
13
star
64

hello_chainlink

chainlink demos
JavaScript
12
star
65

chainlink-staking-v0.2-public-guide

12
star
66

operator-ui

TypeScript
12
star
67

functions-lens-eventbrite

Solidity
12
star
68

ccip-cross-chain-name-service

This project is an educational example of how to create a minimal cross-chain name service using Chainlink CCIP
TypeScript
12
star
69

chain-selectors

Go
12
star
70

tdh2

An implementation of the TDH2 protocol by Shoup & Gennaro (paper link https://www.shoup.net/papers/thresh1.pdf)
Go
11
star
71

chainlink-RSK

Solidity
11
star
72

wsrpc

A bi-directional Websockets RPC library
Go
11
star
73

quickstarts-historical-prices-api

TypeScript
11
star
74

functions-the-graph-uniswap

Solidity
11
star
75

chainlink-automation

Go
10
star
76

datastreams-demo

Demo dApp using Chainlink Data Streams.
TypeScript
10
star
77

ccip-tic-tac-toe

TypeScript
10
star
78

builder

A docker build file for chainlink
Dockerfile
10
star
79

chainlink-vrf

OCR2VRF (in development, do not use in production)
Go
10
star
80

chainlink-data-streams

Go
9
star
81

workshop-distributed-news

Solidity
9
star
82

hardhat-network

Deploys a basic hardhat chain for testing
Dockerfile
9
star
83

cairo-starter-kit

The boilerplate code for getting started with the usage of Chainlink services on Starknet
TypeScript
9
star
84

bq-example-contract

JavaScript
8
star
85

solana-prediction-game

JavaScript
8
star
86

chainlink-node-compose

Docker Compose script for launching multiple chainlink nodes
Shell
8
star
87

substrate-adapter

Go
7
star
88

link-token-sidechain-evm

LINK Token On EVM Sidechains
Solidity
7
star
89

DEVREL-collaborative-nft-tutorial

Solidity
7
star
90

blockchain-ecosystem-map

JavaScript
7
star
91

ccip-liquidation-protector

This project demonstrates how to automate preventing DeFi liquidations & optimizing interest rates on multiple blockchains using Chainlink CCIP, Chainlink Automation and Chainlink Functions
TypeScript
7
star
92

chainlink-solhint-rules

CLL custom Solhint rules
JavaScript
7
star
93

push-gha-metrics-action

Shell
6
star
94

functions-google-bigquery

Demonstration of accessing data from Google BigQuery via Chainlink Functions
JavaScript
6
star
95

ea-framework-js

TypeScript
6
star
96

chainlink-terra-feeds-demo

Showing how to deploy a Terra smart contract which utilizes Chainlink Data Feeds
Rust
6
star
97

datastreams-erc7412

Solidity
6
star
98

feed-registry-example

Example Hardhat project using the Chainlink Feed Registry
Solidity
6
star
99

pancake

JavaScript
6
star
100

havoc

Automatic chaos testing tool and CLI
Go
6
star