Ask Your Question
0

How do I compile and test a tez contract?

asked 2017-05-06 21:26:05 -0500

hadils gravatar image

I am running native Mac OS X. I have started tezos-node in sandbox mode successfully. I have a contract, but want to compile and test it.

edit retag flag offensive close delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2017-05-07 06:16:34 -0500

hnrgrgr gravatar image

We do not disclose the secret key of the bootstrap1 account anymore and we use a proper faucet instead, so the instructions should be slightly adapted:

# generate a key named 'justatest'
./tezos-client gen keys justatest
# give it some free funds from the faucet
./tezos-client originate free account my_account for justatest
# load the program
./tezos-client remember program noop file:scripts/noop.tez
# typecheck it, if you're curious
./tezos-client typecheck program noop
# then originate it, so you can interact with it
# (yes there is a typo in transfering, it'll be fixed)
./tezos-client originate contract noop \
      for justatest transfering 1000 from my_account \
      running noop
# you can send it a transaction by providing the right argument (Unit)
./tezos-client transfer 10 from my_account to noop -arg "Unit"
edit flag offensive delete publish link more
1

answered 2017-05-06 22:33:20 -0500

tezos gravatar image

You can start a node in sandbox mode or use the testnet. To run the sandbox

./tezos-node run --sandbox --rpc-addr 127.0.0.1:8732

then put your contract in a .tez file for convenience. We'll use the no-op contract which does nothing:

parameter unit
code
  { # This is a noop contract
     CDR ; UNIT ; PAIR
  }
return unit

Now using the Tezos client:

# generate a key named 'justatest'
./tezos-client gen keys justatest
# give it some funds from the bootstrap contract
./tezos-client transfer 1000 from bootstrap1 to justatest
# load the program
./tezos-client remember program noop file:scripts/noop.tez
# typecheck it, if you're curious
./tezos-client typecheck program noop
# then originate it, so you can interact with it
# (yes there is a typo in transfering, it'll be fixed)
./tezos-client originate contract noop \
      for justatest transfering 1000 from bootstrap1 \
      running noop
# you can send it a transaction by providing the right argument (Unit)
./tezos-client transfer 10 from bootstrap1 to noop -arg "Unit"
edit flag offensive delete publish link more

Comments

The instructions should be slightly amended my answer. (I did not find how to use monospace in this comment fields...)

hnrgrgr ( 2017-05-07 06:13:27 -0500 )edit

The transfer and remember program client commands do not work.

hadils ( 2017-05-08 18:40:16 -0500 )edit

Ah sorry, you need to activate a protocol first, take a look at test/test_basic.sh

tezos ( 2017-05-09 00:54:46 -0500 )edit
0

answered 2017-05-09 11:08:57 -0500

hadils gravatar image

I adapted the test/test-basic.sh script to load my own .tz file and it works well. Unfortunately, timestamp subtraction is still not available yet.

edit flag offensive delete publish link more

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

Add answer

[hide preview]

Question tools

Follow
3 followers

Stats

Asked: 2017-05-06 21:26:05 -0500

Seen: 1,818 times

Last updated: May 09