예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
파일: Transaction.cs 프로젝트: bojan96/0x
 internal Transaction(EthereumAddress signerAddress, string txData)
 {
     Salt          = Random.GenerateSalt();
     SignerAddress = signerAddress;
     TxData        = txData.HexToByteArray();
 }