How to use the @0x/contract-addresses.NetworkId.Mainnet function in @0x/contract-addresses

To help you get started, we’ve selected a few @0x/contract-addresses examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / pipeline / src / scripts / pull_exchange_transactions_from_etherscan.ts View on Github external
(async () => {
    const apiKey = process.env.ETHERSCAN_API_KEY;
    if (apiKey === undefined) {
        throw new Error('Missing required env var: ETHERSCAN_API_KEY');
    }
    connection = await createConnection(ormConfig as ConnectionOptions);
    const provider = web3Factory.getRpcProvider({
        rpcUrl: INFURA_ROOT_URL,
    });
    const EtherscanTransactionRepository = connection.getRepository(EtherscanTransaction);
    const startBlock = await getStartBlockAsync(EtherscanTransactionRepository);
    logUtils.log(`Start block: ${startBlock}`);
    const endBlock = await calculateEndBlockAsync(provider);
    logUtils.log(`End block: ${endBlock}`);
    const etherscanSource = new EtherscanSource(apiKey, startBlock, endBlock);
    const exchangeContractAddress = getContractAddressesForNetworkOrThrow(NetworkId.Mainnet).exchange;
    logUtils.log('Fetching exchange transactions from Etherscan...');
    const rawTransactions = await etherscanSource.getEtherscanTransactionsForAddressAsync(exchangeContractAddress);
    const transactions = parseEtherscanTransactions(rawTransactions);
    logUtils.log(`Saving ${transactions.length} records to database`);
    await EtherscanTransactionRepository.save(transactions, {
        chunk: Math.ceil(transactions.length / BATCH_SAVE_SIZE),
    });
    logUtils.log('Done');
    process.exit(0);
})().catch(handleError);

@0x/contract-addresses

Used to get known addresses of deployed 0x contracts

Apache-2.0
Latest version published 12 months ago

Package Health Score

73 / 100
Full package analysis

Similar packages