Quick Start
Getting started with a project
To test Stork for local development, you can mock out the price-returning part of Stork. We recommend calling the actual testnet contract to get a sample response, and then update the
let price_tick
line below with the appropriate data.# PriceTick.cairo
%lang starknet
struct PriceTick:
member asset : felt
member value : felt
member timestamp : felt
member publisher : felt
member type : felt
end
# OracleProxy.cairo
%lang starknet
func get_value(asset: felt) -> (price_tick: PriceTick):
# return MOCK_PRICE_TICK structure
let price_tick = PriceTick(...)
return price_tick
end
# IOracleProxy.cairo
%lang starknet
@contract_interface
namespace IOracleProxyStork:
func get_value(asset : felt) -> (price_tick : PriceTick):
end
end
For Python, we recommend using Starknet.py.
from starknet_py.contract import Contract
from starknet_py.net import Client
CONTRACT_ADDRESS = '${ORACLE_PROXY_ADDRESS}'
ASSET = 'ETH/USD' # starknet.py automatically encodes the string
contract = Contract.from_address_sync(CONTRACT_ADDRESS, Client("testnet"))
result = contract.functions["get_value"].call_sync(ASSET)
To use Stork in your contract, you'll need the following:
- 1.The interface
IOracleProxy
file for theOracleProxy
you'll be interacting with - 2.
- 3.
%lang starknet
from oracle.IOracleProxy import IOracleProxy
@view
func get_value_from_stork{syscall_ptr : felt*,range_check_ptr,}(
asset: felt):
let contract_address = ${ORACLE_PROXY_ADDRESS}
let price_tick = IOracleProxy.get_value(contract_address, asset)
# get value with: price_tick.value
To interact with Stork using the CLI, you'll need the following:
- 1.(for CLI only, not Nile) The ABI file for the OracleProxy you'll be interacting with, available on the Welcome Page.
- 2.
CLI
Nile
// If you do not have a wallet provided set up, use --no_wallet
export STARKNET_NETWORK=alpha-goerli
starknet call \
--address ${ORACLE_PROXY_ADDRESS} \
--abi contract_abi.json \
--function get_value
-- inputs 19514442401534788
export ORACLE_PROXY = 0x4c
nile call $ORACLE_PROXY get_value 19514442401534788 --network goerli
Last modified 1yr ago