UMA Protocol
Search…
SDK
The UMA SDK can be used to interact with UMA's Optimistic Oracle using an eventful client designed for a frontend dApp with global state management. To begin, install the SDK using the command:
1
yarn add @uma/sdk
Copied!
Optimistic Oracle Client Usage
The below script is an example for getting request events from the Optimistic Oracle:
1
import { ethers } from 'ethers'
2
import uma from '@uma/sdk'
3
4
// assume you have a url injected from env
5
const provider = new ethers.providers.WebSocketProvider(process.env.CUSTOM_NODE_URL)
6
7
// get the contract instance
8
const contractAddress:string = "0xc43767f4592df265b4a9f1a398b97ff24f38c6a6" // update with optimistic oracle address you want to connect to
9
const client:uma.clients.optimisticOracle.Instance = uma.clients.optimisticOracle.connect(contractAddress, provider)
10
11
// gets all events using ethers query filter api
12
async function events() {
13
const events = await client.queryFilter({})
14
15
// returns EventState, defined in the optimistic oracle client
16
const state:uma.clients.optimisticOracle.EventState = uma.clients.optimisticOracle.getEventState(events)
17
18
// see all requests given even details
19
console.log(state.requests)
20
}
Copied!
For more information using the SDK, go to the sdk package. Other useful resources are the following projects that use the UMA SDK:
  • UMAverse: a user interface for UMA contracts and integrations.
  • Optimistic Oracle dApp: a user interface for interacting with the Optimistic Oracle through price requests, proposals, and disputes.
Copy link