0

I'm hitting an issue trying to originate a contract using tzgo, where by the RPC request is getting an invalid_primitive_namespace error.

I’m compiling my ligo contract to json, which loads fine with tzgo for populating the code section. The issue (I think) I’m hitting is with the initial storage.

The storage for this FA2 style contract is an oracle address, some bigmaps and a set. If I ask ligo to spit out the value for the initial contract (an oracle address and all other things empty) I get:

(Pair (Pair (Pair {} {}) {} "tz1YYBnLs471SKKReLn8nV47Tqh9VDgPoE7F") {})

Which in tzgo micheline I’m currently encoding as:

storage := micheline.NewPair(
    micheline.NewCode(micheline.T_PAIR,
        micheline.NewPair(
            micheline.NewSeq(),
            micheline.NewSeq(),
        ),
        micheline.NewSeq(),
        micheline.NewString(oracle.String()),
    ),
    micheline.NewSeq(),
)

I’m using an empty sequence for all the empty big maps and sets, and the only other thing of note is that we have a three entry pair, which I’m instantiating as NewCode(T_PAIR…) which should give it the correct variadic opcode I believe.

But when I call Originate with this:

contract := contract.NewEmptyContract(rpcClient)
code := micheline.Code{}
err = code.UnmarshalJSON(codedata)
if err != nil {
    return "", fmt.Errorf("failed to decode contract: %v", err)
}
script := micheline.Script{
    Code: code,
    Storage: initial_storage,
}
contract.WithScript(&script)

receipt, err := contract.Deploy(ctx, nil)

I get an error of invalid_primitive_namespace - so I’m doing something wrong, but I’m not sure what.

If I don’t specify the initial storage then I get a different error, so I assume from that the error is with the initial storage.

I did a quick look at what taquito does for submitting operations, and I note that it has storage distinct from script when it submits an operation, but looking at the RPC references for injection/operation it doesn’t give me a clue as to whether one is better than the other, other than I have successfully originated contracts using taquito before.

Can anyone spot what I'm doing wrong?

1 Answer 1

1

It looks like you are using Micheline type opcodes in a Micheline value. Try to replace micheline.T_PAIR with micheline.D_PAIR or use micheline.NewCombPair() for pairs with more than 2 arguments.

1
  • That was it - many thanks! Oct 19, 2022 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.