griffo-io / tron.net

GNU Lesser General Public License v3.0
40 stars 11 forks source link

Transaction signing #3

Open ErkanKule opened 5 years ago

ErkanKule commented 5 years ago

Hi ,

There is no sample for transaction signing

I has a transfer contract for TRX ,

        TransferContract trx = new TransferContract();
        trx.Amount = 100;
        trx.OwnerAddress = Google.Protobuf.ByteString.CopyFrom("TPMcVMR5PsGqsywBtXmjwxEVTtmBzWYaJv", Encoding.ASCII);
        trx.ToAddress = Google.Protobuf.ByteString.CopyFrom("TYZ9AYiuCsNyzhYGosUE1Zeay6DLn96w5p", Encoding.ASCII);

I had private key or ECKey too ,

what next to sign trx in c# ?

artem03 commented 3 years ago

@ErkanKule Have you found a solution to your question? If so, could you share how to sign a transaction directly in C #

EnjoX commented 3 years ago

I'm also interessted if somebody found a solution

MRayp commented 3 years ago

any news? it really should be with some sample code

EnjoX commented 3 years ago

I did it this way but im not sure if its correct, but would be nice if u can test ist.

private const string SignAlgorithmName = "SHA-256withECDSA"; public byte[] SignTransaction(byte[] data) { ISigner signer = SignerUtilities.GetSigner(SignAlgorithmName); signer.Init(true, _privateKey); signer.BlockUpdate(data, 0, data.Length); byte[] sigBytes = signer.GenerateSignature(); return sigBytes; }

MRayp commented 3 years ago

I did it this way but im not sure if its correct, but would be nice if u can test ist.

private const string SignAlgorithmName = "SHA-256withECDSA"; public byte[] SignTransaction(byte[] data) { ISigner signer = SignerUtilities.GetSigner(SignAlgorithmName); signer.Init(true, _privateKey); signer.BlockUpdate(data, 0, data.Length); byte[] sigBytes = signer.GenerateSignature(); return sigBytes; }

and how do you send it to the blockchain? i appreciate if you send full sample of your solution.

EnjoX commented 3 years ago

I have never tried. Its documented at https://developers.tron.network/docs/account If you want to test it you can use https://developers.tron.network/reference#walletbroadcasttransaction-1 I will also test it if i have time

sunny-boy3 commented 3 years ago

Does anyone have a full example of signing and broadcasting?

MRayp commented 3 years ago

Does anyone have a full example of signing and broadcasting?

Not with this library, but check this out: https://github.com/stoway/TronNet#sample-3-contract-trc20-transfer-usdt

Mae6e commented 2 years ago

@MRayp hi, how i can use TronNet with .net framework 4.7 ??

MRayp commented 2 years ago

@MRayp hi, how i can use TronNet with .net framework 4.7 ??

I used it in dotnet core... you should implement it in .net 4.7 yourself .

Mae6e commented 2 years ago

@MRayp ok. because .net framework does not support grpc ... .thank you

ramincsy2 commented 2 years ago

@maede71 Can multiple inputs and multiple outputs be specified for the transaction? That is, he sent tron from 3 addresses to one address?

Mae6e commented 2 years ago

@ramincsy2 i dont know. tronprotocol documentation: The adopted transaction model is the account model instead of the UTXO model. Currently, only one-to-one transaction services are available, meaning that one-to-many or many-to-one transactions are not supported.

help; https://github.com/tronprotocol/documentation/blob/master/TRX/Tron-overview.md and: https://developers.tron.network/docs/transactions-1

ramincsy2 commented 2 years ago

@maede71 How do big exchanges manage the wallets of the users?

for example: when we want to withdraw TRC20 from our wallets we need to pay fee in TRX, which causes a large amount of fee that is not an economic way for us. wold you please offer any solution for this.

ramincsy2 commented 2 years ago

@maede71 Thank you for your guidance

Mae6e commented 2 years ago

@ramincsy2 I think it's paid from a main wallet. And after a while, the users' wallets are transferred to the main wallet. And the cost is paid from the user withdrawal fee. This method prevents small amounts from remaining in the wallets. Maybe there are better solutions, if you find a solution, share it with us...

ramincsy2 commented 2 years ago

@maede71
I need help I want to sign the transaction trc20 usdt offline for .net or c#

Mae6e commented 2 years ago

@ramincsy2 I did not work on this and I do not know anything. on .NET4.7 or core?? How do you use it? And what can I do to help?

ramincsy2 commented 2 years ago

@maede71 .NET4.7 I can sign the transaction offline for trx trc10 but I can not sign the smart contract for trc20 offline I want to send usdt trc20 but the signature is offline

ramincsy2 commented 2 years ago

but I can not sign the smart contract for trc20 offline I want to send usdt trc20 but the signature is offline

EhsanGhanbari commented 7 months ago

Does anyone have a full example of signing and broadcasting?

Not with this library, but check this out: https://github.com/stoway/TronNet#sample-3-contract-trc20-transfer-usdt

it doesn't work!

Mae6e commented 7 months ago

@EhsanGhanbari what is your problem? https://developers.tron.network/docs/trc20-contract-interaction