You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**_NOTE:_** The `simulateScript` function is a debugging tool and hence is not a perfect representation of the actual Chainlink oracle execution environment. Therefore, it is important to make a Functions request on a supported testnet blockchain before mainnet usage.
589
589
590
590
### Local Functions Testnet
591
+
> **Note**
592
+
> Anvil is required to use `localFunctionsTestnet`. Please refer to the [foundry book](https://book.getfoundry.sh) for Anvil [installation instructions](https://book.getfoundry.sh/getting-started/installation).
591
593
592
594
For debugging smart contracts and the end-to-end request flow on your local machine, you can use the `localFunctionsTestnet` function. This creates a local testnet RPC node with a mock Chainlink Functions contracts. You can then deploy your own Functions consumer contract to this local network, create and manage subscriptions, and send requests. Request processing will simulate the behavior of an actual DON where the request is executed 4 times and the discrete median response is transmitted back to the consumer contract. (Note that Chainlink Functions uses the following calculation to select the discrete median response: `const medianResponse = responses[responses.length - 1) / 2]`).
593
595
@@ -596,11 +598,12 @@ The `localFunctionsTestnet` function takes the following values as arguments.
simulationConfigPath?: string // Absolute path to config file which exports simulation config parameters
599
-
options?: ServerOptions, // Ganache server options
600
-
port?: number, // Defaults to 8545
601
+
options?: ServerOptions, // Anvil server options (See: https://www.npmjs.com/package/@viem/anvil#api and https://book.getfoundry.sh/reference/anvil/)
601
602
)
602
603
```
603
604
605
+
`ServerOptions` is optional, and ships with a default `port` of 8545 and the default `test test test...junk` BIP39 mnemonic.
606
+
604
607
Observe that `localFunctionsTestnet` takes in a `simulationConfigPath` string as an optional argument. The primary reason for this is because the local testnet does not have the ability to access or decrypt encrypted secrets provided within request transactions. Instead, you can export an object named `secrets` from a TypeScript or JavaScript file and provide the absolute path to that file as the `simulationConfigPath` argument. When the JavaScript code is executed during the request, secrets specified in that file will be made accessible within the JavaScript code regardless of the `secretsLocation` or `encryptedSecretsReference` values sent in the request transaction. This config file can also contain other simulation config parameters. An example of this config file is shown below.
605
608
606
609
```
@@ -619,7 +622,7 @@ export const maxQueryResponseBytes = 2097152 // Maximum size of incoming HTTP re
getFunds: (address: string, { weiAmount, juelsAmount }: { weiAmount?: BigInt | string; juelsAmount?: BigInt | string }) => Promise<void> // Method which can be called to send funds to any address
625
628
close: () => Promise<void> // Method to close the server
0 commit comments