public async Task ExchangeTokensViaSender() { EthereumAddress exchangeAddress = (EthereumAddress)ExchangeAddress; ExchangeContract exchange = new ExchangeContract(RpcURL, exchangeAddress, new Account(SenderPrivateKey)); Order order = new Order { MakerAddress = (EthereumAddress)MakerAddress, TakerAddress = (EthereumAddress)TakerAddress, SenderAddress = exchange.CallerAccount.Address, FeeRecipientAddress = exchange.CallerAccount.Address, MakerFee = 10, TakerFee = 10, MakerAssetAmount = 100, TakerAssetAmount = 100, MakerAsset = ERC20Asset.Create((EthereumAddress)MakerTokenAddress), TakerAsset = ERC20Asset.Create((EthereumAddress)TakerTokenAddress), ExpirationTime = DateTime.UtcNow + new TimeSpan(1, 0, 0), Salt = Random.GenerateSalt() }; byte[] makerSignature = order.Sign(exchangeAddress, MakerPrivateKey); Transaction tx = ExchangeContract.FillOrderGet0xTx(order, order.TakerAssetAmount, makerSignature); byte[] takerSignature = tx.Sign(exchangeAddress, TakerPrivateKey); string hash = await exchange.FillOrderAsync( order, order.TakerAssetAmount, makerSignature, takerSignature, tx.Salt, new TxParameters(1000000)); }
public async Task CancelOrder() { EthereumAddress exchangeAddress = (EthereumAddress)ExchangeAddress; ExchangeContract exchangeContract = new ExchangeContract(RpcURL, exchangeAddress, new Account(MakerPrivateKey)); Order order = new Order { MakerAddress = (EthereumAddress)MakerAddress, TakerAddress = (EthereumAddress)TakerAddress, SenderAddress = EthereumAddress.ZeroAddress, FeeRecipientAddress = (EthereumAddress)(Web3.GetAddressFromPrivateKey(SenderPrivateKey)), MakerFee = 10, TakerFee = 10, MakerAssetAmount = 100, TakerAssetAmount = 100, MakerAsset = ERC20Asset.Create((EthereumAddress)MakerTokenAddress), TakerAsset = ERC20Asset.Create((EthereumAddress)TakerTokenAddress), ExpirationTime = DateTime.UtcNow + new TimeSpan(1, 0, 0), Salt = Random.GenerateSalt() }; await exchangeContract.CancelOrderAsync(order, new TxParameters(1000000)); }
public async Task ExchangeTokens() { EthereumAddress exchangeAddress = (EthereumAddress)ExchangeAddress; ExchangeContract exchange = new ExchangeContract(RpcURL, exchangeAddress, new Account(TakerPrivateKey)); Order order = new Order { MakerAddress = (EthereumAddress)MakerAddress, TakerAddress = (EthereumAddress)TakerAddress, SenderAddress = (EthereumAddress)TakerAddress, FeeRecipientAddress = (EthereumAddress)(Web3.GetAddressFromPrivateKey(SenderPrivateKey)), MakerFee = 10, TakerFee = 10, MakerAssetAmount = 100, TakerAssetAmount = 100, MakerAsset = ERC20Asset.Create((EthereumAddress)MakerTokenAddress), TakerAsset = ERC20Asset.Create((EthereumAddress)TakerTokenAddress), ExpirationTime = DateTime.UtcNow + new TimeSpan(1, 0, 0), Salt = Random.GenerateSalt() }; byte[] signature = order.Sign(exchangeAddress, MakerPrivateKey); await exchange.FillOrderAsync(order, order.TakerAssetAmount, signature, new TxParameters(1000000)); }
internal Transaction(EthereumAddress signerAddress, string txData) { Salt = Random.GenerateSalt(); SignerAddress = signerAddress; TxData = txData.HexToByteArray(); }