How to use the 0x.js.signatureUtils.ecSignOrderAsync function in 0x

To help you get started, we’ve selected a few 0x 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-starter-project / src / scenarios / match_orders.ts View on Github external
expirationTimeSeconds: randomExpiration,
        salt: generatePseudoRandomSalt(),
        makerAssetAmount: leftOrder.takerAssetAmount,
        takerAssetAmount: rightOrderTakerAssetAmount,
        makerAssetData: leftOrder.takerAssetData,
        takerAssetData: leftOrder.makerAssetData,
        makerFee: ZERO,
        takerFee: ZERO,
    };
    PrintUtils.printData('Right Order', Object.entries(rightOrder));

    // Sign the Left Order
    const leftSignedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, leftOrder, leftMaker);

    //  Sign the Right Order
    const rightSignedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, rightOrder, rightMaker);

    // Print out the Balances and Allowances
    await printUtils.fetchAndPrintContractAllowancesAsync();
    await printUtils.fetchAndPrintContractBalancesAsync();
    // Match the orders via 0x Exchange
    txHash = await contractWrappers.exchange.matchOrders.validateAndSendTransactionAsync(
        leftSignedOrder,
        rightSignedOrder,
        leftSignedOrder.signature,
        rightSignedOrder.signature,
        {
            gas: TX_DEFAULTS.gas,
            from: matcherAccount,
        },
    );
    const leftOrderHashHex = orderHashUtils.getOrderHashHex(leftOrder);
github 0xProject / 0x-starter-project / src / scenarios / match_orders.ts View on Github external
takerAddress: NULL_ADDRESS,
        senderAddress: NULL_ADDRESS,
        feeRecipientAddress: NULL_ADDRESS,
        expirationTimeSeconds: randomExpiration,
        salt: generatePseudoRandomSalt(),
        makerAssetAmount: leftOrder.takerAssetAmount,
        takerAssetAmount: rightOrderTakerAssetAmount,
        makerAssetData: leftOrder.takerAssetData,
        takerAssetData: leftOrder.makerAssetData,
        makerFee: ZERO,
        takerFee: ZERO,
    };
    PrintUtils.printData('Right Order', Object.entries(rightOrder));

    // Sign the Left Order
    const leftSignedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, leftOrder, leftMaker);

    //  Sign the Right Order
    const rightSignedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, rightOrder, rightMaker);

    // Print out the Balances and Allowances
    await printUtils.fetchAndPrintContractAllowancesAsync();
    await printUtils.fetchAndPrintContractBalancesAsync();
    // Match the orders via 0x Exchange
    txHash = await contractWrappers.exchange.matchOrders.validateAndSendTransactionAsync(
        leftSignedOrder,
        rightSignedOrder,
        leftSignedOrder.signature,
        rightSignedOrder.signature,
        {
            gas: TX_DEFAULTS.gas,
            from: matcherAccount,
github 0xProject / 0x-starter-project / src / scenarios / forwarder_buy_erc20_tokens.ts View on Github external
makerAssetAmount,
        takerAssetAmount,
        makerAssetData,
        takerAssetData,
        makerFee: ZERO,
        takerFee: ZERO,
    };

    printUtils.printOrder(order);

    // Print out the Balances and Allowances
    await printUtils.fetchAndPrintContractAllowancesAsync();
    await printUtils.fetchAndPrintContractBalancesAsync();

    // Maker signs the order
    const signedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, order, maker);
    const affiliateFeeRecipient = NULL_ADDRESS;
    const affiliateFee = ZERO;

    // Use the Forwarder to market buy the ERC20 orders using Eth. When using the Forwarder
    // the taker does not need to set any allowances or deposit any ETH into WETH
    txHash = await contractWrappers.forwarder.marketBuyOrdersWithEth.validateAndSendTransactionAsync(
        [signedOrder],
        order.makerAssetAmount,
        [signedOrder.signature],
        [], // no fees required
        [],
        affiliateFee,
        affiliateFeeRecipient,
        {
            gas: TX_DEFAULTS.gas,
            from: taker,
github 0xProject / 0x-starter-project / src / scenarios / forwarder_buy_erc721_tokens.ts View on Github external
takerAssetAmount,
        makerAssetData,
        takerAssetData,
        makerFee: ZERO,
        takerFee: ZERO,
    };

    printUtils.printOrder(order);

    // Print out the Balances and Allowances
    await printUtils.fetchAndPrintContractAllowancesAsync();
    await printUtils.fetchAndPrintContractBalancesAsync();
    await printUtils.fetchAndPrintERC721OwnerAsync(dummyERC721TokenContract.address, tokenId);

    // Maker signs the order
    const signedOrder = await signatureUtils.ecSignOrderAsync(providerEngine, order, maker);
    const affiliateFeeRecipient = NULL_ADDRESS;
    const affiliateFee = ZERO;

    // Use the Forwarder to market buy the ERC721 orders using Eth. When using the Forwarder
    // the taker does not need to set any allowances or deposit any ETH into WETH
    txHash = await contractWrappers.forwarder.marketBuyOrdersWithEth.validateAndSendTransactionAsync(
        [signedOrder],
        order.makerAssetAmount,
        [signedOrder.signature],
        [], // no fees required
        [],
        affiliateFee,
        affiliateFeeRecipient,
        {
            gas: TX_DEFAULTS.gas,
            from: taker,