Skip to main content

SDK / Flask

The AugurV2 SDK was begun before good typescript wrappers existed. So while Augur Turbo uses TypeChain and Hardhat, AugurV2 uses custom wrappers. Below is an example of how to set up the SDK. For more information, see the flash scripts and especially the contract-api. The flash setup for contract-api is done here.

Flash Examples

SDK Usage Example

// Import the contract interfaces if you want typing.
import { ContractInterfaces } from '@augurproject/core';
import { ContractAPI } from '@augurproject/tools
import { computeAddress } from 'ethers/utils'

// Create the wrapper for making calls.
const privateKey = "0x123456789"; // your private key, starting with "0x"
const account = {
privateKey,
address: computeAddress(privateKey)
};
const network = 1; // ethereum mainnet
const config = buildConfig(network)
const provider = await providerFromConfig(config);
const connector = new Connectors.SingleThreadConnector();
const user = ContractAPI.userWrapper(
account,
provider,
config,
connector
);

// Create object with typing for Market.sol ABI.
const market: ContractInterfaces.Market = await user.getMarketContract(
marketId
);

// Call read-only methods, which start with an underscore.
await market._getEndTime();
await market._isFinalized();

// Call writing methods.
await market.finalize();