text: 
  // AUTO GENERATED by vnxcppcodegen
  
  #include <mmx/contract/package.hxx>
  #include <mmx/contract/PuzzleLock.hxx>
  #include <mmx/ChainParams.hxx>
  #include <mmx/Context.hxx>
  #include <mmx/Contract.hxx>
  #include <mmx/Contract_calc_cost.hxx>
  #include <mmx/Contract_calc_cost_return.hxx>
  #include <mmx/Contract_calc_hash.hxx>
  #include <mmx/Contract_calc_hash_return.hxx>
  #include <mmx/Contract_get_dependency.hxx>
  #include <mmx/Contract_get_dependency_return.hxx>
  #include <mmx/Contract_get_owner.hxx>
  #include <mmx/Contract_get_owner_return.hxx>
  #include <mmx/Contract_get_parties.hxx>
  #include <mmx/Contract_get_parties_return.hxx>
  #include <mmx/Contract_is_spendable.hxx>
  #include <mmx/Contract_is_spendable_return.hxx>
  #include <mmx/Contract_is_valid.hxx>
  #include <mmx/Contract_is_valid_return.hxx>
  #include <mmx/Contract_transfer.hxx>
  #include <mmx/Contract_transfer_return.hxx>
  #include <mmx/Contract_validate.hxx>
  #include <mmx/Contract_validate_return.hxx>
  #include <mmx/Operation.hxx>
  #include <mmx/addr_t.hpp>
  #include <mmx/contract/Locked.hxx>
  #include <mmx/contract/Locked_calc_cost.hxx>
  #include <mmx/contract/Locked_calc_cost_return.hxx>
  #include <mmx/contract/Locked_calc_hash.hxx>
  #include <mmx/contract/Locked_calc_hash_return.hxx>
  #include <mmx/contract/Locked_get_dependency.hxx>
  #include <mmx/contract/Locked_get_dependency_return.hxx>
  #include <mmx/contract/Locked_get_owner.hxx>
  #include <mmx/contract/Locked_get_owner_return.hxx>
  #include <mmx/contract/Locked_get_parties.hxx>
  #include <mmx/contract/Locked_get_parties_return.hxx>
  #include <mmx/contract/Locked_is_spendable.hxx>
  #include <mmx/contract/Locked_is_spendable_return.hxx>
  #include <mmx/contract/Locked_is_valid.hxx>
  #include <mmx/contract/Locked_is_valid_return.hxx>
  #include <mmx/contract/Locked_validate.hxx>
  #include <mmx/contract/Locked_validate_return.hxx>
  #include <mmx/contract/PuzzleLock_calc_cost.hxx>
  #include <mmx/contract/PuzzleLock_calc_cost_return.hxx>
  #include <mmx/contract/PuzzleLock_calc_hash.hxx>
  #include <mmx/contract/PuzzleLock_calc_hash_return.hxx>
  #include <mmx/contract/PuzzleLock_get_dependency.hxx>
  #include <mmx/contract/PuzzleLock_get_dependency_return.hxx>
  #include <mmx/contract/PuzzleLock_get_parties.hxx>
  #include <mmx/contract/PuzzleLock_get_parties_return.hxx>
  #include <mmx/contract/PuzzleLock_is_valid.hxx>
  #include <mmx/contract/PuzzleLock_is_valid_return.hxx>
  #include <mmx/contract/PuzzleLock_validate.hxx>
  #include <mmx/contract/PuzzleLock_validate_return.hxx>
  #include <mmx/hash_t.hpp>
  #include <mmx/pubkey_t.hpp>
  #include <mmx/tx_out_t.hxx>
  
  #include <vnx/vnx.h>
  
  
  namespace mmx {
  namespace contract {
  
  
  const vnx::Hash64 PuzzleLock::VNX_TYPE_HASH(0xf33097b29a62c755ull);
  const vnx::Hash64 PuzzleLock::VNX_CODE_HASH(0xab27c6539a99ea14ull);
  
  vnx::Hash64 PuzzleLock::get_type_hash() const {
  	return VNX_TYPE_HASH;
  }
  
  std::string PuzzleLock::get_type_name() const {
  	return "mmx.contract.PuzzleLock";
  }
  
  const vnx::TypeCode* PuzzleLock::get_type_code() const {
  	return mmx::contract::vnx_native_type_code_PuzzleLock;
  }
  
  std::shared_ptr<PuzzleLock> PuzzleLock::create() {
  	return std::make_shared<PuzzleLock>();
  }
  
  std::shared_ptr<vnx::Value> PuzzleLock::clone() const {
  	return std::make_shared<PuzzleLock>(*this);
  }
  
  void PuzzleLock::read(vnx::TypeInput& _in, const vnx::TypeCode* _type_code, const uint16_t* _code) {
  	vnx::read(_in, *this, _type_code, _code);
  }
  
  void PuzzleLock::write(vnx::TypeOutput& _out, const vnx::TypeCode* _type_code, const uint16_t* _code) const {
  	vnx::write(_out, *this, _type_code, _code);
  }
  
  void PuzzleLock::accept(vnx::Visitor& _visitor) const {
  	const vnx::TypeCode* _type_code = mmx::contract::vnx_native_type_code_PuzzleLock;
  	_visitor.type_begin(*_type_code);
  	_visitor.type_field(_type_code->fields[0], 0); vnx::accept(_visitor, version);
  	_visitor.type_field(_type_code->fields[1], 1); vnx::accept(_visitor, owner);
  	_visitor.type_field(_type_code->fields[2], 2); vnx::accept(_visitor, chain_height);
  	_visitor.type_field(_type_code->fields[3], 3); vnx::accept(_visitor, delta_height);
  	_visitor.type_field(_type_code->fields[4], 4); vnx::accept(_visitor, puzzle);
  	_visitor.type_field(_type_code->fields[5], 5); vnx::accept(_visitor, target);
  	_visitor.type_end(*_type_code);
  }
  
  void PuzzleLock::write(std::ostream& _out) const {
  	_out << "{\"__type\": \"mmx.contract.PuzzleLock\"";
  	_out << ", \"version\": "; vnx::write(_out, version);
  	_out << ", \"owner\": "; vnx::write(_out, owner);
  	_out << ", \"chain_height\": "; vnx::write(_out, chain_height);
  	_out << ", \"delta_height\": "; vnx::write(_out, delta_height);
  	_out << ", \"puzzle\": "; vnx::write(_out, puzzle);
  	_out << ", \"target\": "; vnx::write(_out, target);
  	_out << "}";
  }
  
  void PuzzleLock::read(std::istream& _in) {
  	if(auto _json = vnx::read_json(_in)) {
  		from_object(_json->to_object());
  	}
  }
  
  vnx::Object PuzzleLock::to_object() const {
  	vnx::Object _object;
  	_object["__type"] = "mmx.contract.PuzzleLock";
  	_object["version"] = version;
  	_object["owner"] = owner;
  	_object["chain_height"] = chain_height;
  	_object["delta_height"] = delta_height;
  	_object["puzzle"] = puzzle;
  	_object["target"] = target;
  	return _object;
  }
  
  void PuzzleLock::from_object(const vnx::Object& _object) {
  	for(const auto& _entry : _object.field) {
  		if(_entry.first == "chain_height") {
  			_entry.second.to(chain_height);
  		} else if(_entry.first == "delta_height") {
  			_entry.second.to(delta_height);
  		} else if(_entry.first == "owner") {
  			_entry.second.to(owner);
  		} else if(_entry.first == "puzzle") {
  			_entry.second.to(puzzle);
  		} else if(_entry.first == "target") {
  			_entry.second.to(target);
  		} else if(_entry.first == "version") {
  			_entry.second.to(version);
  		}
  	}
  }
  
  vnx::Variant PuzzleLock::get_field(const std::string& _name) const {
  	if(_name == "version") {
  		return vnx::Variant(version);
  	}
  	if(_name == "owner") {
  		return vnx::Variant(owner);
  	}
  	if(_name == "chain_height") {
  		return vnx::Variant(chain_height);
  	}
  	if(_name == "delta_height") {
  		return vnx::Variant(delta_height);
  	}
  	if(_name == "puzzle") {
  		return vnx::Variant(puzzle);
  	}
  	if(_name == "target") {
  		return vnx::Variant(target);
  	}
  	return vnx::Variant();
  }
  
  void PuzzleLock::set_field(const std::string& _name, const vnx::Variant& _value) {
  	if(_name == "version") {
  		_value.to(version);
  	} else if(_name == "owner") {
  		_value.to(owner);
  	} else if(_name == "chain_height") {
  		_value.to(chain_height);
  	} else if(_name == "delta_height") {
  		_value.to(delta_height);
  	} else if(_name == "puzzle") {
  		_value.to(puzzle);
  	} else if(_name == "target") {
  		_value.to(target);
  	}
  }
  
  /// \private
  std::ostream& operator<<(std::ostream& _out, const PuzzleLock& _value) {
  	_value.write(_out);
  	return _out;
  }
  
  /// \private
  std::istream& operator>>(std::istream& _in, PuzzleLock& _value) {
  	_value.read(_in);
  	return _in;
  }
  
  const vnx::TypeCode* PuzzleLock::static_get_type_code() {
  	const vnx::TypeCode* type_code = vnx::get_type_code(VNX_TYPE_HASH);
  	if(!type_code) {
  		type_code = vnx::register_type_code(static_create_type_code());
  	}
  	return type_code;
  }
  
  std::shared_ptr<vnx::TypeCode> PuzzleLock::static_create_type_code() {
  	auto type_code = std::make_shared<vnx::TypeCode>();
  	type_code->name = "mmx.contract.PuzzleLock";
  	type_code->type_hash = vnx::Hash64(0xf33097b29a62c755ull);
  	type_code->code_hash = vnx::Hash64(0xab27c6539a99ea14ull);
  	type_code->is_native = true;
  	type_code->is_class = true;
  	type_code->native_size = sizeof(::mmx::contract::PuzzleLock);
  	type_code->parents.resize(2);
  	type_code->parents[0] = ::mmx::contract::Locked::static_get_type_code();
  	type_code->parents[1] = ::mmx::Contract::static_get_type_code();
  	type_code->create_value = []() -> std::shared_ptr<vnx::Value> { return std::make_shared<PuzzleLock>(); };
  	type_code->methods.resize(23);
  	type_code->methods[0] = ::mmx::Contract_calc_cost::static_get_type_code();
  	type_code->methods[1] = ::mmx::Contract_calc_hash::static_get_type_code();
  	type_code->methods[2] = ::mmx::Contract_get_dependency::static_get_type_code();
  	type_code->methods[3] = ::mmx::Contract_get_owner::static_get_type_code();
  	type_code->methods[4] = ::mmx::Contract_get_parties::static_get_type_code();
  	type_code->methods[5] = ::mmx::Contract_is_spendable::static_get_type_code();
  	type_code->methods[6] = ::mmx::Contract_is_valid::static_get_type_code();
  	type_code->methods[7] = ::mmx::Contract_transfer::static_get_type_code();
  	type_code->methods[8] = ::mmx::Contract_validate::static_get_type_code();
  	type_code->methods[9] = ::mmx::contract::Locked_calc_cost::static_get_type_code();
  	type_code->methods[10] = ::mmx::contract::Locked_calc_hash::static_get_type_code();
  	type_code->methods[11] = ::mmx::contract::Locked_get_dependency::static_get_type_code();
  	type_code->methods[12] = ::mmx::contract::Locked_get_owner::static_get_type_code();
  	type_code->methods[13] = ::mmx::contract::Locked_get_parties::static_get_type_code();
  	type_code->methods[14] = ::mmx::contract::Locked_is_spendable::static_get_type_code();
  	type_code->methods[15] = ::mmx::contract::Locked_is_valid::static_get_type_code();
  	type_code->methods[16] = ::mmx::contract::Locked_validate::static_get_type_code();
  	type_code->methods[17] = ::mmx::contract::PuzzleLock_calc_cost::static_get_type_code();
  	type_code->methods[18] = ::mmx::contract::PuzzleLock_calc_hash::static_get_type_code();
  	type_code->methods[19] = ::mmx::contract::PuzzleLock_get_dependency::static_get_type_code();
  	type_code->methods[20] = ::mmx::contract::PuzzleLock_get_parties::static_get_type_code();
  	type_code->methods[21] = ::mmx::contract::PuzzleLock_is_valid::static_get_type_code();
  	type_code->methods[22] = ::mmx::contract::PuzzleLock_validate::static_get_type_code();
  	type_code->fields.resize(6);
  	{
  		auto& field = type_code->fields[0];
  		field.data_size = 4;
  		field.name = "version";
  		field.code = {3};
  	}
  	{
  		auto& field = type_code->fields[1];
  		field.is_extended = true;
  		field.name = "owner";
  		field.code = {11, 32, 1};
  	}
  	{
  		auto& field = type_code->fields[2];
  		field.is_extended = true;
  		field.name = "chain_height";
  		field.code = {33, 3};
  	}
  	{
  		auto& field = type_code->fields[3];
  		field.is_extended = true;
  		field.name = "delta_height";
  		field.code = {33, 3};
  	}
  	{
  		auto& field = type_code->fields[4];
  		field.is_extended = true;
  		field.name = "puzzle";
  		field.code = {16};
  	}
  	{
  		auto& field = type_code->fields[5];
  		field.is_extended = true;
  		field.name = "target";
  		field.code = {11, 32, 1};
  	}
  	type_code->build();
  	return type_code;
  }
  
  std::shared_ptr<vnx::Value> PuzzleLock::vnx_call_switch(std::shared_ptr<const vnx::Value> _method) {
  	switch(_method->get_type_hash()) {
  		case 0xb23d047adf8b2612ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_calc_cost>(_method);
  			auto _return_value = ::mmx::Contract_calc_cost_return::create();
  			_return_value->_ret_0 = calc_cost(_args->params);
  			return _return_value;
  		}
  		case 0x622fcf1cba1952edull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_calc_hash>(_method);
  			auto _return_value = ::mmx::Contract_calc_hash_return::create();
  			_return_value->_ret_0 = calc_hash();
  			return _return_value;
  		}
  		case 0x989dd3da956ebbd0ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_get_dependency>(_method);
  			auto _return_value = ::mmx::Contract_get_dependency_return::create();
  			_return_value->_ret_0 = get_dependency();
  			return _return_value;
  		}
  		case 0x8fe2c64fdc8f0680ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_get_owner>(_method);
  			auto _return_value = ::mmx::Contract_get_owner_return::create();
  			_return_value->_ret_0 = get_owner();
  			return _return_value;
  		}
  		case 0x6f7a46e940a18a57ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_get_parties>(_method);
  			auto _return_value = ::mmx::Contract_get_parties_return::create();
  			_return_value->_ret_0 = get_parties();
  			return _return_value;
  		}
  		case 0xd12879d16cac3d5cull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_is_spendable>(_method);
  			auto _return_value = ::mmx::Contract_is_spendable_return::create();
  			_return_value->_ret_0 = is_spendable(_args->utxo, _args->context);
  			return _return_value;
  		}
  		case 0xe3adf9b29a723217ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_is_valid>(_method);
  			auto _return_value = ::mmx::Contract_is_valid_return::create();
  			_return_value->_ret_0 = is_valid();
  			return _return_value;
  		}
  		case 0xd41bec275faff1ffull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_transfer>(_method);
  			auto _return_value = ::mmx::Contract_transfer_return::create();
  			transfer(_args->new_owner);
  			return _return_value;
  		}
  		case 0xc2126a44901c8d52ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::Contract_validate>(_method);
  			auto _return_value = ::mmx::Contract_validate_return::create();
  			_return_value->_ret_0 = validate(_args->operation, _args->context);
  			return _return_value;
  		}
  		case 0x4d220deaf420a61aull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_calc_cost>(_method);
  			auto _return_value = ::mmx::contract::Locked_calc_cost_return::create();
  			_return_value->_ret_0 = calc_cost(_args->params);
  			return _return_value;
  		}
  		case 0x9d30c68c91b2d2e5ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_calc_hash>(_method);
  			auto _return_value = ::mmx::contract::Locked_calc_hash_return::create();
  			_return_value->_ret_0 = calc_hash();
  			return _return_value;
  		}
  		case 0xf155dff11fe1aed3ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_get_dependency>(_method);
  			auto _return_value = ::mmx::contract::Locked_get_dependency_return::create();
  			_return_value->_ret_0 = get_dependency();
  			return _return_value;
  		}
  		case 0x70fdcfdff7248688ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_get_owner>(_method);
  			auto _return_value = ::mmx::contract::Locked_get_owner_return::create();
  			_return_value->_ret_0 = get_owner();
  			return _return_value;
  		}
  		case 0xb634d38d89230559ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_get_parties>(_method);
  			auto _return_value = ::mmx::contract::Locked_get_parties_return::create();
  			_return_value->_ret_0 = get_parties();
  			return _return_value;
  		}
  		case 0xa904459ea0b4fdddull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_is_spendable>(_method);
  			auto _return_value = ::mmx::contract::Locked_is_spendable_return::create();
  			_return_value->_ret_0 = is_spendable(_args->utxo, _args->context);
  			return _return_value;
  		}
  		case 0x37ed54e91a14f1acull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_is_valid>(_method);
  			auto _return_value = ::mmx::contract::Locked_is_valid_return::create();
  			_return_value->_ret_0 = is_valid();
  			return _return_value;
  		}
  		case 0x1652c71f107a4ee9ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::Locked_validate>(_method);
  			auto _return_value = ::mmx::contract::Locked_validate_return::create();
  			_return_value->_ret_0 = validate(_args->operation, _args->context);
  			return _return_value;
  		}
  		case 0xef887e5b77e465b5ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_calc_cost>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_calc_cost_return::create();
  			_return_value->_ret_0 = calc_cost(_args->params);
  			return _return_value;
  		}
  		case 0x3f9ab53d1276114aull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_calc_hash>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_calc_hash_return::create();
  			_return_value->_ret_0 = calc_hash();
  			return _return_value;
  		}
  		case 0xc83c186ef34eeb1bull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_get_dependency>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_get_dependency_return::create();
  			_return_value->_ret_0 = get_dependency();
  			return _return_value;
  		}
  		case 0xa0530fd9cb9a9c62ull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_get_parties>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_get_parties_return::create();
  			_return_value->_ret_0 = get_parties();
  			return _return_value;
  		}
  		case 0xf4969d5cbc33744eull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_is_valid>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_is_valid_return::create();
  			_return_value->_ret_0 = is_valid();
  			return _return_value;
  		}
  		case 0xd5290eaab65dcb0bull: {
  			auto _args = std::static_pointer_cast<const ::mmx::contract::PuzzleLock_validate>(_method);
  			auto _return_value = ::mmx::contract::PuzzleLock_validate_return::create();
  			_return_value->_ret_0 = validate(_args->operation, _args->context);
  			return _return_value;
  		}
  	}
  	return nullptr;
  }
  
  
  } // namespace mmx
  } // namespace contract
  
  
  namespace vnx {
  
  void read(TypeInput& in, ::mmx::contract::PuzzleLock& value, const TypeCode* type_code, const uint16_t* code) {
  	if(code) {
  		switch(code[0]) {
  			case CODE_OBJECT:
  			case CODE_ALT_OBJECT: {
  				Object tmp;
  				vnx::read(in, tmp, type_code, code);
  				value.from_object(tmp);
  				return;
  			}
  			case CODE_DYNAMIC:
  			case CODE_ALT_DYNAMIC:
  				vnx::read_dynamic(in, value);
  				return;
  		}
  	}
  	if(!type_code) {
  		vnx::skip(in, type_code, code);
  		return;
  	}
  	if(code) {
  		switch(code[0]) {
  			case CODE_STRUCT: type_code = type_code->depends[code[1]]; break;
  			case CODE_ALT_STRUCT: type_code = type_code->depends[vnx::flip_bytes(code[1])]; break;
  			default: {
  				vnx::skip(in, type_code, code);
  				return;
  			}
  		}
  	}
  	const char* const _buf = in.read(type_code->total_field_size);
  	if(type_code->is_matched) {
  		if(const auto* const _field = type_code->field_map[0]) {
  			vnx::read_value(_buf + _field->offset, value.version, _field->code.data());
  		}
  	}
  	for(const auto* _field : type_code->ext_fields) {
  		switch(_field->native_index) {
  			case 1: vnx::read(in, value.owner, type_code, _field->code.data()); break;
  			case 2: vnx::read(in, value.chain_height, type_code, _field->code.data()); break;
  			case 3: vnx::read(in, value.delta_height, type_code, _field->code.data()); break;
  			case 4: vnx::read(in, value.puzzle, type_code, _field->code.data()); break;
  			case 5: vnx::read(in, value.target, type_code, _field->code.data()); break;
  			default: vnx::skip(in, type_code, _field->code.data());
  		}
  	}
  }
  
  void write(TypeOutput& out, const ::mmx::contract::PuzzleLock& value, const TypeCode* type_code, const uint16_t* code) {
  	if(code && code[0] == CODE_OBJECT) {
  		vnx::write(out, value.to_object(), nullptr, code);
  		return;
  	}
  	if(!type_code || (code && code[0] == CODE_ANY)) {
  		type_code = mmx::contract::vnx_native_type_code_PuzzleLock;
  		out.write_type_code(type_code);
  		vnx::write_class_header<::mmx::contract::PuzzleLock>(out);
  	}
  	else if(code && code[0] == CODE_STRUCT) {
  		type_code = type_code->depends[code[1]];
  	}
  	char* const _buf = out.write(4);
  	vnx::write_value(_buf + 0, value.version);
  	vnx::write(out, value.owner, type_code, type_code->fields[1].code.data());
  	vnx::write(out, value.chain_height, type_code, type_code->fields[2].code.data());
  	vnx::write(out, value.delta_height, type_code, type_code->fields[3].code.data());
  	vnx::write(out, value.puzzle, type_code, type_code->fields[4].code.data());
  	vnx::write(out, value.target, type_code, type_code->fields[5].code.data());
  }
  
  void read(std::istream& in, ::mmx::contract::PuzzleLock& value) {
  	value.read(in);
  }
  
  void write(std::ostream& out, const ::mmx::contract::PuzzleLock& value) {
  	value.write(out);
  }
  
  void accept(Visitor& visitor, const ::mmx::contract::PuzzleLock& value) {
  	value.accept(visitor);
  }
  
  } // vnx
  