Creates a new instance of LitOracleKit
The Lit Network to connect to (e.g., "datil-dev")
Private key used for signing transactions and minting PKPs
Generates Lit Action code and returns it along with its IPFS CID
Parameters for generating the Lit Action code
Object containing the generated code and its IPFS CID
Executes a Lit Action to fetch data and write it to a smart contract
Parameters specifying the data source, contract, and function to call
Response from the Lit Action execution
const result = await sdk.writeToChain({
dataSource: `
const url = "https://api.weather.gov/gridpoints/LWX/97,71/forecast";
const response = await fetch(url).then((res) => res.json());
const nearestForecast = response.properties.periods[0];
return [nearestForecast.temperature, nearestForecast.probabilityOfPrecipitation.value || 0];
`,
functionAbi: "function updateWeather(int256 temperature, uint8 precipitationProbability) external",
toAddress: "0xYourContractAddress",
chain: "yellowstone"
});
LitOracleKit provides functionality to create and manage oracles using Lit Protocol. It allows fetching off-chain data and writing it to blockchain smart contracts using Programmable Key Pairs (PKPs).