Git Product home page Git Product logo

Comments (17)

farukterzioglu avatar farukterzioglu commented on May 24, 2024

@artem03 right now I am using this library to create&sign&send TRC20 TriggerSmartContract transactions without problem.
Did you try to send any?
I will check if there was any custom modification for TriggerSmartContract on my side, but as I remember I done nothing regarding to it.

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

@farukterzioglu I was trying to send a TRC20 TriggerSmartContract for USDT just today, and got a SIGERROR error when broadcasting.

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

Let me check more

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

Yes of course, maybe I made a mistake somewhere, but I've checked my code many times, maybe I'm just doing something wrong

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

@farukterzioglu Did you find any "custom modification" for the TRC20 TriggerSmartContract sign?

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

@artem03 Just checked and saw they are same, there is no difference between signing TRX transaction and TRC20 transaction. Both signs the txid and adds the result to the signatures field. Both signatures is 68 bytes and this works in Tron Mainnet and Shasta.

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

@farukterzioglu Oh, sorry, I sent a transaction to the broadcast without the fee_limit field, after adding this field everything worked, the problem can be closed, I wanted to ask if you know how to decode the data field (to get the recipient and the amount you received) when receiving the transaction block

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

@artem03 normal TRX transaction or TRC20 transaction?

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

I guess you are asking about this

Amount = Convert.ToInt64(transactionEvent.Result.Value),
From = transactionEvent.Result.From.Replace("0x", "41").ToVisibleAddress(),
To = transactionEvent.Result.To.Replace("0x", "41").ToVisibleAddress(),

with

using NBitcoin.DataEncoders;

public static string ToVisibleAddress(this string tronAddress)
        {
            if (string.IsNullOrWhiteSpace(tronAddress))
            {
                return null;
            }

            byte[] bytes = tronAddress.FromHexToByteArray();
            return Encoders.Base58Check.EncodeData(bytes);
        }
        
public static byte[] FromHexToByteArray(this string input)
        {
            var numberChars = input.Length;
            var bytes = new byte[numberChars / 2];
            for (var i = 0; i < numberChars; i += 2)
            {
                bytes[i / 2] = Convert.ToByte(input.Substring(i, 2), 16);
            }
            return bytes;
        }   
        
          

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

Not sure what exactly I need, I asked about Data in TriggerSmartContract, I use the following code to encode the data

public class TestParamsInput
	{
		[Parameter("address", 1)]
		public string First { get; set; }
		[Parameter("uint256", 2)]
		public UInt64 Second { get; set; }
	}
var abiEncode = new ABIEncode();
var data = abiEncode.GetABIParamsEncoded<TestParamsInput>(new TestParamsInput() { First = "address", Second = UInt64.Parse("amount") });

But I don't know how to decode them

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

can you paste the encoded data here

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

"00000000000000000000000033a53245269c4706e378e7c58788bfb47c8d4fbd00000000000000000000000000000000000000000000000000000000000f4240"

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

not sure this what you want but you can check this request:
https://api.trongrid.io/event/transaction/f87d6f7973895f1d8de5dd7bbbf23b4a9fcb7ae8961378b556147df3d42e2386?visible=true

from hdwallet.

artem03 avatar artem03 commented on May 24, 2024

Thanks, it will help me

from hdwallet.

farukterzioglu avatar farukterzioglu commented on May 24, 2024

to decode that kind of data, I use Nethereum heavily

some code to give an idea:

_contractBuilder = new ContractBuilder(abi, contractAddressVisible);
_contract = new Nethereum.Contracts.Contract(null, abi, contractAddressVisible);

...

public Function GetFunction(string functionName)
        {
            return _contract.GetFunction(functionName);
        }
        
public TReponse DecodeSimpleResponse<TReponse>(string functionName, string data)
        {
            Function function = GetFunction(functionName);
            return function.DecodeSimpleTypeOutput<TReponse>(data);
        }
        

from hdwallet.

sinaptech avatar sinaptech commented on May 24, 2024

May you please help me with some c# code how to transfer Trc20 contract balance to another trx wallet? both creating the transaction signing and broadcasting to the network

from hdwallet.

willbetter10 avatar willbetter10 commented on May 24, 2024

to decode that kind of data, I use Nethereum heavily

some code to give an idea:

_contractBuilder = new ContractBuilder(abi, contractAddressVisible);
_contract = new Nethereum.Contracts.Contract(null, abi, contractAddressVisible);

...

public Function GetFunction(string functionName)
        {
            return _contract.GetFunction(functionName);
        }
        
public TReponse DecodeSimpleResponse<TReponse>(string functionName, string data)
        {
            Function function = GetFunction(functionName);
            return function.DecodeSimpleTypeOutput<TReponse>(data);
        }
        

Hey, I have the similar problems, might need your help. Can you do me a favor?

from hdwallet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.