public async Task GetEthSendGasLimit() { string address = "0xb332Feee826BF44a431Ea3d65819e31578f30446"; BigInteger gasLimit = await GasUtils.EstimateEthGasLimit(address, SolidityUtils.ConvertToUInt(0.04055123, 18)); Assert.IsTrue(gasLimit > 0); }
/// <summary> /// Gets the gas limit for the transfer of this token from the user's address to another address. /// </summary> /// <param name="receivingAddress"> The address to be receiving the tokens. </param> /// <param name="amount"> The amount of tokens to send and test the gas limit for. </param> /// <param name="onLimitReceived"> Action to execute when the gas limit has been received. </param> public override void GetTransferGasLimit(string receivingAddress, dynamic amount, Action <BigInteger> onLimitReceived) { GasUtils.EstimateContractGasLimit <ERC20.Messages.Transfer>(erc20TokenContract.ContractAddress, userWalletManager.GetWalletAddress(), receivingAddress, SolidityUtils.ConvertToUInt(amount, AssetDecimals)).OnSuccess(onLimitReceived); }
public Task <TransactionPoller> Approve(string privateKey, string spender, decimal amount, BigInteger gasLimit, BigInteger gasPrice) { Messages.Approve approve = new Messages.Approve { Spender = spender, Value = SolidityUtils.ConvertToUInt(amount, Decimals.Value) }; return(ContractUtils.SendContractMessage(approve, privateKey, ContractAddress, gasPrice, gasLimit)); }
/// <summary> /// Transfers a certain number of tokens of this contract from a wallet to another address. /// </summary> /// <param name="gasLimit"> The gas limit to use when sending the tokens. </param> /// <param name="gasPrice"> The gas price to use when sending the tokens. </param> /// <param name="privateKey"> The private key of the address sending the tokens. </param> /// <param name="addressTo"> The address the tokens are being sent to. </param> /// <param name="address"> The address to transfer the tokens to. </param> /// <param name="amount"> The amount of tokens to transfer. </param> public Task <TransactionPoller> Transfer(string privateKey, string addressTo, decimal amount, BigInteger gasLimit, BigInteger gasPrice) { Messages.Transfer transfer = new Messages.Transfer { AmountToSend = SolidityUtils.ConvertToUInt(amount, Decimals.Value), To = addressTo }; return(ContractUtils.SendContractMessage(transfer, privateKey, ContractAddress, gasPrice, gasLimit)); }
/// <summary> /// Locks a certain amount of purpose into the Hodler smart contract. /// </summary> /// <param name="privateKey"> The private key of the address sending the transaction. </param> /// <param name="gasLimit"> The gas limit to send with the transaction. </param> /// <param name="gasPrice"> The gas price to send with the transaction. </param> /// <param name="id"> The id of the lock function call. </param> /// <param name="lockAmount"> The amount of purpose to lock. </param> /// <param name="monthsToLock"> How many months the purpose should be locked for. </param> public EthTransactionPromise Hodl(string privateKey, BigInteger gasLimit, BigInteger gasPrice, BigInteger id, decimal lockAmount, int monthsToLock) { Messages.Hodl hodl = new Messages.Hodl { Id = id, Value = SolidityUtils.ConvertToUInt(lockAmount, 18), Months = monthsToLock }; return(ContractUtils.SendContractMessage(hodl, privateKey, ContractAddress, gasPrice, gasLimit)); }
public EthTransactionPromise TransferFrom(string privateKey, string addressFrom, string addressTo, decimal amount, BigInteger gasLimit, BigInteger gasPrice) { Messages.TransferFrom transferFrom = new Messages.TransferFrom { AmountToSend = SolidityUtils.ConvertToUInt(amount, Decimals.Value), From = addressFrom, To = addressTo }; return(ContractUtils.SendContractMessage(transferFrom, privateKey, ContractAddress, gasPrice, gasLimit)); }
/// <summary> /// Transfers a specified amount of ether from the input UserWallet to a specified address. /// </summary> /// <param name="userWalletManager"> The wallet to send the ether from. </param> /// <param name="gasLimit"> The gas limit to use for this ether send transaction. </param> /// <param name="gasPrice"> The gas price to use for this ether send transaction. </param> /// <param name="address"> The address to send the ether to. </param> /// <param name="amount"> The amount of ether to send. </param> public override void Transfer(UserWalletManager userWalletManager, HexBigInteger gasLimit, HexBigInteger gasPrice, string address, decimal amount) { userWalletManager.SignTransaction <ConfirmTransactionPopup>( request => EthUtils.SendEther(request, gasLimit, gasPrice, userWalletManager.GetWalletAddress(), address, amount), gasLimit, gasPrice, SolidityUtils.ConvertToUInt(amount, 18), address, "", address, AssetAddress, amount, "ETH"); }
public async Task EstimateGasLimitTest() { ERC20.Messages.Transfer transfer = new ERC20.Messages.Transfer { To = "0x5831819C84C05DdcD2568dE72963AC9f7e2833b6", Value = SolidityUtils.ConvertToUInt(1, 18) }; BigInteger gasLimit = await GasUtils.EstimateContractGasLimit( transfer, "0x5831819C84C05DdcD2568dE72963AC9f1e6831b6", "0xb332Feee826BF44a431Ea3d65819e31578f30446"); Assert.IsTrue(gasLimit > 0); }
/// <summary> /// Locks a certain amount of purpose into the Hodler smart contract. /// </summary> /// <param name="userWalletManager"> The class managing the wallet. </param> /// <param name="gasLimit"> The gas limit to send with the transaction. </param> /// <param name="gasPrice"> The gas price to send with the transaction. </param> /// <param name="id"> The id of the lock function call. </param> /// <param name="value"> The amount of purpose to lock. </param> /// <param name="monthsToLock"> How many months the purpose should be locked for. </param> public void Hodl(UserWalletManager userWalletManager, HexBigInteger gasLimit, HexBigInteger gasPrice, BigInteger id, decimal value, int monthsToLock) { var transactionInput = ContractFunction.CreateFunction <Messages.Hodl>( userWalletManager, gasPrice, gasLimit, id, SolidityUtils.ConvertToUInt(value, 18), new BigInteger(monthsToLock)).CreateTransactionInput(ContractAddress); userWalletManager.SignTransaction <ConfirmLockPopup>( request => ContractUtils.SendContractMessage("Locking PRPS", transactionInput, request), gasLimit, gasPrice, 0, ContractAddress, transactionInput.Data, monthsToLock, value); }
/// <summary> /// Transfers a certain number of tokens of this contract from a wallet to another address. /// </summary> /// <param name="userWalletManager"> The wallet to transfer the tokens from. </param> /// <param name="gasLimit"> The gas limit to use when sending the tokens. </param> /// <param name="gasPrice"> The gas price to use when sending the tokens. </param> /// <param name="address"> The address to transfer the tokens to. </param> /// <param name="amount"> The amount of tokens to transfer. </param> public void Transfer(UserWalletManager userWalletManager, HexBigInteger gasLimit, HexBigInteger gasPrice, string address, decimal amount) { var transactionInput = ContractFunction.CreateFunction <Messages.Transfer>( userWalletManager, gasPrice, gasLimit, address, SolidityUtils.ConvertToUInt(amount, Decimals.Value)).CreateTransactionInput(ContractAddress); userWalletManager.SignTransaction <ConfirmTransactionPopup>( request => ContractUtils.SendContractMessage($"Sending {Symbol}", transactionInput, request), gasLimit, gasPrice, 0, ContractAddress, transactionInput.Data, address, ContractAddress, amount, Symbol); }
/// <summary> /// Estimates the gas limit of transfering eth from one address to another. /// </summary> /// <param name="receivingAddress"> The address to receive the ether. </param> /// <param name="amount"> The amount of ether that is requesting to be sent. </param> /// <param name="onLimitReceived"> The action to execute when the gas limit has been received. </param> public override void GetTransferGasLimit(string receivingAddress, dynamic amount, Action <BigInteger> onLimitReceived) { GasUtils.EstimateEthGasLimit(receivingAddress, SolidityUtils.ConvertToUInt(amount, 18)).OnSuccess(onLimitReceived); }