### Start Frontend using npm Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Command to start the frontend development server. Assumes the project has been built and dependencies installed. Navigates to the app directory before running the start script. ```bash cd app/ npm run start ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/app/README.md Installs project dependencies using the Bun package manager. This is a crucial first step before running or developing the application. ```bash bun i ``` -------------------------------- ### Run Send-USD Client Application (NPM) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/starknet/send_usd/README.md Installs project dependencies using npm and starts the client application. This application likely interacts with the deployed Send-USD contract to fetch and display price feed data. ```bash cd ../client npm install npm run start ``` -------------------------------- ### Install Frontend Dependencies and Build (Shell) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Installs project dependencies for the frontend application and builds the application for production. These commands should be run from the `app/` directory. ```shell npm i npm run build ``` -------------------------------- ### Start Next.js Development Server Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/fuel/fetch-and-update-btc-price/README.md Starts the Next.js development server for the frontend application. Requires npm. ```bash npm run dev ``` -------------------------------- ### Run React App in Development Mode Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/solana/send_usd/app/README.md Starts the React development server, allowing you to view your application in the browser and see live updates on code changes. It also displays linting errors in the console. ```bash npm start ``` -------------------------------- ### Install Forge and OpenZeppelin Dependencies (Shell) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Installs Forge and OpenZeppelin contract dependencies for the AMM contract. Requires Foundry and Node.js to be installed. ```shell forge install foundry-rs/forge-std@v1.8.0 --no-git --no-commit forge install OpenZeppelin/openzeppelin-contracts@v4.8.1 --no-git --no-commit ``` -------------------------------- ### Run Development Server with Bun Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/app/README.md Starts the Next.js development server using Bun. This command allows developers to see the application running locally at http://localhost:3000. ```bash bun dev ``` -------------------------------- ### Install Dependencies with npm and Forge Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Installs required Solidity dependencies using npm and Forge package manager. Ensures the project has the necessary libraries for deployment and testing. ```bash npm install forge install foundry-rs/forge-std@v1.8.0 --no-git --no-commit ``` -------------------------------- ### Build React App for Production Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/solana/send_usd/app/README.md Creates an optimized production build of your React application in the 'build' folder. This process includes minification and hashing of filenames for improved performance. ```bash npm run build ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/solana-anchor/README.md Installs project dependencies using the pnpm package manager. This is a common step for Node.js-based projects. ```bash pnpm install ``` -------------------------------- ### Run Coin Flip Example (npm) Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/coin_flip/README.md Execute the coin flip demonstration script using npm. Requires installation of dependencies and provides arguments for private key, contract address, chain name, and RPC URL. ```bash npm i npm run flip-coin -- \ --private-key \ --address
\ --chain-name \ --rpc-url ``` -------------------------------- ### Copy Environment File Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/fuel/fetch-and-update-btc-price/README.md Copies the example environment file to a local file, typically used for local development setup. ```bash cp .env.example .env.local ``` -------------------------------- ### Install Pyth SDK for Solidity Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/pyth_sample/README.md Installs the Pyth SDK for Solidity via npm, enabling smart contracts to interact with Pyth Price Feeds and retrieve on-chain price data. ```bash npm init -y npm install @pythnetwork/pyth-sdk-solidity ``` -------------------------------- ### Run Solana Post Example Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/js/README.md Executes the TypeScript example that posts Pyth Lazer price data to a Solana smart contract. ```bash pnpm run start:post_solana ``` -------------------------------- ### Eject Create React App Configuration Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/solana/send_usd/app/README.md This command allows you to customize the underlying build tools (Webpack, Babel, ESLint) by copying their configuration files into your project. Note that this is a one-way operation. ```bash npm run eject ``` -------------------------------- ### Copy Environment Configuration Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Copies the example environment configuration file to a new file named .env for customization. ```bash cp .env.example .env ``` -------------------------------- ### Start Fuel Development Server Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/fuel/fetch-and-update-btc-price/README.md Starts a local Fuel node with hot-reloading for smart contract development. Requires npm. ```bash npm run fuels:dev ``` -------------------------------- ### Install Foundry Dependencies (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Command to install project dependencies using Foundry's package manager. This is a necessary step after cloning the repository or updating dependencies. ```bash forge install ``` -------------------------------- ### Run WebSocket Client Example Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/js/README.md Executes the TypeScript example that connects to the Pyth Lazer WebSocket stream to receive real-time price updates. ```bash pnpm run start ``` -------------------------------- ### Navigate to EVM Directory (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Command to change the current directory to the EVM-specific examples within the Pyth Lazer project. This is typically done before installing dependencies or running commands. ```bash cd lazer/evm ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Installs project dependencies using the Bun package manager. This is a prerequisite for compiling and deploying the smart contracts. ```sh bun install ``` -------------------------------- ### Build Project Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Builds the project using the blueprint CLI. This command compiles smart contracts and generates necessary wrappers. ```bash npx blueprint build ``` ```bash yarn blueprint build ``` -------------------------------- ### Install Forge Dependencies Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/pyth_sample/README.md Installs the forge-std library, a common dependency for Foundry projects, ensuring project compatibility and access to standard testing utilities. ```bash forge install foundry-rs/forge-std@v1.8.0 --no-git --no-commit ``` -------------------------------- ### Build Solana Anchor Program Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/solana-anchor/README.md Compiles the Solana program written using the Anchor framework. This command is essential before deploying or testing the program. ```bash anchor build ``` -------------------------------- ### Deploy Send-USD Contract to Starknet (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/starknet/send_usd/README.md Navigates to the Send-USD contract directory for Starknet and deploys the contract using its deployment script. The output, including the contract address, is saved to '~/send_usd.env'. ```bash cd pyth-examples/price_feeds/starknet/send_usd/contract deploy/deploy.sh > ~/send_usd.env ``` -------------------------------- ### Run Pyth Lazer Contract Tests (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Command to execute the test suite for the Pyth Lazer contract examples using Foundry. This command verbosely outputs test execution details. ```bash forge test -v ``` -------------------------------- ### Test Project Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Runs the contract test suite using the blueprint CLI. Ensures the smart contracts function as expected. ```bash npx blueprint test ``` ```bash yarn blueprint test ``` -------------------------------- ### Run Solana Anchor Tests Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/solana-anchor/README.md Executes the test suite for the Solana Anchor program. This helps ensure the program's functionality and correctness. ```bash pnpm test:anchor ``` -------------------------------- ### Deploy or Run Scripts Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Executes deployment scripts or other custom scripts defined within the project using the blueprint CLI. ```bash npx blueprint run ``` ```bash yarn blueprint run ``` -------------------------------- ### Initialize Pyth Lazer Contract (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Demonstrates the constructor for setting up a PythLazer contract instance within your smart contract. It requires the address of the deployed PythLazer contract. ```solidity PythLazer pythLazer; constructor(address pythLazerAddress) { pythLazer = PythLazer(pythLazerAddress); } ``` -------------------------------- ### Build Smart Contracts with Foundry (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Command to compile the Solidity smart contracts using Foundry. This step generates the necessary artifacts for deployment and testing. ```bash forge build ``` -------------------------------- ### Set Environment Variables for Deployment Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Configures essential environment variables for blockchain interaction. Includes private key, RPC URL for the target network, and the Pyth contract address. ```bash export PRIVATE_KEY=0x... export RPC_URL=https://sepolia.optimism.io/ export PYTH_ADDRESS=0x0708325268dF9F66270F1401206434524814508b ``` -------------------------------- ### Deploy Pyth Contract to Starknet (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/starknet/send_usd/README.md Clones the pyth-crosschain repository, navigates to the Starknet contracts directory, and deploys the Pyth contract to a local Katana instance. The deployment output is redirected to a file named 'pyth.env' which contains contract addresses. ```bash git clone https://github.com/pyth-network/pyth-crosschain.git cd pyth-crosschain/target_chains/starknet/contracts deploy/deploy.sh > ~/pyth.env ``` -------------------------------- ### Configure Client Environment Variables (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/starknet/send_usd/README.md Sets necessary environment variables for the client application, including the account's private key and address, which are required for authenticating and sending transactions on Starknet. ```bash export ACCOUNT_PRIVATE_KEY=0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a export ACCOUNT_ADDRESS=0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca ``` -------------------------------- ### Configure Lazer Access Token Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/js/README.md Sets the Lazer Access Token as an environment variable for authentication with the Pyth Lazer service. ```bash export ACCESS_TOKEN=your_actual_token ``` -------------------------------- ### Import Pyth Lazer Libraries (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Shows how to import necessary libraries for Pyth Lazer integration into a Solidity smart contract. These libraries provide core functionality for interacting with Pyth Lazer price feeds. ```solidity import {PythLazer} from "pyth-lazer/PythLazer.sol"; import {PythLazerLib} from "pyth-lazer/PythLazerLib.sol"; ``` -------------------------------- ### Deploy send_usd Contract Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Deploys the 'send_usd' contract to the TON testnet using the blueprint CLI. Requires API key and mnemonic phrase from the .env file. ```bash npx blueprint run deploySendUsd --custom https://testnet.toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type testnet --custom-key --mnemonic ``` -------------------------------- ### Set Environment Variables from File (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/starknet/send_usd/README.md Exports environment variables from a specified file. This is used to load contract addresses and other configuration details into the current shell session for subsequent commands. ```bash export $(xargs < ~/pyth.env) ``` -------------------------------- ### Retrieve ETH/SOL Price using ChainlinkApp Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Interacts with the deployed ChainlinkApp contract to retrieve the price of ETH/SOL. This demonstrates how to query Pyth price data through the integrated application. ```bash forge script script/GetEthSolPrice.s.sol --rpc-url $RPC_URL --broadcast ``` -------------------------------- ### Create New Contract Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Generates a new smart contract template within the project using the blueprint CLI. 'ContractName' should be replaced with the desired contract name. ```bash npx blueprint create ContractName ``` ```bash yarn blueprint create ContractName ``` -------------------------------- ### Deploy PythAggregatorV3 Contract Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Executes the Foundry deployment script for the PythAggregatorV3 contract. This contract acts as an adapter for Pyth price feeds, enabling their use in Chainlink-compatible applications. ```bash forge script script/PythAggregatorV3Deployment.s.sol --rpc-url $RPC_URL --broadcast --verify ``` -------------------------------- ### Generate Contract ABI (Shell) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Generates the ABI for the OracleSwap contract and saves it to a JSON file. This ABI is used by the frontend application to create transactions. ```shell forge inspect OracleSwap abi > ../app/src/abi/OracleSwapAbi.json ``` -------------------------------- ### Run AMM Contract Tests (Shell) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Executes all tests for the AMM smart contract. Tests are located in the `contract/test` directory and are run using the Forge testing framework. ```shell forge test ``` -------------------------------- ### Filter Updates by Feed ID (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Example of filtering Pyth Lazer price updates based on a specific feed ID and timestamp. This is crucial for ensuring that only relevant and recent price data is processed. ```solidity if (feedId == YOUR_FEED_ID && _timestamp > timestamp) { // Update logic } ``` -------------------------------- ### Deploy AMM Contract (Shell) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Deploys the AMM contract along with two ERC20 tokens and initializes the pool with Pyth price feeds. Transfers tokens to the pool for testing. Requires environment variables to be set. ```shell forge script scripts/OracleDeployment.s.sol --rpc-url $RPC_URL --broadcast ``` -------------------------------- ### Deploy ChainlinkApp Contract Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Deploys the ChainlinkApp contract, which integrates with Pyth price feeds. This contract can be used with Morpho vaults and other applications requiring Pyth data. ```bash forge script script/ChainlinkApp.s.sol --rpc-url $RPC_URL --broadcast --verify ``` -------------------------------- ### Minting Smart Contract Logic (Move) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/aptos/mint_nft/README.md Contains the core smart contract logic for managing an NFT minting process. It handles transactions where the mint is paid in native currency, with a fixed cost of 1$ per NFT. This code is intended for deployment on the Aptos testnet. ```Move module mint_nft::minting { // Contract logic for NFT minting goes here } ``` -------------------------------- ### Set Environment Variables for Deployment (Bash) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/oracle_swap/README.md Sets essential environment variables required for deploying the AMM contract. These include RPC URL, private key, Pyth contract address, and token details. ```bash export RPC_URL= export PRIVATE_KEY= export PYTH_ADDRESS= export TOKEN_NAME_1=MockWETH export TOKEN_SYMBOL_1=mWETH export TOKEN_NAME_2=MockSOL export TOKEN_SYMBOL_2=mSOL ``` -------------------------------- ### Verify ECDSA Signed Message on Solana Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/js/README.md Verifies an ECDSA-signed message on the Solana blockchain using the Pyth Lazer program. Requires a URL, keypair path, and hex-encoded message. ```bash pnpm run start:verify_ecdsa_message \ --url 'https://api.devnet.solana.com' \ --keypair-path './keypair.json' \ --message "e4bd474dda8934550d660e6ef4ee6ec1557349e283090c0107cad8bb997e67783a68be5646a5c949a8deaa6bee6ec1fc8aceb5002d6808b1da8ce5e9d26fd1b56ebeaf9d001c0075d3c793403ab1a9b03706000301010000000100eaf83297b5090000" ``` -------------------------------- ### Handle Verification Fees (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Illustrates how to check and ensure sufficient payment for Pyth Lazer price feed verification. It retrieves the required fee from the PythLazer contract and compares it with the sent value. ```solidity uint256 verification_fee = pythLazer.verification_fee(); require(msg.value >= verification_fee, "Insufficient fee"); ``` -------------------------------- ### Update On-Chain Pyth Price Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Executes the Foundry script to post a price update to the Pyth network on-chain. This action requires the `PRICE_UPDATE` environment variable to be set with the fetched price data. ```bash forge script script/UpdatePrice.s.sol --rpc-url $RPC_URL --broadcast ``` -------------------------------- ### Set ChainlinkApp Contract Address Environment Variable Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Stores the deployed ChainlinkApp contract address in an environment variable for subsequent interactions. This allows scripts and applications to reference the deployed instance. ```bash export CONTRACT_ADDR=0x7E1Bf7047200dB58A0eD8002552e1243B0DB4bfC ``` -------------------------------- ### Verify Ed25519 Signed Message on Solana Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/js/README.md Verifies an Ed25519-signed message on the Solana blockchain using the Pyth Lazer program. Requires a URL, keypair path, and hex-encoded message. ```bash pnpm run start:verify_ed25519_message \ --url 'https://api.testnet.solana.com' \ --keypair-path './keypair.json' \ --message "b9011a82f3c5c2760beb0c78827c75b0b18f1d4a2dcddf9d3efb291e66de25927538deffd74606de833eff236022aaca7b8a79cf15d3c7b51a91b500b2b9e6ca64bcfa03f65210bee4fcf5b1cee1e537fabcfd95010297653b94af04d454fc473e94834f1c0075d3c793c03c26adb03706000301010000000100aa749416b4090000" ``` -------------------------------- ### Frontend React App for NFT Minting (TypeScript) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/aptos/mint_nft/README.md The React application code for interacting with the NFT minting smart contract. It manages the frontend logic for user interactions, wallet connections, and blockchain transactions. Requires replacing a placeholder contract address with the deployed module's address. ```TypeScript import React, { useState } from 'react'; import { useAptos } from '@aptos-labs/wallet-adapter-react'; const MINT_NFT_MODULE = "0x19f8503273cdb5aa93ffe4539277684615242127aa2e65ef91424136a316c9c7"; // Replace with your deployed module address function App() { const { account, signAndSubmitTransaction } = useAptos(); const [minting, setMinting] = useState(false); const mintNFT = async () => { if (!account) return; setMinting(true); try { const payload = { function: `${MINT_NFT_MODULE}::minting::mint_nft`, type_arguments: [], arguments: [], }; await signAndSubmitTransaction(payload); alert('NFT minted successfully!'); } catch (error) { console.error('Minting failed:', error); alert('NFT minting failed.'); } finally { setMinting(false); } }; return (

1$ NFT Mint

{account ? ( ) : (

Connect your Petra wallet.

)}
); } export default App; ``` -------------------------------- ### Fetch and Prepare Pyth Price Update Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/chainlink_migration/README.md Retrieves the latest price update data for specified Pyth feed IDs from the Pyth Hermes API using `curl` and formats it for on-chain posting using `jq`. The fetched binary data is saved to `price_update.txt` and then exported as a hex string. ```bash curl 'https://hermes.pyth.network/v2/updates/price/latest?ids[]=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace&ids[]=0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d' | jq '.binary.data[0]' -r > price_update.txt export PRICE_UPDATE="0x`cat price_update.txt`" ``` -------------------------------- ### Coin Flip Solidity Contract Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/coin_flip/README.md The Solidity smart contract that implements the coin flip logic using Pyth Entropy. It handles receiving entropy, performing the flip, and returning the result. ```solidity // Contract code for CoinFlip.sol goes here. // See contract/src/CoinFlip.sol for implementation details. ``` -------------------------------- ### NFT Contract: Get Tokens by Owner Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Retrieves a list of all token IDs owned by a specific address within the NFT contract. This function is essential for querying NFT ownership. ```solidity function tokensOfOwner(address owner) external view returns (uint256[] memory) ``` -------------------------------- ### Verify and Parse Price Updates (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Code snippet for verifying a Pyth Lazer update and parsing the price data payload. It utilizes the `verifyUpdate` function and expects the `update` data to be passed along with the verification fee. ```solidity (bytes memory payload,) = pythLazer.verifyUpdate{value: verification_fee}(update); // Parse payload using PythLazerLib functions ``` -------------------------------- ### Send USD Payment Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Initiates a USD payment to a specified TON wallet address using the deployed contract. Requires the recipient's TON address, the USD amount, API key, and mnemonic phrase. ```bash npx blueprint run sendUsdPayment 1 --custom https://testnet.toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type testnet --custom-key --mnemonic ``` -------------------------------- ### Receive and Process Pyth Lazer Price Updates (Solidity) Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/evm/README.md Demonstrates receiving and processing Pyth Lazer price updates within a smart contract. It includes signature verification, payload parsing, fee handling, and extraction of price feed properties. The function `updatePrice` is the primary entry point for receiving updates. ```solidity function updatePrice(bytes calldata update) public payable ``` -------------------------------- ### NFTGrowth Contract: Get Growth Fee Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Returns the current fee required for initiating an NFT growth request. This fee likely covers the cost of accessing external entropy services. ```solidity function getGrowFee() external view returns (uint256) ``` -------------------------------- ### Coin Flip Solidity Contract Interaction (TypeScript) Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/coin_flip/README.md Demonstrates the TypeScript code for interacting with the Coin Flip Solidity contract. This script handles the logic for requesting and receiving coin flip results from the Pyth Entropy service. ```typescript // Example of interacting with the CoinFlip.sol contract. // See app/src/flip_coin.ts for full implementation. ``` -------------------------------- ### NFTGrowth Contract: Initiate NFT Growth Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Starts the growth process for a specific NFT using a provided random number from the user. This function is central to the NFT's state modification based on external entropy. ```solidity function grow(uint256 tokenId, bytes32 userRandomNumber) external ``` -------------------------------- ### Message Format for send_usd Operation Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/ton/send_usd/README.md Defines the structure of a message to send a USD-denominated payment on TON. Includes recipient address, USD amount, Pyth price update data, and attached TON value. ```typescript { queryId: number, // 64-bit unique identifier for the request recipient: Address, // TON address of payment recipient usdAmount: number, // Amount in USD dollars updateData: Buffer, // Pyth price update data (converted to cell chain) value: bigint // Amount of TON to attach to message } ``` -------------------------------- ### Deploy Contracts to Blast Sepolia Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Deploys the NFT Growth smart contracts to the Blast Sepolia test network using Hardhat Ignition. The --verify flag ensures contract verification on block explorers. ```sh bunx hardhat ignition deploy ignition/modules/App.ts --network blast-sepolia --verify ``` -------------------------------- ### Build Sui Project Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/sui/README.md Builds the Sui Move project using the Sui CLI. This command compiles all the Move modules and dependencies required for the project. ```bash sui move build ``` -------------------------------- ### NFTGrowth Contract: Mint New NFT Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Enables users to mint a new NFT. This function likely initializes the NFT with default properties and assigns ownership to the caller. ```solidity function mint() external ``` -------------------------------- ### Retrieve Latest Price Updates (Hermes API) Source: https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/evm/pyth_sample/README.md Fetches the latest price updates for specified Pyth Price Feed IDs using the Hermes API. Requires cURL and knowledge of the target price feed IDs. ```bash curl -X 'GET' \ 'https://hermes.pyth.network/v2/updates/price/latest?ids%5B%5D=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43&ids%5B%5D=0xc96458d393fe9deb7a7d63a0ac41e2898a67a7750dbd166673279e06c868df0a' ``` -------------------------------- ### Run All Sui Tests Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/sui/README.md Executes all tests defined within the Sui Move project. This is useful for ensuring the integrity and correctness of the smart contract logic. ```bash sui move test ``` -------------------------------- ### Pyth Entropy Callback Function Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md The callback function that the Pyth entropy system invokes to deliver the requested random number. This function processes the received randomness to update the NFT's state. ```solidity function entropyCallback(uint64 sequenceNumber, address provider, bytes32 randomNumber) external ``` -------------------------------- ### Run Specific Sui Test Source: https://github.com/pyth-network/pyth-examples/blob/main/lazer/sui/README.md Runs a specific test case within the Sui Move project. This is helpful for debugging or focusing on a particular piece of functionality, such as parsing and validating updates. ```bash sui move test test_parse_and_validate_update ``` -------------------------------- ### NFTGrowth Contract: Owner Forced Unlock Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Grants the contract owner the ability to unlock an NFT, irrespective of the standard lock status or cooldown period. This provides administrative control over NFT states. ```solidity function ownerUnlock(uint256 tokenId) external onlyOwner ``` -------------------------------- ### NFTGrowth Contract: Unlock NFT Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Allows a user to unlock an NFT, presumably after a lock period has expired or a growth process has completed. This function is crucial for managing sequential growth steps. ```solidity function unlock(uint256 tokenId) external ``` -------------------------------- ### NFT Contract: Withdraw Funds Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md Allows the contract owner to withdraw the contract's balance to a specified address. This function is typically used for managing collected fees or contract earnings. ```solidity function withdraw(address to) external onlyOwner ``` -------------------------------- ### NFTGrowth Contract: Internal Ownership Check Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md An internal modifier or function that verifies if the caller of a specific function is the owner of the NFT in question. This ensures that only authorized users can interact with their NFTs. ```solidity modifier requireOwnership(uint256 tokenId) ``` -------------------------------- ### NFTGrowth Contract: Internal Lock Check Source: https://github.com/pyth-network/pyth-examples/blob/main/entropy/growing/contract/README.md An internal modifier or function that enforces a lock on an NFT, preventing new growth requests until the current process is finished and the lock period has expired. This prevents race conditions and ensures orderly state updates. ```solidity modifier requireLock(uint256 tokenId) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.