Quick Start

Getting started with a project

Good to know: Remember that the return object for get_value is a PriceTick.

Developing Locally

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

Python

For Python, we recommend using Starknet.py.

  • The current address of OracleProxy available on the Welcome Page

  • The name of the asset from the Assets page.

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)

Cairo

To use Stork in your contract, you'll need the following:

  1. The interface IOracleProxy file for the OracleProxy you'll be interacting with

  2. The current address of OracleProxy available on the Welcome Page

  3. The name of the asset from the Assets page.

%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

CLI

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. The name of the asset from the Assets page.

To use the StarkNet CLI follow this guide. To Install Nile, follow that guide.

// 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

Last updated