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?
2 Answers
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– Juan Blanco2018-12-13 09:35:13 +00:00Commented Dec 13, 2018 at 9:35