Add Pragma as a dependency to your scarb/snforge project
Overview of the contract
hack_template.cairo
get_asset_price
, which takes as input the asset id of the asset we want to retrieve the price of, and returns the price of the asset. The asset id is a felt252, and can be converted from a string using the felt252
conversion. The asset id is used to identify the data feed we want to retrieve (for example BTC/USD).
Then comes the contract itself:
AggregationMode
enum is used to specify the aggregation mode of the data, the DataType
enum is used to specify the type of data to be retrieved, and the PragmaPricesResponse
structure is used to store the response to the function call.
Working with Remix
1
Activate the Starknet Plugin
To begin with, you will have to activate the Starknet plugin:

2
Compile the Code
Once the Starknet plugin is activated, the Starknet icon should appear on the left side of the screen. You will then need to compile the code:

3
4
Interact with the Contract
Once deployed, you can interact with the contract:
