Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
web3Wrapper,
contractWrappers,
{ maker, taker },
{ WETH: etherTokenAddress, ZRX: zrxTokenAddress },
);
printUtils.printAccounts();
// the amount the maker is selling of maker asset (1 set of ERC721 Token and ERC20 tokens)
// when set to 1, this order cannot be partially filled.
const makerAssetAmount = new BigNumber(1);
// the amount the maker wants of taker asset
const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(0.1), DECIMALS);
// Generate a random token id
const tokenId = generatePseudoRandomSalt();
// 0x v2 uses hex encoded asset data strings to encode all the information needed to identify an asset
const erc721AssetData = assetDataUtils.encodeERC721AssetData(dummyERC721TokenContract.address, tokenId);
const erc20AssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
const erc20AssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(0.2), DECIMALS);
// combine both the ERC721 asset data and the ERC20 asset data into multi asset data
// the order is exchanging 1 ERC721 and 0.2 ZRX in exchange for 0.1 WETH
const makerAssetData = assetDataUtils.encodeMultiAssetData(
[makerAssetAmount, erc20AssetAmount],
[erc721AssetData, erc20AssetData],
);
const takerAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddress);
let txHash;
const zrxToken = new ERC20TokenContract(zrxTokenAddress, providerEngine);
// Mint a new ERC721 token for the maker
const mintTxHash = await dummyERC721TokenContract.mint.validateAndSendTransactionAsync(maker, tokenId, {
from: maker,
});
}
// Initialize the Web3Wrapper, this provides helper functions around fetching
// account information, balances, general contract logs
const web3Wrapper = new Web3Wrapper(providerEngine);
const [maker, taker] = await web3Wrapper.getAvailableAddressesAsync();
const printUtils = new PrintUtils(web3Wrapper, contractWrappers, { maker, taker }, { WETH: etherTokenAddress });
printUtils.printAccounts();
// the amount the maker is selling of maker asset: 1 ERC721 Token
const makerAssetAmount = new BigNumber(1);
// the amount the maker is selling of maker asset
const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(0.1), DECIMALS);
const tokenId = generatePseudoRandomSalt();
// 0x v2 uses hex encoded asset data strings to encode all the information needed to identify an asset
const makerAssetData = assetDataUtils.encodeERC721AssetData(dummyERC721TokenContract.address, tokenId);
const takerAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddress);
let txHash;
// Mint a new ERC721 token for the maker
const mintTxHash = await dummyERC721TokenContract.mint.sendTransactionAsync(maker, tokenId, { from: maker });
await printUtils.awaitTransactionMinedSpinnerAsync('Mint ERC721 Token', mintTxHash);
// Allow the 0x ERC721 Proxy to move ERC721 tokens on behalf of maker
const isApproved = true;
const makerERC721ApprovalTxHash = await dummyERC721TokenContract.setApprovalForAll.validateAndSendTransactionAsync(
contractAddresses.erc721Proxy,
isApproved,
{ from: maker },
);
await printUtils.awaitTransactionMinedSpinnerAsync('Maker ERC721 Approval', makerERC721ApprovalTxHash);
// With the Forwarding contract, the taker requires 0 additional set up
// Initialize the Web3Wrapper, this provides helper functions around fetching
// account information, balances, general contract logs
const web3Wrapper = new Web3Wrapper(providerEngine);
const [maker, taker] = await web3Wrapper.getAvailableAddressesAsync();
const printUtils = new PrintUtils(web3Wrapper, contractWrappers, { maker, taker }, { WETH: etherTokenAddress });
printUtils.printAccounts();
// the amount the maker is selling of maker asset (1 ERC721 Token)
const makerAssetAmount = new BigNumber(1);
// the amount the maker wants of taker asset
const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(0.1), DECIMALS);
// Generate a random token id
const tokenId = generatePseudoRandomSalt();
// 0x v2 uses hex encoded asset data strings to encode all the information needed to identify an asset
const makerAssetData = assetDataUtils.encodeERC721AssetData(dummyERC721TokenContract.address, tokenId);
const takerAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddress);
let txHash;
// Mint a new ERC721 token for the maker
const mintTxHash = await dummyERC721TokenContract.mint.sendTransactionAsync(maker, tokenId, { from: maker });
await printUtils.awaitTransactionMinedSpinnerAsync('Mint ERC721 Token', mintTxHash);
const erc721Token = new ERC721TokenContract(dummyERC721TokenContract.address, providerEngine);
// Allow the 0x ERC721 Proxy to move ERC721 tokens on behalf of maker
const makerERC721ApprovalTxHash = await erc721Token.setApprovalForAll.validateAndSendTransactionAsync(
contractAddresses.erc721Proxy,
true,
{ from: maker },
);
await printUtils.awaitTransactionMinedSpinnerAsync('Maker ERC721 Approval', makerERC721ApprovalTxHash);