0

I'm trying to encode some parameters and I've noticed all the encoders in the ABI project. Essentially, I want the equivalent to abi.encodeParameter(type, value) in Nethereum? Is there an easy solution to obtaining this with the parameter attributes on the model?

1

You can encode them like this, ParameterEncoder is in the namespace Nethereum.ABI.FunctionEncoding

 public byte[] GetABIParamsEncoded<T>(T functionInput)
 {
            var type = typeof(T);
            return new ParametersEncoder().EncodeParametersFromTypeAttributes(type, functionInput);
  }

This simpler function will be available in 3.1 in the ABIEncode class

0

I think this is what I was looking for will update if so

 var encoder = new ConstructorCallEncoder();  
 var result = encoder.EncodeRequest<datamodel>(datamodel, "");
  • 1
    Yes that achieves it as the ConstructorCallEncoder, does not have any signature :) – Juan Blanco Dec 13 '18 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.