AltMe icon indicating copy to clipboard operation
AltMe copied to clipboard

How to convert following michelson sentences in Micheline?

Open hawkbee1 opened this issue 2 years ago • 1 comments

        final parameters = token.isFA1
      ? '''(Pair "${keyStore.publicKeyHash}" (Pair "${state.withdrawalAddress}" $amount))'''
      : '''{Pair "${keyStore.publicKeyHash}" {Pair "${state.withdrawalAddress}" (Pair ${int.parse(token.tokenId ?? '0')} $amount)}}''';

An hint on finding Micheline parameters with breakpoint on beacon transaction: image

hawkbee1 avatar May 23 '23 08:05 hawkbee1

example (not tested yet):


import 'package:tezart/src/micheline_encoder.dart';

void main() {
  final michelsonCode = """
    parameter int;
    storage int;
    code {
      CAR;
      SWAP;
      ADD;
      NIL operation;
      PAIR
    }
  """;

  final michelineJson = MichelineEncoder.parse(michelsonCode);
  print(michelineJson);

  final michelineBinary = MichelineEncoder.encode(michelineJson);
  print(michelineBinary.toHex());
}

TalebRafiepour avatar May 23 '23 12:05 TalebRafiepour