|
@@ -155,6 +155,68 @@ namespace HyperCube.Models
|
|
var answer = await RunFunction2("eth_sendTransaction", transObj);
|
|
var answer = await RunFunction2("eth_sendTransaction", transObj);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public async Task Approve(string spender, string amount, string tokenAddress)
|
|
|
|
+ {
|
|
|
|
+ TransactionObject transObj = new TransactionObject();
|
|
|
|
+ transObj.from = spender;
|
|
|
|
+ transObj.to = tokenAddress;// "0xe5D682717955d6C35d465A3485625C64655a04f4";
|
|
|
|
+ transObj.gas = "9000";
|
|
|
|
+ transObj.value = "0";
|
|
|
|
+ transObj.data = await compileFunction($"function approve(address spender, uint256 amount)");
|
|
|
|
+ if (tokenAddress != null)
|
|
|
|
+ {
|
|
|
|
+ transObj.data += zerofill(tokenAddress, 64, true);
|
|
|
|
+ transObj.data += zerofill(spender, 64, true);
|
|
|
|
+ transObj.data += zerofill(dec2hex(Convert.ToInt32(amount)), 64, true);
|
|
|
|
+ }
|
|
|
|
+ var answer = await RunFunction2("eth_sendTransaction", transObj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async Task SubmitTransaction(string owner, string tokenvalue, string receiver, string tokenAddress = "0xe5D682717955d6C35d465A3485625C64655a04f4")
|
|
|
|
+ {
|
|
|
|
+ //"submitTransaction(address destination, uint value, address tokenAddress)"
|
|
|
|
+ var tokenAmount = float.Parse(tokenvalue, System.Globalization.CultureInfo.InvariantCulture);// * 1000000000000000000;
|
|
|
|
+
|
|
|
|
+ //ETHtoERC20(address tokenAddress)
|
|
|
|
+ //ERC20toETH(address tokenAddress, address sender, uint256 tokenAmount, uint256 ethAmount) public payable returns(bool)
|
|
|
|
+ TransactionObject transObj = new TransactionObject();
|
|
|
|
+ transObj.from = owner;
|
|
|
|
+ transObj.to = "0x862A2Ac8D1dB37085c786981A8F5bd54594f7162";// "0xe5D682717955d6C35d465A3485625C64655a04f4";
|
|
|
|
+ transObj.gas = "9000";
|
|
|
|
+ transObj.value = "0";
|
|
|
|
+ transObj.data = await compileFunction($"submitTransaction(address destination, uint value, address tokenAddress)");
|
|
|
|
+ if (tokenvalue != null)
|
|
|
|
+ {
|
|
|
|
+ transObj.data += zerofill(receiver, 64, true);
|
|
|
|
+ transObj.data += zerofill(dec2hex(Convert.ToInt32(tokenAmount)), 64, true);
|
|
|
|
+ transObj.data += zerofill(tokenAddress, 64, true);
|
|
|
|
+ }
|
|
|
|
+ var answer = await RunFunction2("eth_sendTransaction", transObj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async Task ChangeCurrency(string from_token_selected, string to_token_selected, string tokenAddress, string sender, string from, string to, string fi, string ti)
|
|
|
|
+ {
|
|
|
|
+ var val = float.Parse(fi, System.Globalization.CultureInfo.InvariantCulture);
|
|
|
|
+ var tokenAmount = val;// * 1000000000000000000;
|
|
|
|
+ val = float.Parse(ti, System.Globalization.CultureInfo.InvariantCulture);
|
|
|
|
+ var ethAmount = val / 5; // /5
|
|
|
|
+ //ETHtoERC20(address tokenAddress)
|
|
|
|
+ //ERC20toETH(address tokenAddress, address sender, uint256 tokenAmount, uint256 ethAmount) public payable returns(bool)
|
|
|
|
+ TransactionObject transObj = new TransactionObject();
|
|
|
|
+ transObj.from = sender;
|
|
|
|
+ transObj.to = "0x862A2Ac8D1dB37085c786981A8F5bd54594f7162";// "0xe5D682717955d6C35d465A3485625C64655a04f4";
|
|
|
|
+ transObj.gas = "9000";
|
|
|
|
+ transObj.value = "0";
|
|
|
|
+ transObj.data = await compileFunction($"function ERC20toETH(address tokenAddress, address sender, uint256 tokenAmount, uint256 ethAmount)");
|
|
|
|
+ if (tokenAddress != null && tokenAmount != null)
|
|
|
|
+ {
|
|
|
|
+ transObj.data += zerofill(tokenAddress, 64, true);
|
|
|
|
+ transObj.data += zerofill(sender, 64, true);
|
|
|
|
+ transObj.data += zerofill(dec2hex(Convert.ToInt32(tokenAmount)), 64, true);
|
|
|
|
+ transObj.data += zerofill(dec2hex(Convert.ToInt32(ethAmount)), 64, true);
|
|
|
|
+ }
|
|
|
|
+ var answer = await RunFunction2("eth_sendTransaction", transObj);
|
|
|
|
+ }
|
|
|
|
|
|
public async Task<string> Verify(AccountModel verifier, ArticleModel article)
|
|
public async Task<string> Verify(AccountModel verifier, ArticleModel article)
|
|
{
|
|
{
|