How to use the @0x/contract-addresses.getContractAddressesForNetworkOrThrow 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_erc20_events.ts View on Github external
interface Token {
    // name is used for logging only.
    name: string;
    address: string;
    defaultStartBlock: number;
}

const tokensToGetApprovalEvents: Token[] = [
    {
        name: 'WETH',
        address: getContractAddressesForNetworkOrThrow(NETWORK_ID).etherToken,
        defaultStartBlock: 4719568, // Block when the WETH contract was deployed.
    },
    {
        name: 'ZRX',
        address: getContractAddressesForNetworkOrThrow(NETWORK_ID).zrxToken,
        defaultStartBlock: 4145415, // Block when the ZRX contract was deployed.
    },
    {
        name: 'DAI',
        address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
        defaultStartBlock: 4752008, // Block when the DAI contract was deployed.
    },
];

(async () => {
    connection = await createConnection(ormConfig as ConnectionOptions);
    const provider = web3Factory.getRpcProvider({
        rpcUrl: INFURA_ROOT_URL,
    });
    const endBlock = await calculateEndBlockAsync(provider);
    for (const token of tokensToGetApprovalEvents) {
github 0xProject / 0x-monorepo / packages / contract-wrappers / src / utils / zeroex_transaction_decoder.ts View on Github external
_.each(NetworkId, (networkId: any) => {
            if (typeof networkId !== 'number') {
                return;
            }
            const contractAddressesForNetwork = getContractAddressesForNetworkOrThrow(networkId);
            _.each(contractAddressesForNetwork, (contractAddress: string, contractName: string) => {
                const contractNameLowercase = _.toLower(contractName);
                if (_.isUndefined(deployedContractInfoByName[contractNameLowercase])) {
                    deployedContractInfoByName[contractNameLowercase] = [];
                }
                deployedContractInfoByName[contractNameLowercase].push({
                    contractAddress,
                    networkId,
                });
            });
        });
        // Load contract artifacts
github 0xProject / 0x-monorepo / packages / website / ts / pages / governance / connect_form.tsx View on Github external
public async getZrxBalanceAsync(owner: string): Promise {
        utils.assert(this._contractWrappers !== undefined, 'ContractWrappers must be instantiated.');
        const contractAddresses = getContractAddressesForNetworkOrThrow(this.networkId);
        const tokenAddress: string = contractAddresses.zrxToken;
        const erc20Token = new ERC20TokenContract(tokenAddress, this._contractWrappers.getProvider());
        try {
            const amount = await erc20Token.balanceOf.callAsync(owner);
            return amount;
        } catch (error) {
            return ZERO;
        }
    }
    private async _onConnectWalletClickAsync(): Promise {
github 0xProject / 0x-starter-project / src / contracts.ts View on Github external
const ERC721_TOKENS_BY_NETWORK_ID: { [networkId: number]: string[] } = {
    [RINKEBY_NETWORK_ID]: ['0xffce3807ac47060e900ce3fb9cdad3597c25425d'],
    [GANACHE_NETWORK_ID]: ['0x07f96aa816c1f244cbc6ef114bb2b023ba54a2eb'],
    [KOVAN_NETWORK_ID]: ['0x84580f1ea9d989c71c13492d5d157712f08795d8'],
    [ROPSTEN_NETWORK_ID]: [],
};

export const dummyERC721TokenContracts: DummyERC721TokenContract[] = [];

for (const tokenAddress of ERC721_TOKENS_BY_NETWORK_ID[NETWORK_CONFIGS.networkId]) {
    dummyERC721TokenContracts.push(
        new DummyERC721TokenContract(tokenAddress, providerEngine),
    );
}

export const contractAddresses = getContractAddressesForNetworkOrThrow(NETWORK_CONFIGS.networkId);
github 0xProject / 0x-monorepo / packages / website / ts / pages / instant / config_generator.tsx View on Github external
private readonly _setAvailableAssetsFromOrderProvider = async (): Promise => {
        const { value } = this.props;
        if (value.orderSource !== undefined && _.isString(value.orderSource)) {
            this.setState({ isLoadingAvailableTokens: true });
            const networkId = constants.NETWORK_ID_MAINNET;
            const sraOrderProvider = new StandardRelayerAPIOrderProvider(value.orderSource, networkId);
            const etherTokenAddress = getContractAddressesForNetworkOrThrow(networkId).etherToken;
            const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddress);
            const assetDatas = await sraOrderProvider.getAvailableMakerAssetDatasAsync(etherTokenAssetData);
            const availableTokens = _.reduce(
                assetDatas,
                (acc, assetData) => {
                    const metaDataIfExists = assetMetaDataMap[assetData] as ERC20AssetMetaData;
                    if (metaDataIfExists) {
                        acc[assetData] = metaDataIfExists;
                    }
                    return acc;
                },
                {} as ObjectMap,
            );
            this.setState({ availableTokens, isLoadingAvailableTokens: false });
        }
    };
github 0xProject / 0x-monorepo / packages / order-watcher / src / server.ts View on Github external
const GANACHE_NETWORK_ID = 50;
const DEFAULT_RPC_URL = 'http://localhost:8545';

const provider = new Web3ProviderEngine();
const jsonRpcUrl = process.env.JSON_RPC_URL || DEFAULT_RPC_URL;
const rpcSubprovider = new RPCSubprovider(jsonRpcUrl);
provider.addProvider(rpcSubprovider);
providerUtils.startProviderEngine(provider);

const networkId = process.env.NETWORK_ID !== undefined ? _.parseInt(process.env.NETWORK_ID) : GANACHE_NETWORK_ID;

const contractAddressesString = process.env.contractAddresses;
const contractAddressesIfExists =
    contractAddressesString === undefined
        ? getContractAddressesForNetworkOrThrow(networkId)
        : JSON.parse(contractAddressesString);

const orderWatcherConfig: any = {
    isVerbose: process.env.IS_VERBOSE === 'true',
};
const orderExpirationCheckingIntervalMs = process.env.ORDER_EXPIRATION_CHECKING_INTERVAL_MS;
if (orderExpirationCheckingIntervalMs !== undefined) {
    orderWatcherConfig.orderExpirationCheckingIntervalMs = _.parseInt(orderExpirationCheckingIntervalMs);
}
const eventPollingIntervalMs = process.env.EVENT_POLLING_INTERVAL_MS;
if (eventPollingIntervalMs !== undefined) {
    orderWatcherConfig.eventPollingIntervalMs = _.parseInt(eventPollingIntervalMs);
}
const expirationMarginMs = process.env.EXPIRATION_MARGIN_MS;
if (expirationMarginMs !== undefined) {
    orderWatcherConfig.expirationMarginMs = _.parseInt(expirationMarginMs);

@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