Get a mapping of promise of all readable values of a contract in a specific chain.
type Chain = "eth" | "bsc" | "polygon"
getContract(chain: Chain, address: string): Promise<Record<string, Promise<() => unknown>>>
async function process({ dataSource }) {
const UNISWAP_ETH_USDC_LP = "0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640";
const contract = await dataSource.get("contract").getContract("eth", UNISWAP_ETH_USDC_LP);
/**
* {
* factory: Promise<string>;
* fee: Promise<BigNumber>;
* ...
* token0: Promise<string>;
* token1: Promise<string>;
* }
*/
})
getContract().
readFunction()
If the contract is verified in a block explorer, you can find all available contract reads on the contract on the platform.
type Chain = "eth" | "bsc" | "polygon"
getContract(chain: Chain, address: string): Promise<Record<string, Promise<() => unknown>>>
async function process({ dataSource }) {
const UNISWAP_ETH_USDC_LP = "0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640";
const contract = await dataSource.get("contract").getContract("eth", UNISWAP_ETH_USDC_LP);
const liquidity = await contract.liquidity();
// 37390839582564985275
const observation = await contract.observation(1);
/** {
* blockTimestamp: 1689656759
* tickCumulative: 13856267136263
* secondsPerLiquidityCumulativeX128: 151724863035695328813484017762
* initialized: true
* }
*/
})