benduran 82f140a97e Merge remote-tracking branch 'origin/main' into bduran/dual-publish 2 недель назад
..
lib f68b5d5abc feat(lazer/contracts/evm): add deterministic deployment script (#2137) 1 год назад
script 668539d8bd chore(lazer) lazer contracts add tri-state 3 недель назад
src a8ef1444d2 chore(lazer/evm) exponent parsing fix 2 недель назад
test 7f5033ca7a chore(lazer) Evm contract upgrades 3 недель назад
.gitignore ab0cf6f7d8 chore: updated gitignore to excluse the built dist/ folder 3 недель назад
README.md 07835ec8ae chore: remove deprecated BlastAPI endpoints (#3025) 2 месяцев назад
foundry.lock b66668ae8c feat(contracts) Deploy a new lazer contract (#3043) 2 месяцев назад
foundry.toml 0bef7c90d7 chore(lazer/contracts/evm): add solc version to foundry.toml 5 месяцев назад
remappings.txt 6ab44570b2 feat: add lazer contracts and sdks (#2119) 1 год назад

README.md

Pyth Lazer EVM Contract and SDK

This package is built using Foundry.

PythLazer is an EVM on-chain contract that keeps track of trusted signers of Pyth Lazer payloads. It allows consumers to easily check validity of Pyth Lazer signatures while enabling key rotation.

PythLazerReceiver contains utilities required to validate and parse Pyth Lazer payloads. Contracts should use PythLazerReceiver as the base contract (or one of the base contracts) of their contracts to gain access to the provided functions.

Build

forge build

Test

forge test

Format

forge fmt

Gas Snapshots

forge snapshot

Anvil

Anvil does not come with CreateX by default. It can be deployed or an RPC which has the contract can be forked. The below command forks an RPC with a functional CreateX contract.

anvil --fork-url "https://sepolia.drpc.org"

Deploy

Run the following commands to deploy the PythLazer contract to the target network. For the verification to work, you need to provide an API key (which is etherscan most of the times). If you can't make it work, you can always deploy the contract without verification and verify it manually later (using the standard input json format).

export ETHERSCAN_API_KEY=<your_etherscan_api_key>
forge script script/PythLazerDeploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast --verify

Then, run the following command to add the trusted signer to the PythLazer contract. The trusted signer is the address of the Pyth Lazer payload signer, and the expiration timestamp is the time when the signer will no longer be trusted.

cast send --rpc-url <your_rpc_url> --private-key <your_private_key> 0xACeA761c27A909d4D3895128EBe6370FDE2dF481 "updateTrustedSigner(address,uint256)" \
    "<trusted_signer_address>" "<trusted_signer_expiration_timestamp>"

Upgrade

The UUPSUpgradeable feature adds functions to the cocntract which support upgrading through the use of an UUPS/ERC1967Proxy. A function can be defined to migrate state if needed. Be careful of changing storage slots when upgrading. See Documentation for more details. In addition, the private key is necessary or contracts will be deployed to different addresses than expected.

forge script script/PythLazerDeploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast --sig "migrate()"

Cast

cast <subcommand>

Help

forge --help
anvil --help
cast --help