generated from smartcontractkit/hardhat-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 103
/
Functions-request-config.js
23 lines (21 loc) · 1.21 KB
/
Functions-request-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require("fs")
const { Location, ReturnType, CodeLanguage } = require("@chainlink/functions-toolkit")
// Configure the request by setting the fields below
const requestConfig = {
// String containing the source code to be executed
source: fs.readFileSync("./calculation-example.js").toString(),
//source: fs.readFileSync("./API-request-example.js").toString(),
// Location of source code (only Inline is currently supported)
codeLocation: Location.Inline,
// Optional. Secrets can be accessed within the source code with `secrets.varName` (ie: secrets.apiKey). The secrets object can only contain string values.
secrets: { apiKey: process.env.COINMARKETCAP_API_KEY ?? "" },
// Optional if secrets are expected in the sourceLocation of secrets (only Remote or DONHosted is supported)
secretsLocation: Location.DONHosted,
// Args (string only array) can be accessed within the source code with `args[index]` (ie: args[0]).
args: ["1", "bitcoin", "btc-bitcoin", "btc", "1000000", "450"],
// Code language (only JavaScript is currently supported)
codeLanguage: CodeLanguage.JavaScript,
// Expected type of the returned value
expectedReturnType: ReturnType.uint256,
}
module.exports = requestConfig