Skip to content

Commit 7959104

Browse files
committed
Update to handle 127.0.0.1 instead of localhost.
1 parent adafbac commit 7959104

8 files changed

Lines changed: 1840 additions & 248 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ return Functions.encodeString(escape("$hello*world?"));
588588
**_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.
589589

590590
### 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).
591593
592594
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]`).
593595

@@ -596,11 +598,12 @@ The `localFunctionsTestnet` function takes the following values as arguments.
596598
```
597599
const localFunctionsTestnet = await startLocalFunctionsTestnet(
598600
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/)
601602
)
602603
```
603604

605+
`ServerOptions` is optional, and ships with a default `port` of 8545 and the default `test test test...junk` BIP39 mnemonic.
606+
604607
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.
605608

606609
```
@@ -619,7 +622,7 @@ export const maxQueryResponseBytes = 2097152 // Maximum size of incoming HTTP re
619622

620623
```
621624
{
622-
server: Server // Ganache server
625+
server: Server // Anvil server
623626
adminWallet: { address: string, privateKey: string } // Funded admin wallet
624627
getFunds: (address: string, { weiAmount, juelsAmount }: { weiAmount?: BigInt | string; juelsAmount?: BigInt | string }) => Promise<void> // Method which can be called to send funds to any address
625628
close: () => Promise<void> // Method to close the server
369 KB
Binary file not shown.

package-lock.json

Lines changed: 174 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
"@types/jest": "^29.5.1",
4343
"@types/node": "^18.16.3",
4444
"@types/prettier": "^2.7.3",
45-
"babel-loader": "9.1.2",
46-
"browserify": "17.0.0",
4745
"@typescript-eslint/eslint-plugin": "^6.7.5",
4846
"@typescript-eslint/parser": "^6.7.5",
47+
"babel-loader": "9.1.2",
48+
"browserify": "17.0.0",
4949
"cpy-cli": "^5.0.0",
50-
"esmify": "2.1.1",
5150
"eslint": "^8.51.0",
5251
"eslint-config-prettier": "^9.0.0",
5352
"eslint-plugin-prettier": "^5.0.1",
53+
"esmify": "2.1.1",
5454
"jest": "^29.5.0",
5555
"nock": "^13.3.1",
5656
"prettier": "^3.0.3",
@@ -72,6 +72,7 @@
7272
"proseWrap": "preserve"
7373
},
7474
"dependencies": {
75+
"@viem/anvil": "^0.0.7",
7576
"axios": "^1.4.0",
7677
"bcrypto": "^5.4.0",
7778
"cbor": "^9.0.1",

0 commit comments

Comments
 (0)