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?
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
I think this is what I was looking for will update if so
var encoder = new ConstructorCallEncoder();
var result = encoder.EncodeRequest<datamodel>(datamodel, "");
-
1Yes that achieves it as the ConstructorCallEncoder, does not have any signature :) – Juan Blanco Dec 13 '18 at 9:35