0

I'm trying to originate a contract in Tezos so I can test delegating to a baking account.

I was able to do this before the upgrade to babylonnet, but now that a script is required for the contract, I'm having difficulty with the tezos-client method.

For the body of the script, I took the contents of the file src/bin_client/test/contracts/entrypoints/manager.tz and replaced it in the position of the command. (Will include the gory details below.)

The client returns saying that the simulation fails, but I'm not sure what to fix. Is there anything wrong in the script, or did I enter the command incorrectly?

Thanks!!

== The command and reply ...

tezos@ip-10-0-51-4:~/source/tezos$ ./tezos-client -l originate contract bw_alphanet_customer_del transferring 16159 from bw_alphanet_customer running '

parameter (or (lambda %do unit (list operation)) (unit %default)); storage key_hash; code { UNPAIR ; IF_LEFT { # 'do' entrypoint # Assert no token was sent: # to send tokens, the default entry point should be used PUSH mutez 0 ; AMOUNT ; ASSERT_CMPEQ ; # Assert that the sender is the manager DUUP ; IMPLICIT_ACCOUNT ; ADDRESS ; SENDER ; ASSERT_CMPEQ ; # Execute the lambda argument UNIT ; EXEC ; PAIR ; } { # 'default' entrypoint DROP ; NIL operation ; PAIR ; } };' --delegate tz1bw1vPAQhAWkFWBD6naoS21GrVvrzhKy8G --burn-cap 0.257

0: <(editted by poster) NOT_A_LINK>:8732/network/version <<<<0: 200 OK { "chain_name": "TEZOS_ALPHANET_BABYLON_2019-09-27T07:43:32Z", "distributed_db_version": 0, "p2p_version": 0 } Warning:

             This is NOT the Tezos Mainnet.

 The node you are connecting to claims to be running on the
           Tezos Alphanet DEVELOPMENT NETWORK.
      Do NOT use your fundraiser keys on this network.
      Alphanet is a testing network, with free tokens.

1: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/protocols <<<<1: 200 OK { "protocol": "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS", "next_protocol": "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS" } 2: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/context/contracts/tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd/counter <<<<2: 200 OK "80039" 3: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/context/contracts/tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd/manager_key <<<<3: 200 OK null 4: <(editted by poster) NOT_A_LINK>/monitor/bootstrapped <<<<4: 200 OK { "block": "BMDKJ33KXKTQgthsCMeY4MEAunfnqKei4GZFcH3HSvk9zn7WZN9", "timestamp": "2019-11-14T18:01:40Z" } Node is bootstrapped, ready for injecting operations. 5: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/context/constants <<<<5: 200 OK { "proof_of_work_nonce_size": 8, "nonce_length": 32, "max_revelations_per_block": 32, "max_operation_data_length": 16384, "max_proposals_per_delegate": 20, "preserved_cycles": 3, "blocks_per_cycle": 2048, "blocks_per_commitment": 32, "blocks_per_roll_snapshot": 256, "blocks_per_voting_period": 8192, "time_between_blocks": [ "30", "40" ], "endorsers_per_block": 32, "hard_gas_limit_per_operation": "800000", "hard_gas_limit_per_block": "8000000", "proof_of_work_threshold": "70368744177663", "tokens_per_roll": "8000000000", "michelson_maximum_type_size": 1000, "seed_nonce_revelation_tip": "125000", "origination_size": 257, "block_security_deposit": "344000000", "endorsement_security_deposit": "43000000", "block_reward": "16000000", "endorsement_reward": "2000000", "cost_per_byte": "1000", "hard_storage_limit_per_operation": "60000", "test_chain_duration": "86400", "quorum_min": 3000, "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 24, "delay_per_missing_endorsement": "2" } 6: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/hash <<<<6: 200 OK "BMDKJ33KXKTQgthsCMeY4MEAunfnqKei4GZFcH3HSvk9zn7WZN9" 7: <(editted by poster) NOT_A_LINK>/chains/main/chain_id <<<<7: 200 OK "NetXUdfLh6Gm88t" 8: <(editted by poster) NOT_A_LINK>/chains/main/chain_id <<<<8: 200 OK "NetXUdfLh6Gm88t" 9: <(editted by poster) NOT_A_LINK>/chains/main/blocks/head/helpers/scripts/run_operation { "operation": { "branch": "BMDKJ33KXKTQgthsCMeY4MEAunfnqKei4GZFcH3HSvk9zn7WZN9", "contents": [ { "kind": "reveal", "source": "tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd", "fee": "0", "counter": "80040", "gas_limit": "10000", "storage_limit": "0", "public_key": "edpkvUMdU2QD4PXJXeyCB3Hy9woa5onBc6dep1wSDXvQ3bfxnV3S5q" }, { "kind": "origination", "source": "tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd", "fee": "0", "counter": "80041", "gas_limit": "800000", "storage_limit": "60000", "balance": "16159000000", "delegate": "tz1bw1vPAQhAWkFWBD6naoS21GrVvrzhKy8G", "script": { "code": [ { "prim": "parameter", "args": [ { "prim": "or", "args": [ { "prim": "lambda", "args": [ { "prim": "unit" }, { "prim": "list", "args": [ { "prim": "operation" } ] } ], "annots": [ "%do" ] }, { "prim": "unit", "annots": [ "%default" ] } ] } ] }, { "prim": "storage", "args": [ { "prim": "key_hash" } ] }, { "prim": "code", "args": [ [ [ [ { "prim": "DUP" }, { "prim": "CAR" }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ], { "prim": "IF_LEFT", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "0" } ] }, { "prim": "AMOUNT" }, [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ], { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ], [ { "prim": "DIP", "args": [ [ { "prim": "DUP" } ] ] }, { "prim": "SWAP" } ], { "prim": "IMPLICIT_ACCOUNT" }, { "prim": "ADDRESS" }, { "prim": "SENDER" }, [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ], { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ], { "prim": "UNIT" }, { "prim": "EXEC" }, { "prim": "PAIR" } ], [ { "prim": "DROP" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": { "prim": "Unit" } } } ], "signature": "edsigtXomBKi5CTRf5cjATJWSyaRvhfYNHqSUGrn4SdbYRcGwQrUGjzEfQDTuqHhuA8b2d8NarZjz8TRf65WkpQmo423BtomS8Q" }, "chain_id": "NetXUdfLh6Gm88t" } <<<<9: 200 OK { "contents": [ { "kind": "reveal", "source": "tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd", "fee": "0", "counter": "80040", "gas_limit": "10000", "storage_limit": "0", "public_key": "edpkvUMdU2QD4PXJXeyCB3Hy9woa5onBc6dep1wSDXvQ3bfxnV3S5q", "metadata": { "balance_updates": [], "operation_result": { "status": "applied", "consumed_gas": "10000" } } }, { "kind": "origination", "source": "tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd", "fee": "0", "counter": "80041", "gas_limit": "800000", "storage_limit": "60000", "balance": "16159000000", "delegate": "tz1bw1vPAQhAWkFWBD6naoS21GrVvrzhKy8G", "script": { "code": [ { "prim": "parameter", "args": [ { "prim": "or", "args": [ { "prim": "lambda", "args": [ { "prim": "unit" }, { "prim": "list", "args": [ { "prim": "operation" } ] } ], "annots": [ "%do" ] }, { "prim": "unit", "annots": [ "%default" ] } ] } ] }, { "prim": "storage", "args": [ { "prim": "key_hash" } ] }, { "prim": "code", "args": [ [ [ [ { "prim": "DUP" }, { "prim": "CAR" }, { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] } ] ], { "prim": "IF_LEFT", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "mutez" }, { "int": "0" } ] }, { "prim": "AMOUNT" }, [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ], { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ], [ { "prim": "DIP", "args": [ [ { "prim": "DUP" } ] ] }, { "prim": "SWAP" } ], { "prim": "IMPLICIT_ACCOUNT" }, { "prim": "ADDRESS" }, { "prim": "SENDER" }, [ [ { "prim": "COMPARE" }, { "prim": "EQ" } ], { "prim": "IF", "args": [ [], [ [ { "prim": "UNIT" }, { "prim": "FAILWITH" } ] ] ] } ], { "prim": "UNIT" }, { "prim": "EXEC" }, { "prim": "PAIR" } ], [ { "prim": "DROP" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": { "prim": "Unit" } }, "metadata": { "balance_updates": [], "operation_result": { "status": "failed", "errors": [ { "kind": "permanent", "id": "proto.005-PsBabyM1.michelson_v1.ill_typed_data", "expected_type": { "prim": "key_hash" }, "ill_typed_expression": { "prim": "Unit" } }, { "kind": "permanent", "id": "proto.005-PsBabyM1.invalidSyntacticConstantError", "location": 0, "expectedForm": { "prim": "key_hash" }, "wrongExpression": { "prim": "Unit" } }, { "kind": "permanent", "id": "proto.005-PsBabyM1.michelson_v1.invalid_expression_kind", "location": 0, "expected_kinds": [ "string", "bytes" ], "wrong_kind": "primitiveApplication" } ] } } } ] } This simulation failed: Manager signed operations: From: tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd Fee to the baker: ꜩ0 Expected counter: 80040 Gas limit: 10000 Storage limit: 0 bytes Revelation of manager public key: Contract: tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd Key: edpkvUMdU2QD4PXJXeyCB3Hy9woa5onBc6dep1wSDXvQ3bfxnV3S5q This revelation was successfully applied Consumed gas: 10000 Manager signed operations: From: tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd Fee to the baker: ꜩ0 Expected counter: 80041 Gas limit: 800000 Storage limit: 60000 bytes Origination: From: tz1Ux9UPkoVdwRVNJPzwtPsC4Rfm9ppTquxd Credit: ꜩ16159 Script: { parameter (or (lambda %do unit (list operation)) (unit %default)) ; storage key_hash ; code { UNPAIR ; IF_LEFT { PUSH mutez 0 ; AMOUNT ; ASSERT_CMPEQ ; DUP 2 ; IMPLICIT_ACCOUNT ; ADDRESS ; SENDER ; ASSERT_CMPEQ ; UNIT ; EXEC ; PAIR } { DROP ; NIL operation ; PAIR } } } Initial storage: Unit Delegate: tz1bw1vPAQhAWkFWBD6naoS21GrVvrzhKy8G This operation FAILED.

Ill typed data: 1: Unit is not an expression of type key_hash At line 1 characters 0 to 4, value Unit is invalid for type key_hash. At line 1 characters 0 to 4, unexpected primitive, only a string or a byte sequence can be used here. Fatal error: origination simulation failed

0

You have to provide the contract storage which should be the address of the tz account managing the smart contract. The commmand-line option is --init.

That being said, note that since Babylon, originating an account is not required anymore for delegating tokens; tz accounts can now delegate directly.

| improve this answer | |
  • Thanks for the answer. What I was really after was to be able to delegate tokens, so that's perfect. – El Diablo Nov 15 '19 at 14:46
  • Just in case anyone was trying the same thing as I was, you can use tezos-client to do the direct delegation; ./tezos-client set delegate for bw_alphanet_customer to bw_alphanet --fee 1.0 --burn-cap 0.537 In this case bw_alphanet_customer and bw_alphanet are both accounts known to my local tezos-client. – El Diablo Nov 15 '19 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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