Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Functions examples to use Sepolia #58

Merged
merged 6 commits into from
Apr 12, 2024
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
2 changes: 1 addition & 1 deletion functions-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ To set up the project, follow these steps:
1. Set the following variables:

- PRIVATE_KEY
- POLYGON_MUMBAI_RPC_URL
- ETHEREUM_SEPOLIA_RPC_URL
18 changes: 9 additions & 9 deletions functions-examples/examples/1-simple-computation/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

// hardcoded for Polygon Mumbai
const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";

const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -38,7 +38,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -205,7 +205,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const readLatest = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x5abE77Ba2aE8918bfD96e2e382d5f213f10D39fA"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const updateRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const donId = "fun-polygon-mumbai-1";
const updateRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";
const gatewayUrls = [
"https://01.functions-gateway.testnet.chain.link/",
"https://02.functions-gateway.testnet.chain.link/"
];
const explorerUrl = "https://mumbai.polygonscan.com";

// Initialize functions settings
const source = fs
Expand All @@ -44,7 +45,7 @@ const updateRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -156,7 +157,7 @@ const updateRequestMumbai = async () => {
);
};

updateRequestMumbai().catch((e) => {
updateRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
17 changes: 8 additions & 9 deletions functions-examples/examples/11-package-imports/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x91257aa1c6b7f382759c357fbc53c565c80f7fee"; // REPLACE this with your Functions consumer address
const subscriptionId = 38; // REPLACE this with your subscription ID

// hardcoded for Polygon Mumbai
const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -38,7 +37,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -205,7 +204,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
18 changes: 9 additions & 9 deletions functions-examples/examples/12-abi-encoding/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x5fC6e53646CC53f0C3575fd2c71b5056c4823f5c"; // REPLACE this with your Functions consumer address
const subscriptionId = 139; // REPLACE this with your subscription ID

// hardcoded for Polygon Mumbai
const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
// hardcoded for Ethereum Sepolia
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -38,7 +38,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -218,7 +218,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 8 additions & 8 deletions functions-examples/examples/2-call-api/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -37,7 +37,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -204,7 +204,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 8 additions & 8 deletions functions-examples/examples/3-custom-response/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -37,7 +37,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -204,7 +204,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 8 additions & 8 deletions functions-examples/examples/4-post-data/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -37,7 +37,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -204,7 +204,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 8 additions & 8 deletions functions-examples/examples/5-use-secrets-threshold/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";
const gatewayUrls = [
"https://01.functions-gateway.testnet.chain.link/",
"https://02.functions-gateway.testnet.chain.link/",
];
const explorerUrl = "https://mumbai.polygonscan.com";

// Initialize functions settings
const source = fs
Expand All @@ -45,7 +45,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -244,7 +244,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 8 additions & 8 deletions functions-examples/examples/6-use-secrets-gist/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ require("@chainlink/env-enc").config();
const consumerAddress = "0x8dFf78B7EE3128D00E90611FBeD20A71397064D9"; // REPLACE this with your Functions consumer address
const subscriptionId = 3; // REPLACE this with your subscription ID

const makeRequestMumbai = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const linkTokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
const donId = "fun-polygon-mumbai-1";
const explorerUrl = "https://mumbai.polygonscan.com";
const makeRequestSepolia = async () => {
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const linkTokenAddress = "0x779877A7B0D9E8603169DdbD7836e478b4624789";
const donId = "fun-ethereum-sepolia-1";
const explorerUrl = "https://sepolia.etherscan.io";

// Initialize functions settings
const source = fs
Expand All @@ -41,7 +41,7 @@ const makeRequestMumbai = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down Expand Up @@ -240,7 +240,7 @@ const makeRequestMumbai = async () => {
})();
};

makeRequestMumbai().catch((e) => {
makeRequestSepolia().catch((e) => {
console.error(e);
process.exit(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ethers = require("ethers");
require("@chainlink/env-enc").config();

const generateOffchainSecretsFile = async () => {
// hardcoded for Polygon Mumbai
const routerAddress = "0x6E2dc0F9DB014aE19888F539E59285D2Ea04244C";
const donId = "fun-polygon-mumbai-1";
// hardcoded for Ethereum Sepolia
const routerAddress = "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0";
const donId = "fun-ethereum-sepolia-1";

const secrets = { apiKey: process.env.COINMARKETCAP_API_KEY };

Expand All @@ -18,7 +18,7 @@ const generateOffchainSecretsFile = async () => {
"private key not provided - check your environment variables"
);

const rpcUrl = process.env.POLYGON_MUMBAI_RPC_URL; // fetch mumbai RPC URL
const rpcUrl = process.env.ETHEREUM_SEPOLIA_RPC_URL; // fetch Sepolia RPC URL

if (!rpcUrl)
throw new Error(`rpcUrl not provided - check your environment variables`);
Expand Down
Loading