stoway / tronnet Goto Github PK
View Code? Open in Web Editor NEW.net sdk of tron
License: MIT License
.net sdk of tron
License: MIT License
Contract validate error : account xx does not exist
Please follow this commit: night-king@e5f4033
Also you can clone my Fork: https://github.com/night-king/TronNet
I am running my website on Windows Server IIS 10 and I am using .NET 5 integrated with Angular.
I have some problem using any APIs of TronNet on production environment.
everything work fine on localhost but when I deploy on server I get below error:
Grpc.Core.RpcException: Status(StatusCode="Cancelled", Detail="Received http2 header with status: 503")
at TronNet.Contracts.TRC20ContractClient.BalanceOfAsync(String contractAddress, ITronAccount ownerAccount)
On the other hand, I simply GetBalanceAsync of an address, in one of my web page work correctly and get balances, but on other pages I get the error !
Also, in those pages that I have problem to getting the balance for example, it work on the first try, but when I refresh the page I get the error !
The code that I get contract balance is :
private async Task<decimal> GetContractBalance(string contractAddress, string privateKey)
{
decimal balance = 0;
var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20);
ITronAccount tronAccount = _tronWalletClient.GetAccount(privateKey);
balance = await contractClient.BalanceOfAsync(contractAddress, tronAccount); // Error
return balance;
}
I can't use the following:
services.AddTronNet();
In a console. So I need to create the Wallet object myself.
Hi,
I have tested this library on mainnet as well as testnet and it's working perfectly on both. I'm able to transfer TRX and USDT from one account to another, I have one question though, how can I know the balance of TRX and USDT? couldn't find any example.
Thanks.
UPDATE:
I'm able to get USDT account balance using this code
var account = _wallet.GetAccount(fromKey); var contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20); return contractClient.BalanceOfAsync(contractAddress, account);
Still not able to get TRX balance.
[ERR] Value was either too large or too small for an Int64.
System.OverflowException: Value was either too large or too small for an Int64.
at System.Numerics.BigInteger.op_Explicit(BigInteger value)
at TronNet.ABI.Decoders.IntTypeDecoder.DecodeLong(Byte[] encoded)
at TronNet.ABI.Decoders.IntTypeDecoder.Decode(Byte[] encoded, Type type)
at TronNet.ABI.FunctionEncoding.ParameterDecoder.DecodeOutput(Byte[] outputBytes, ParameterOutput[] outputParameters)
at TronNet.ABI.FunctionEncoding.ParameterDecoder.DecodeAttributes(Byte[] output, Object result, PropertyInfo[] properties)
at TronNet.ABI.FunctionEncoding.ParameterDecoder.DecodeAttributes(String output, Object result, PropertyInfo[] properties)
at TronNet.ABI.FunctionEncoding.ParameterDecoder.DecodeAttributes[T](String output, T result, PropertyInfo[] properties)
at TronNet.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutput[T](T functionOutputResult, String output)
at TronNet.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutput[T](String output)
at TronNet.Contracts.TRC20ContractClient.BalanceOfAsync(String contractAddress, ITronAccount ownerAccount)
按交易哈希查询交易GetTransactionById,如何解析这个接口返回的数据 我要取得发送地址,接收地址和金额,有偿。
这下面是返回的 要解析parameter.value.data的数据
{
"ret":[
{
"contractRet":"SUCCESS"
}
],
"signature":[
"4a7e494686ee3f0e3e288fabee9612a4d83f30b99e4b543b4f5da053dd481b91c35ebdf5568e325136371ed47303a8e6acd1ca419532d77c494636324fb42a7201"
],
"txID":"d1c8d6461bd5a67e79359c27480745329c4f53cb82ff8ee1379f9eaa5dd17709",
"raw_data":{
"contract":[
{
"parameter":{
"value":{
"data":"7688415300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000002710000000000000000000000000af8a80171afcca0a76d33ec56f6e3000bceab5ef0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f09afffc8b64bca573deb35d12ff9b9c69497075",
"owner_address":"419e1d445505e6acea6372c69c4afbe6c0c76f8587",
"contract_address":"412e598a00d210f294d54bb7b1b8d008558d67d2e7"
},
"type_url":"type.googleapis.com/protocol.TriggerSmartContract"
},
"type":"TriggerSmartContract"
}
],
"ref_block_bytes":"7497",
"ref_block_hash":"1fc27e8ca4b6cc9f",
"expiration":1626706053000,
"fee_limit":300000000,
"timestamp":1626705994921
},
"raw_data_hex":"0a02749722081fc27e8ca4b6cc9f40888ff2f9ab2f5a9002081f128b020a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412d5010a15419e1d445505e6acea6372c69c4afbe6c0c76f85871215412e598a00d210f294d54bb7b1b8d008558d67d2e722a4017688415300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000002710000000000000000000000000af8a80171afcca0a76d33ec56f6e3000bceab5ef0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f09afffc8b64bca573deb35d12ff9b9c6949707570a9c9eef9ab2f900180c6868f01"
}
It was working, suddenly has stopped with no reason !
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter "Illegal character at 0")
at TronNet.Crypto.Base58Encoder.Decode(String input)
at TronNet.Crypto.Base58Encoder.DecodeFromBase58Check(String addressBase58)
at TronNet.Contracts.TRC20ContractClient.TransferAsync(String contractAddress, ITronAccount ownerAccount, String toAddress, Decimal amount, String memo, Int64 feeLimit)
Hello. How should I send the decimal amount?
在VS中发布时选择生成单个文件,运行时会报异常
查找相关资料,是引用的GRPC包引起的,在更新的GRPC版本中修复了该问题
System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
at Grpc.Core.Internal.NativeExtension..ctor()
at Grpc.Core.Internal.NativeExtension.Get()
at Grpc.Core.Internal.NativeMethods.Get()
at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
at Grpc.Core.GrpcEnvironment..ctor()
at Grpc.Core.GrpcEnvironment.AddRef()
I have a main account with about 1500TRX and enough energy & bandwidth in it.
I went through several steps:
@) When I transfer some token by my tronlink wallet to this new generated address, transfer will succeed, but when I'm using below code I get error :
The account is out of energy, or the contract's fee limit has been exceeded.
https://tronscan.io/#/transaction/714c0a87220765b223c429802814ce8f0eb5a5dfb1e7eb60243ab5ab008a9119?lang=en
BUT I have enough energy !
using TronNet;
using System.Threading.Tasks;
using Google.Protobuf;
using Microsoft.Extensions.Options;
namespace TronNetTest
{
class Class1
{
private readonly IWalletClient _wallet;
private readonly IContractClientFactory _contractClientFactory;
public Class1(IWalletClient wallet, IContractClientFactory contractClientFactory)
{
_wallet = wallet;
_contractClientFactory = contractClientFactory;
}
public async Task TransferAsync()
{
var privateKey = "000000000000-PRIVATE-KEY-EXAMPLE-00000000000";
var account = _wallet.GetAccount(privateKey);
var contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; //USDT Contract Address
var to = "00000000-NEW-GENERATED-ADDRESS-0000000000";
var amount = 10; //USDT Amount
var feeAmount = 5 * 1000000L;
var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20);
var result = await contractClient.TransferAsync(contractAddress, account, to, amount, string.Empty, feeAmount);
}
}
}
TronNet 0.2.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package TronNet 0.2.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
I looked at the sample, seems like we can only get the balance if we have the private key.
This shouldn't be the case.
Normally I can get the TxID when I signed the transaction online.
But here since we are signing offline, we won't get any TxID when signing.
And the result returned by BroadcastTransactionAsync() is only TRUE. Nothing else.
Hey, this isn't a bug issue. Is it possible to recover an Address from a signed message and the original message? I looked at the ECKey class and that seemed to have the methods I want, but I don't see where it would verify a user's address.
How can I check TRX balance in my wallet?
var data= window.tronWeb.toHex('key');
console.log(data);
window.tronWeb.trx.sign(data).then((sign) => {
console.log(sign)
var url="/Public/login";
var data={
address:App.address,
password:this.password,
intro:this.intro,
sign:sign
};
$.post(url,data,function(res){
if(res.status==0)
tips(res.info)
else
{
window.sessionStorage.setItem('login',1)
window.sessionStorage.setItem('loginAddress',App.address)
window.location=res.url
}
})
})
TRC20ContractClient
var balance = Convert.ToDecimal(result.Balance);
if (decimals > 0)
{
balance /= Convert.ToDecimal(Math.Pow(10, decimals));
}
Change to
var balance = Nethereum.Web3.Web3.Convert.FromWeiToBigDecimal(result.Balance);
return decimal.Parse(balance.ToString());
How to get the last transactions for an account? I'm trying to check if a payment posted I would like a list of the transactions for an account. I haven't been able to figure out how to.
When I use demo with 'TransferAsync',but found some wrong with it!
var contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
wallet.TriggerConstantContract()
{{ "code": "CONTRACT_VALIDATE_ERROR", "message": "Q29udHJhY3QgdmFsaWRhdGUgZXJyb3IgOiBTbWFydCBjb250cmFjdCBpcyBub3QgZXhpc3Qu" }}
Thanks!
I can successfully sign and broadcast TRX transactions and get account balance, but transferring tokens is not working for me.
My code:
public async Task<string> TransactionToken(string contractAddress, string privateKey, string toAddress, decimal amount)
{
try
{
var account = _walletClient.GetAccount(privateKey);
var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20);
var result = await contractClient.TransferAsync(contractAddress, account, toAddress, amount, string.Empty, 5 * 1000000L);
return result;
}
catch (Exception)
{
return null;
throw;
}
}
I get a txid in the response and it seems that everything's working fine, but the transaction is not happening on the network and I can't find the txid on tronscan.
First of all thanks for your library. Is there a sample to get balace of account for tron and tron's tokens like usdt?
I can not find any ducument for TronNet.
Hello,
I am getting sigerror error.
Sample 3: I tried Contract TRC20 Transfer (USDT) and there was no transaction.
I tried Sample 2: Transaction Sign Offline but it didn't work there either. There is a problem with the trongrid.io installer.
How do they do this.
program.cs
using TronNet;
builder.Services.AddTronNet(x =>
{
x.Network = TronNetwork.MainNet;
x.Channel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50051 };
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50052 };
x.ApiKey ="myapikey";
});
homecontroller.cs
using TronNet;
var privateKey = "8e812436a0e3323166e1f0e8ba79e19e217b2c4a53c970d4cca0cfb1078979df";
string fromAddress = "TFbrUmaS8Zqdbsw92GDoqx6nH2U9GoosrS";
var account = new Lottery.WebUi.Models.TronAccount()
{
Address = fromAddress,
PrivateKey = privateKey,
PublicKey = "04a5bb3b28466f578e6e93fbfd5f75cee1ae86033aa4bbea690e3312c087181eb366f9a1d1d6a437a9bf9fc65ec853b9fd60fa322be3997c47144eb20da658b3d1"
};
var ecKey = new TronECKey(privateKey, _options.Value.Network);
var from = "TFbrUmaS8Zqdbsw92GDoqx6nH2U9GoosrS";
var to = "TDRK6kQnc55EWkFL4bvv8Fefdbt3HfsiE9";
var amount = 5_000_000L;
var transactionExtension = await _transactionClient.CreateTransactionAsync(from, to, amount);
var transactionSigned = _transactionClient.GetTransactionSign(transactionExtension.Transaction, privateKey);
var result = await _transactionClient.BroadcastTransactionAsync(transactionSigned); // return false, sigerror
Example address
address = TA3vQ9NQ7nhGr2W6kMw4DFTYhoWMv8hi3h
contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
{{ "code": "CONTRACT_VALIDATE_ERROR", "message": "Q29udHJhY3QgdmFsaWRhdGUgZXJyb3IgOiB0aGlzIG5vZGUgZG9lcyBub3Qgc3VwcG9ydCBjb25zdGFudA==" }}
作者您好,感谢您的无私分享
请问下这个在winform下如何配置呢
How can i transfer TRC-20 tokens ? does this project support them ?
Hi. can I use this package to listen to trc20 contract of a tron wallet address?
how to transfer trx from one wallet to other wallet in asp.net c# ,
i want to send tron from one account to other account , please suggest me help full code script which i used in my asp.net c# project
hi
how can i get Transaction details by txid same as web3 library?
https://cn.developers.tron.network/docs/exchangewallet-integrate-with-the-tron-network
想实现的功能是TRC_20 USDT的地址,判断这个地址是否有资金实时转入。
现在不清楚怎么实现图片上面的3个步骤,可以给个示例吗?万分感谢
I have a question.
I have 100,000 wallet addresses and I want to be notified immediately if a token is deposited into it, like a webhook / event listener or something like that.
Is there a way that is basic and we can do it? Like wallet applications, in the past I used to regularly query and compare transactions, but this is not good at all.
Example:
https://api.trongrid.io/v1/accounts/{address}/transactions/trc20?only_confirmed=true&contract_address=TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t&only_to=true&limit=200
for each address
TKgw1i2s6KnUTLDmVTBCcrhTifCze43ae1
Hello. I'm new to tron. I have problems acquiring balances. I've registred on trongrid.io, issued an apikey and generated an account using wallet.GenerateAccount()
.
protocol.GetAccountAsync
returns empty account, whith nothing whithin it, I have no balances, but everything is null or 0, is it ok?contractClient.BalanceOfAsync
throws exception with message "Contract validate error : Smart contract is not exist.". Do I need to create something to use usdt over tron network?This is full code of my test program:
static decimal GetTRXBalance(IWalletClient _walletClient, string address)
{
var protocol = _walletClient.GetProtocol();
var addr = _walletClient.ParseAddress(address);
var result = Task.Run(async () => await protocol.GetAccountAsync(new Account
{
Address = addr
}));
var account = result.GetAwaiter().GetResult();
var balance = Convert.ToDecimal(account.Balance) / 1_000_000L;
return balance;
}
static decimal GetUSDTBalance(IWalletClient _walletClient, IContractClient _contractClient, string privatekey, string contractAddress)
{
var tronacc = _walletClient.GetAccount(privatekey);
Task<decimal> result = Task.Run(async () => await _contractClient.BalanceOfAsync(contractAddress, tronacc));
var account = result.GetAwaiter().GetResult();
return account;
}
static void test()
{
IServiceCollection services = new ServiceCollection();
services.AddTronNet(x =>
{
x.Network = TronNetwork.MainNet;
x.Channel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50051 };
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50052 };
x.ApiKey = "apikey";
});
services.AddLogging();
var service = services.BuildServiceProvider();
var wallet = service.GetService<IWalletClient>();
var contract = service.GetService<IContractClientFactory>().CreateClient(ContractProtocol.TRC20);
//TJy97mgrgBmko6Nuzjx3RYG6oN6LqW8ykr
//b6b5f0d3ca6b26ac143b70116454a273b26952c4b2fe8e4615e7175f95495b8e
//04df8eb6ea14fbd72ca3cd121fdf1ad530f80c93091ed7c6e1a47a018ab1a276fcadb74beaf92775d54767c4694dd5351dbe7aaceea2df7144aeb9246f44c44244
//var tronacc = wallet.GenerateAccount();
decimal trx = GetTRXBalance(wallet, "TJy97mgrgBmko6Nuzjx3RYG6oN6LqW8ykr");
decimal usdt = GetUSDTBalance(wallet, contract, "b6b5f0d3ca6b26ac143b70116454a273b26952c4b2fe8e4615e7175f95495b8e", "TJy97mgrgBmko6Nuzjx3RYG6oN6LqW8ykr");
;
}
static void Main(string[] args)
{
test();
}
.Net Standard project is not support, How can I used TronNet in Xamarin?
{ "code": "TAPOS_ERROR", "message": "VGFwb3MgY2hlY2sgZXJyb3I=" } 报双花问题,请问这个怎么解决
Hi Stoway,
As you mention before about IP frequency limits of using the TronGrid GRPC service that is 15QPS,
I read about it on
https://developers.tron.network/docs/faq#10how-to-solve-the-error-of-trongrid-503-service-temporarily-unavailable
So I realized that we have 15QPS per API keys.
Is there any possibility to use multiple API keys in one project?
I think if I devide my requests and send them to specific API key I may have more ability to manage my requests.
I use below configuration on my .NET 5 startup.cs:
services.AddTronNet(x =>
{
x.Network = TronNetwork.MainNet;
x.Channel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50051 };
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50052 };
x.ApiKey = _appConfiguration["Tron:APIKey"].ToString();
});
Nuget package seems to be broken and have unresolved dependency to its other projects.
also there is an unnecessary dependency to StowayNet.Extensions.DependencyInjection project which can be removed and use dotnet core build-in di.
I got an error when calling BalanceOfAsync
ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')
Google.Protobuf.Collections.RepeatedField.get_Item(int index)
TronNet.Contracts.TRC20ContractClient.GetDecimals(WalletClient wallet, byte[] contractAddressBytes)
TronNet.Contracts.TRC20ContractClient.BalanceOfAsync(string contractAddress, ITronAccount ownerAccount)
CryptoPayment.WebUI.Controllers.WeatherForecastController.Get(IWalletClient _wallet, IContractClientFactory
my code:
var balance = await contractClient.BalanceOfAsync("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", wallet);
Hello All,
My Code:
IServiceCollection services = new ServiceCollection();
services.AddTronNet(x =>
{
x.Network = TronNetwork.MainNet;
x.Channel = new GrpcChannelOption { Host = "grpc.trongrid.io"};
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.trongrid.io"};
x.ApiKey = "3334986a-****";
});
services.AddLogging();
var service = services.BuildServiceProvider();
var walletClient = service.GetService<IWalletClient>();
var account = walletClient.GetAccount(walletPrivateKey);
//USDT TOKEN
var contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
//收的錢包
var to = "TLhTDxNcm9XaSq35mghq6Az35LeHdcn77S";
var amount = 1;
//手續費 10 TRX
var feeAmount = 20 * 1_000_000L;
var contractClientFactory = service.GetService<IContractClientFactory>();
var contractClient = contractClientFactory.CreateClient(ContractProtocol.TRC20);
//備註只能用英文
var result = contractClient.TransferAsync(contractAddress, account, to, amount, "Test", feeAmount);
Console.WriteLine("-- RESULT --");
Console.WriteLine(JsonConvert.SerializeObject(result));
result = Id = 1, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
BalanceOfFunctionOutput unit256 should convert to BigInteger instead of long
public class BalanceOfFunctionOutput : IFunctionOutputDTO
{
[Parameter("uint256", 1)]
public BigInteger Balance { get; set; }
}
BalanceOfAsync() should allow to pass in an Account with only PublicKey. There is no reason we need to have access to PrivateKey just to query for the balance. Look into the code and you should notices that the PrivateKey passed in is not used at all.
and since #1 had been changed to BigInteger, the following line in BalanceOfAsync() shall change to
// var balance = Convert.ToDecimal(result.Balance);
var balance = (decimal)result.Balance;
The following code won't compile without explicitly cast the result to (byte)
internal byte GetPublicAddressPrefix()
{
return (byte)(_network == TronNetwork.MainNet ? 0x41 : 0xa0);
}
how can I get txid after signing and broadcasting TRX and token transactions ?
{{ "code": "SIGERROR", "message": "VmFsaWRhdGUgc2lnbmF0dXJlIGVycm9yOiA3Y2I2OTRkZTQwMTI2MWUwMmRjOWU2MjZlNzU3MWJjMGRkNzliNGI5YjJlZmE0MDhmMmU5YzlkNzUwMTRiM2UxMGIzOTEwZDA1ZTIwYjJjY2VhMDAzZTRmZjk2YTA5NWNmZTY2ZDVlMzA2YzE2NzNiZGJmYTY4MTIwNDBiYTZmODAwIGlzIHNpZ25lZCBieSBUVFdrRjFYdnBxZE5qazNFWUZDb1BjSEZydUdOQlNKVkJzIGJ1dCBpdCBpcyBub3QgY29udGFpbmVkIG9mIHBlcm1pc3Npb24u" }}
There is a sample code like below in your github page but there not GenerateKey() function in the TronClient classs.
public void GenerateAddress()
{
var key = _tronClient.GenerateKey();
var address = key.GetPublicAddress();
}
Hello,
I can't find where the error is in my work in core 6 :(
I searched many articles and when I finally ran it, the result was "b8107a19cb24e2ffe69b2b45a9499c1bf1bc78f0a54223569a48b6e311df3903". I don't know where to use this incoming information. How do I access the txID? Is this the result of the txID?
I wonder if it is due to the api settings in trongrid.io. Can you help me.
program.cs
builder.Services.AddTronNet(x =>
{
x.Network = TronNetwork.MainNet;
x.Channel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50051 };
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.trongrid.io", Port = 50052 };
x.ApiKey ="myapikey"
});
TronAccount.cs
namespace .WebUi.Models
{
public class TronAccount : ITronAccount
{
public string PublicKey { get; set; }
public string PrivateKey { get; set; }
public string Address { get; set; }
public byte GetAddressPrefix()
{
throw new NotImplementedException();
}
}
}
homecontroller.cs
using TronNet;
private readonly IWalletClient _wallet;
private readonly IContractClientFactory _contractClientFactory;
public HomeController( IWalletClient wallet, IContractClientFactory contractClientFactory)
{
_wallet = wallet;
_contractClientFactory = contractClientFactory;
}
public async Task Index()
{
var privateKey = "8e812436a0e3323166e1f0e8ba79e19e217b2c4a53c970d4cca0cfb1078979df";
string fromAddress = "TFbrUmaS8Zqdbsw92GDoqx6nH2U9GoosrS";
var account = new WebUi.Models.TronAccount()
{
Address = fromAddress,
PrivateKey = privateKey
};
var contractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; //USDT Contract Address
var to = "TDRK6kQnc55EWkFL4bvv8Fefdbt3HfsiE9";
var amount = 5; //USDT Amount
var feeAmount = 5 * 1000000L;
var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20);
var result = await contractClient.TransferAsync(contractAddress, account, to, amount, string.Empty, feeAmount);
// result="b8107a19cb24e2ffe69b2b45a9499c1bf1bc78f0a54223569a48b6e311df3903
Hi there,
Im trying to transfer USDT over tron network but there is an exception:
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. (Parameter 'Illegal character 0 at 1')'
Code:
services.AddTronNet(x =>
{
x.Network = TronNetwork.TestNet;
x.Channel = new GrpcChannelOption { Host = "grpc.nile.trongrid.io", Port = 50051 };
x.SolidityChannel = new GrpcChannelOption { Host = "grpc.nile.trongrid.io", Port = 50061 };
x.ApiKey = "8e79fb6f-e787-418b-8238-c666651b51ac";
});
var account = _wallet.GetAccount(privateKey);
var contractAddress = "TSzM1BMMHidyodU9FBq2v2rGfoZnuX9L5T";
var to = "TRw1rCgZzidsos7iYevHP73c6o79H8187v";
var amount = 10;
var feeAmount = 5 * 1000000L;
var contractClient = _contractClientFactory.CreateClient(ContractProtocol.TRC20);
var result = await contractClient.TransferAsync(contractAddress, account, to, amount, "TERC", feeAmount);
And if there is any other/better approach please help how to do it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.