Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require("@nomiclabs/hardhat-ethers")
require("@chainlink/env-enc").config()
require("@nomicfoundation/hardhat-toolbox")

/**
* @type import('hardhat/config').HardhatUserConfig
Expand Down Expand Up @@ -36,6 +36,15 @@ module.exports = {
},
},
},
{
version: "0.7.0",
settings: {
optimizer: {
enabled: true,
runs: 1_000,
},
},
},
{
version: "0.6.6",
settings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ whatsnext:
}
---

import { Tabs } from "@components/Tabs"
import { Aside, CodeSample } from "@components"
import ChainlinkFunctions from "@features/chainlink-functions/common/ChainlinkFunctions.astro"

Expand Down Expand Up @@ -117,10 +118,23 @@ Get the required libraries from the [Chainlink Functions Starter Kit](https://gi

1. Run the `curl` command to download the latest tarball from the starter kit `main` branch and then run `tar -xf` with the `--strip` flag to extract only the files you need. The following command combines both steps:

```shell
curl -L -o ../functions.tar.gz https://api.github.com/repos/smartcontractkit/functions-hardhat-starter-kit/tarball/main &&
tar -xf ../functions.tar.gz --strip=1 -T <(echo -e "smartcontractkit-functions-hardhat-starter-kit-*/contracts/dev\nsmartcontractkit-functions-hardhat-starter-kit-*/contracts/test\nsmartcontractkit-functions-hardhat-starter-kit-*/FunctionsSandboxLibrary\nsmartcontractkit-functions-hardhat-starter-kit-*/contracts/FunctionsConsumer.sol")
```
{/* prettier-ignore */}
<Tabs client:visible>
<Fragment slot="tab.1">MacOS</Fragment>
<Fragment slot="tab.2">Linux</Fragment>
<Fragment slot="panel.1">
```shell MacOS
curl -L -o ../functions.tar.gz https://api.github.com/repos/smartcontractkit/functions-hardhat-starter-kit/tarball/main &&
tar -xf ../functions.tar.gz --strip=1 -T <(echo -e "smartcontractkit-functions-hardhat-starter-kit-*/contracts/dev\nsmartcontractkit-functions-hardhat-starter-kit-*/contracts/test\nsmartcontractkit-functions-hardhat-starter-kit-*/FunctionsSandboxLibrary\nsmartcontractkit-functions-hardhat-starter-kit-*/contracts/FunctionsConsumer.sol")
```
</Fragment>
<Fragment slot="panel.2">
```shell Linux
curl -L -o ../functions.tar.gz https://api.github.com/repos/smartcontractkit/functions-hardhat-starter-kit/tarball/main &&
tar -xf ../functions.tar.gz --strip=1 --wildcards smartcontractkit-functions-hardhat-starter-kit-*/contracts/dev smartcontractkit-functions-hardhat-starter-kit-*/contracts/test smartcontractkit-functions-hardhat-starter-kit-*/FunctionsSandboxLibrary smartcontractkit-functions-hardhat-starter-kit-*/contracts/FunctionsConsumer.sol
```
</Fragment>
</Tabs>

When you are done, you should have the necessary dependencies in the following directories:

Expand Down Expand Up @@ -246,7 +260,7 @@ Now that the consumer contract is deployed and the subscription is created and f

## Send requests

After your on-chain resources are configured, you can send Chainlink Functions requests to the DON. This can be done from a Web3 application, script, another on-chain smart contract, or any other location capable of submitting requests to your consumer contract. This example uses [Ethers v6](https://docs.ethers.org/v6/) without Hardhat to show you how to generate a request, encrypt secrets, send your request, and read the fulfillment response.
After your on-chain resources are configured, you can send Chainlink Functions requests to the DON. This can be done from a Web3 application, script, another on-chain smart contract, or any other location capable of submitting requests to your consumer contract. This example shows you how to generate a request, encrypt secrets, send your request, and read the fulfillment response.

Each request has the following components:

Expand All @@ -263,13 +277,13 @@ For this example, download some example source code and create a script to assem
1. Use `curl` to get the example source code. This code runs on each node in the DON and returns a response to your consumer contract. For this example, use the source from the [Call an API](/chainlink-functions/tutorials/api-query-parameters) tutorial. The following `curl` request creates a file named `Functions-request-source.js` with the source code:

```shell
curl -o Functions-request-source.js https://raw.githubusercontent.com/dwightjl/functions-examples/main/Functions-request-source.js
curl -o Functions-request-source.js https://raw.githubusercontent.com/smartcontractkit/smart-contract-examples/main/add-functions-to-project/Functions-request-source.js
```

1. Get the example script and put it in the `./scripts` directory:

```shell
curl -o ./scripts/request.js https://raw.githubusercontent.com/dwightjl/functions-examples/main/scripts/request.js
curl -o ./scripts/request.js https://raw.githubusercontent.com/smartcontractkit/smart-contract-examples/main/add-functions-to-project/scripts/request.js
```

1. Edit the script and set your deployed consumer address in `const consumerAddress`:
Expand Down Expand Up @@ -318,10 +332,10 @@ For this example, download some example source code and create a script to assem

1. Save and close the script.

1. Run the script to send the request to the DON. Because this script does not require Hardhat, you can use `node`.
1. Run the script to send the request to the DON.

```shell
node ./scripts/request.js
npx hardhat run scripts/request.js --network your_network
```

If the script runs successfully, the script reads your consumer contract and prints the stored value that the DON returned.
Expand Down