function getEncoding(messageSyntax, messageType, payload) {
const source = `syntax = "proto2";
package default_package;
${messageSyntax}`;
const root = protobuf.parse(source).root;
const topLevelTypes = root.nested.default_package.nested;
const type = topLevelTypes[messageType];
const error = type.verify(payload);
if (error !== null) {
throw new Error(error);
}
const message = type.create(payload);
const buffer = type.encode(message).finish();
console.log(buffer);
return [...buffer].map((n) => n.toString(16).padStart(2, "0")).join(" ");
}