Smart Contract Operations

Note: Tezster supports smart contracts in Michelson only.

Smart Contract With Single Entry Point

Deploy a Contract

You can deploy a smart contract in non-interactive mode or interactive mode.

To deploy a smart contract put the Michelson code in a file (eg.- testcontract.tz) Code e.g.-

parameter string;
storage string;
code {CAR; NIL operation; PAIR;};

Code Description : This code stores a string to the storage.

  • Deploy smart contract in interactive mode: (Use "-i" flag to use interactive mode)

To deploy the smart contract on tezos network, run:

tezster deploy -i
eg.- tezster deploy -i
? Enter contract label: simplecontract
? Enter absolute path of contract(.tz) file: ./testcontract.tz
? Enter initial storage value: "good morning"
? Enter account label/pkh: bootstrap1
? Enter amount: (optional, default is 0) 0
? Enter operation fee: (optional, default is 100000) 100000
? Enter storage limit: (optional, default is 10000) 10000
? Enter gas limit: (optional, default is 500000) 500000

If the operation is successful, you'll receive a contract address (KT1***).

Note: Amount, operation fee, storage limit and gas limit are optional fields with default value.

  • Deploy smart contract in non-interactive mode:

To deploy the smart contract on tezos network, run:

tezster deploy <contract-label> <contract-file-path> <initial-storage> <account> <--optional amount>
eg.- tezster deploy simplecontract ./testcontract.tz "\"good morning\"" bootstrap1

If the operation is successful, you'll receive a contract address (KT1***).

Note: To change default value for amount, operation fee, storage limit and gas limit use command in interactive mode.

To input string in non-interactive mode, enclose value as - "\"string_Value\"".

Invoke a Contract

If you want to make any other transactions into already deployed contracts, then invoke/call the contract.

  • Invoke smart contract in interactive mode: (Use "-i" flag to use interactive mode)

tezster call -i
eg.- tezster call -i
? Enter contract name: simplecontract
? Enter argument value: "good evening"
? Enter account label/pkh: bootstrap1
? Enter amount: (optional, default is 0) 0
? Enter operation fee: (optional, default is 100000) 100000
? Enter storage limit: (optional, default is 10000) 10000
? Enter gas limit: (optional, default is 500000) 500000

Note: Amount, operation fee, storage limit and gas limit are optional fields with default value.

  • Invoke smart contract in non-interactive mode:

tezster call <contract-label> <argument-value> <account> <--optional amount>
eg.- tezster call simplecontract "\"good evening\"" bootstrap1

Note: To change default value for amount, operation fee, storage limit and gas limit use command in interactive mode.

To input string in non-interactive mode, enclose value as - "\"string_Value\"".

Smart Contract With Multiple Entry Point

You need to have a michelson smart contract file. You can use this link for reference contract and paste in a file (eg.- event.tz).

List Entry Points

You can To list all entry points and its corresponding parameters using contract file path or contract address. To list entry points, run:

tezster list-entry-points <contract-absolute-path/contract-address>

Note: If using contract address, make sure current node provider is set to delphinet node.

Deploy a Complex Contract

To deploy contract using initial storage value, run:

tezster deploy -i
eg.- tezster deploy -i
? Enter contract label: event
? Enter absolute path of contract(.tz) file: ./event.tz
? Enter initial storage value: Pair {} "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"
? Enter account label/pkh: bootstrap1
? Enter amount: (optional, default is 0) 0
? Enter operation fee: (optional, default is 100000) 100000
? Enter storage limit: (optional, default is 10000) 10000
? Enter gas limit: (optional, default is 500000) 500000

If the operation is successful, you'll receive a contract address (KT1***).

Note: Amount, operation fee, storage limit and gas limit are optional fields with default value.

Invoke a Complex Contract

Again to call the contract, run:

tezster call -i
eg.- tezster call -i
? Enter contract name: event
? Enter argument value: Right (Left (Pair "Tezster meetup" "30-04-2020"))
? Enter account label/pkh: bootstrap1
? Enter amount: (optional, default is 0) 0
? Enter operation fee: (optional, default is 100000) 100000
? Enter storage limit: (optional, default is 10000) 10000
? Enter gas limit: (optional, default is 500000) 500000

Note : <argument value> for an entry-point can be obtained using : "tezster list-entry-points <absolute path>"

Fetch Contract Storage

To see the current storage in a contract, run:

tezster get-storage <contract-label/address>
eg.- tezster get-storage simplecontract

You can check the updated storage after each step when you deploy or call contract.

Add Existing Contract

This will add a reference to already deployed contract so that you can further interact with it by using a contract label. To add contract, run:

tezster add-contract <contract-label> <contract-address>
eg.- tezster add-contract swap KT1**********

After adding contract you can interact with it using call, get-storage etc commands.

List Contracts

To list down all the deployed smart contracts using tezster, run

tezster list-contracts

Remove a Contract

To remove previously deployed smart contract from the list, run:

tezster remove-contract <contract-label>