sbv2-solana/libraries/py
Conner Gallagher 39377b0c20 cleaned up package.json, tsconfig.json, and misc build configs
cleaned up tsconfig


wip


wip


Publish

 - @switchboard-xyz/switchboardv2-cli@0.1.22
 - @switchboard-xyz/eslint-config@0.1.0
 - @switchboard-xyz/sbv2-lite@0.1.2
 - @switchboard-xyz/sbv2-utils@0.0.14
 - @switchboard-xyz/switchboard-v2@0.0.98
 - @switchboard-xyz/v2-feed-parser@0.1.1
 - @switchboard-xyz/v2-feed-walkthrough@0.1.1
 - @switchboard-xyz/lease-observer@0.1.1
 - anchor-feed-parser@0.1.2
 - anchor-vrf-parser@0.1.2
 - spl-feed-parser@0.1.2
 - website@0.1.1

Publish


Publish

 - @switchboard-xyz/switchboardv2-cli@0.1.22
 - @switchboard-xyz/eslint-config@0.1.0
 - @switchboard-xyz/sbv2-lite@0.1.2
 - @switchboard-xyz/sbv2-utils@0.1.13
 - @switchboard-xyz/switchboard-v2@0.0.98
 - @switchboard-xyz/v2-feed-parser@0.1.1
 - @switchboard-xyz/v2-feed-walkthrough@0.1.1
 - @switchboard-xyz/lease-observer@0.1.1
 - anchor-feed-parser@0.1.1
 - anchor-vrf-parser@0.1.1
 - spl-feed-parser@0.1.1

Publish


ww
2022-05-25 12:38:29 -06:00
..
switchboardpy init 2022-05-17 10:42:04 -06:00
tests init 2022-05-17 10:42:04 -06:00
LICENSE cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00
README.md init 2022-05-17 10:42:04 -06:00
example.py init 2022-05-17 10:42:04 -06:00
poetry.lock init 2022-05-17 10:42:04 -06:00
pyproject.toml cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00

README.md

switchboardv2-py-api


SwitchboardPy is the Python client for Switchboard. It provides wrappers to help you to interact with the Switchboard V2 program on-chain.

Internally it uses AnchorPy, an Anchor API implementation in Python.

pypi   twitter  

Installation

pip install switchboardpy

Basic Usage

import asyncio
from solana.keypair import Keypair
from solana.publickey import PublicKey
from solana.rpc.async_api import AsyncClient
from anchorpy import Program, Provider, Wallet

from switchboardpy import AggregatorAccount, AccountParams

# Devnet Program ID.
SBV2_DEVNET_PID = PublicKey(
    '2TfB33aLaneQb5TNVwyDz3jSZXS6jdW2ARw1Dgf84XCG'
)

async def main():
    client = AsyncClient("https://api.devnet.solana.com/")
    provider = Provider(client, Wallet(Keypair()))
    program = await Program.at(
        SBV2_DEVNET_PID, provider
    )
    agg = AggregatorAccount(AccountParams(program=program, public_key=PublicKey("88FX4tBstuwBPNhQU4EEBoPX35neSu4Le9zDSwtPRRQz")))

    # getting aggregator data
    data = await agg.load_data()

    # getting most recent value (decimal.Decimal)
    val = await agg.get_latest_value()

    print('LATEST VALUE:')
    print(val)

    await program.close()

asyncio.run(main())

"""
OUTPUT
LATEST VALUE:
180.12115
"""