Based on the doc, it seems that we need to specify the address of the contract we want to track. How could I track the new contract? eg. After deploying a factory contract, we also need to track all the new contract created by the factory.
Understanding that you could do this manually or writing a Cron task to check new contract deployment and script a re-deployment, is there any way to do this programmatically within thegraph.com? eg. How does uniswap track new trading pair after someone adding them (new contract address to track I suppose)?
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function createPair(address tokenA, address tokenB) external returns (address pair);
}
It's straight forward to track the factory contract. But after createPair
, how could I track the newly created contract address pair
? Is it possible to do this within thegraph.com? Or do I have to do it the hard way?
Answer: https://thegraph.com/docs/define-a-subgraph#data-source-templates
you can look into the official doc of subgraph. https://thegraph.com/docs/en/developing/creating-a-subgraph/#data-source-templates