/Foundry_Chainlink-Tutorial

This project shows you how to use Foundry to compile and deploy Smart contracts.

Primary LanguageSolidity

Labs

Chainstack is the leading suite of services connecting developers with Web3 infrastructure

         

HomepageSupported protocolsChainstack blogChainstack docsBlockchain API referenceStart for free

Using Chainlink data feeds with Foundry

This project shows how to use Foundry to compile and deploy Smart contracts.

See the full tutorial on the Chainstack blog:

Project details

Foundry is one of the latest smart contract development tools currently in the market, and it allows users to compile contracts, write tests, deploy contracts, and much more through its command line interface. This project is already set up for you to deploy smart contracts and interact with Chainlink’s data feeds.

Learn more about Foundry: Foundry: A fast Solidity smart contract development toolkit

Quick start

Clone this repository

git clone https://github.com/soos3d/Foundry_Chainlink-Tutorial.git

Install Foundry

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

Then:

foundryup

Compile smart contracts

forge build

Create a .env file

In the root directory:

touch .env

This will create a new .env file, paste and edit the following in it:

GOERLI_RPC_URL=CHAINSTACK_GOERLI_NODE_URL
PRIVATE_KEY=YOU_PRIVATE_KEY
ETHERSCAN_KEY=ETHERSCAN_API_KEY(to verify the smart contract)

Deploy the smart contract

Run the following command:

forge script script/priceFeedsScript.s.sol:ChainlinkScript --rpc-url $GOERLI_RPC_URL  --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv

Prerequisites

  • Linux or MacOS
  • A Goerli Chainstack endpoint

Deploy a Goerli node:

  1. Sign up with Chainstack.
  2. Deploy a node.
  3. View node access and credentials.

Dependencies

Install

Clone this repository

git clone https://github.com/soos3d/Foundry_Chainlink-Tutorial.git

Install Foundry

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

Then:

foundryup

Example

Here is a link to a verified smart contract deployed to the Goerli testnet, and then verified using Foundry's command line.