Interacting with the L1
Last updated
Last updated
The testnet EVM provides precompiles that allows querying native L1 information. The precompile addresses start at 0x0000000000000000000000000000000000000800 and have methods for querying perps positions, spot balances, vault equity, staking delegations, oracle prices, and the L1 block number.
The values are guaranteed to match the latest L1 state at the time the EVM block is constructed.
Attached is a solidity files describing the read precompiles as well as a python script that demonstrates calling a precompile.
To convert to floating point numbers, divide the returned price by 10^(6 - asset szDecimals) for the perp ones and 10^(8 - base asset szDecimals) for the spot ones.
A system contract is available at 0x3333333333333333333333333333333333333333 for sending transactions from the EVM to the L1. It supports sending IOC orders, vault transfers, staking, sending spot, and transfering between spot and perps. Solidity and ABI files for the write system contract are attached.
Happy building and let us know if you have any questions or feedback.