--via-ir
flag. The relevant methods for other tools may vary.forge init
:
Oracle.sol
IConnectOracle
interface, which will be used to interact with the ConnectOracle contract.
${REST_URL}/minievm/evm/v1/connect_oracle
where ${REST_URL}
refers to the REST endpoint URL of the rollup.oracle_get_price
: This function will return the price of a single asset pairoracle_get_prices
: This function will return the price of multiple asset pairsforge compile
will fail unless we provide a test file that matches the Oracle.sol
contract. Foundry expects a test file like Oracle.t.sol
to exist and import the contract under test. To resolve this, we will rename the existing test file Counter.t.sol
to Oracle.t.sol
.
forge compile
should work without any errors.
forge script
command. First, we need to create a script file to handle the deployment. Create a new file named Oracle.s.sol
in the script
directory.
PRIVATE_KEY
with the deployer’s private key, and JSON_RPC_URL
with your rollup’s JSON-RPC endpoint.
oracle_get_price()
function, use Foundry’s cast call command.
Field | ABI-Encoded Value | Decoded Value |
---|---|---|
Price | 0x2c3cd0d43 | 11874929987 |
Timestamp | 0x1856610b4b695788 | 1753695806045116296 |