-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove octez node stuff and simplify octez-client stuff for developers (
#137) * Remove octez node stuff and simplify octez-client stuff for developers * Remove unused images * Fix broken link * Clarify installation options and RPC nodes * "From a faucet" Co-authored-by: NicNomadic <[email protected]> * "Configured to use an RPC node" Co-authored-by: NicNomadic <[email protected]> * Change title to "interacting with contracts" --------- Co-authored-by: NicNomadic <[email protected]>
- Loading branch information
1 parent
3d71ecd
commit 3462d09
Showing
21 changed files
with
251 additions
and
2,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: The Octez client | ||
authors: 'Thomas Zoughebi, Aymeric Bethencourt, Maxime Fernandez, Tim McMackin' | ||
lastUpdated: 27th October 2023 | ||
--- | ||
|
||
The Octez command-line client is part of the Octez suite of tools for interacting with Tezos and running nodes. | ||
Developers use the Octez client for many tasks, including: | ||
|
||
- Working with accounts | ||
- Sending transactions and interacting with contracts | ||
- Originating smart contracts and smart rollups | ||
|
||
Other parts of Octez allow you to host, manage, and monitor nodes, bake blocks, and host RPC nodes. | ||
|
||
This documentation is an overview of the Octez client for Tezos smart contract and dApp developers. | ||
For more detailed information, see the [Octez documentation](https://tezos.gitlab.io/) and opentezos.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
title: Creating accounts | ||
--- | ||
|
||
You can create or import accounts into the Octez client just like you do so in wallet applications. | ||
|
||
Octez keeps a local list of aliases for addresses, including user accounts, smart contracts, and smart rollups. | ||
You can list the aliases that the Octez client is aware of by running the command `octez-client list known addresses`. | ||
When you run transactions with Octez, you can use the alias in place of the account address. | ||
|
||
## Creating accounts | ||
|
||
To create an account, run this command, replacing `local_account` with a local name for the new account: | ||
|
||
```bash | ||
octez-client gen keys local_account | ||
``` | ||
|
||
You can see the address of the account by running this command: | ||
|
||
```bash | ||
octez-client show address local_account | ||
``` | ||
|
||
The account address (technically the hash of the public key) starts with `tz1`, `tz2`, or `tz3`. | ||
You can use this address to send tez to this account, such as from a faucet if you are using a testnet. | ||
See [Using sandboxes and testnets](../testnets). | ||
|
||
<!-- TODO | ||
## Importing pregenerated accounts | ||
Some testnets provide accounts that anyone can access. | ||
You can use these accounts for tasks such as local tests and automated tests, but be aware that their private keys are publicly available and anyone can use them. | ||
TODO info about Alice and Bob and how to import them --> | ||
|
||
## Importing pre-existing accounts | ||
|
||
If you already have a Tezos account, you can import your private key to use the account in Octez: | ||
|
||
1. Export the private key from your wallet application, being careful not to expose it to anyone. | ||
|
||
1. Run this command, replacing `$ALIAS` with a local alias for the account and `$PRIVATE_KEY` with the private key: | ||
|
||
```bash | ||
octez-client import secret key $ALIAS unencrypted:$PRIVATE_KEY | ||
``` | ||
|
||
Now you can use the alias in place of the address when you send transactions with Octez. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: Installing the Octez client | ||
lastUpdated: 27th October 2023 | ||
--- | ||
|
||
You can install the Octez client directly on your computer or use a Docker image that has the most recent version of the Octez tools installed. | ||
|
||
## Installing the Octez client locally | ||
|
||
You can install the Octez client on your computer by using your package manager. | ||
Then, initialize it to use the RPC node of your choice: | ||
|
||
1. Install the client: | ||
|
||
- For MacOS, run these commands: | ||
|
||
```bash | ||
brew tap serokell/tezos-packaging-stable https://github.com/serokell/tezos-packaging-stable.git | ||
brew install tezos-client | ||
``` | ||
|
||
- For Ubuntu, Windows WSL, and Linux distributions that use `apt`, run these commands: | ||
|
||
```bash | ||
REPO="ppa:serokell/tezos" | ||
sudo add-apt-repository -y $REPO && sudo apt-get update | ||
sudo apt-get install -y tezos-client | ||
``` | ||
|
||
- For Fedora and Linux distributions that use Copr, run these commands: | ||
|
||
```bash | ||
REPO="@Serokell/Tezos" | ||
dnf copr enable -y $REPO && dnf update -y | ||
dnf install -y tezos-client | ||
``` | ||
|
||
For more local installation options, see [How to get Tezos](https://tezos.gitlab.io/introduction/howtoget.html) in the Octez documentation. | ||
|
||
1. Verify that the Octez client is installed by running this command: | ||
|
||
```bash | ||
octez-client --version | ||
``` | ||
|
||
If you see a message with the version of Octez that you have installed, the Octez client is installed correctly. | ||
For help on Octez, run `octez-client --help` or see the [Octez documentation](http://tezos.gitlab.io/index.html). | ||
|
||
1. Initialize the client's configuration file by running this command: | ||
```bash | ||
octez-client config init | ||
``` | ||
This command creates a default configuration file in the location `$HOME/.tezos-client/config`. | ||
1. Set the RPC node to use: | ||
1. Get the URL of a public RPC node or a private node that you have access to. | ||
For example, you can get the URL of a testnet node from https://teztnets.xyz/, such as `https://rpc.ghostnet.teztnets.xyz` for Ghostnet. | ||
1. Set your Octez client to use this node by running this command on the command line, replacing the Ghostnet URL with the URL that you copied: | ||
```bash | ||
octez-client --endpoint https://rpc.ghostnet.teztnets.xyz config update | ||
``` | ||
If you are using a testnet, Octez shows a warning that you are not using Mainnet. | ||
You can hide this message by setting the `TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER` environment variable to "YES". | ||
1. Verify that you are using the correct RPC URL by running this command: | ||
```bash | ||
octez-client config show | ||
``` | ||
The response from Octez includes the URL of the RPC node that you are using. | ||
For a full list of Octez client commands, run `octez-client man`. | ||
## Using the Octez client in the Tezos Docker image | ||
The Tezos Docker image contains the latest version of the Octez client and the other Octez tools. | ||
To start a container from this image, run this command: | ||
```bash | ||
docker run -it --rm --entrypoint /bin/sh --name octez-container tezos/tezos:latest | ||
``` | ||
You can verify that the Octez client is available in the container by running this command: | ||
```bash | ||
octez-client --version | ||
``` | ||
Then set the RPC node for the client as described above. | ||
For more information about using the Docker image, see [Using Docker Images And Docker-Compose](https://tezos.gitlab.io/introduction/howtoget.html#using-docker-images-and-docker-compose) in the Octez documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: Interacting with contracts | ||
authors: Tim McMackin | ||
lastUpdated: 27 October 2023 | ||
--- | ||
|
||
Before sending transactions to contracts with the Octez client, make sure that your client is configured to use an RPC node for the network that you want to use. | ||
To verify the RPC node that you are using, run `octez-client config show` and look at the value in the `entrypoint` field. | ||
|
||
## Sending tez | ||
|
||
To send tez from a source account to a target account, use the `octez-client transfer` command, as in this example: | ||
|
||
```bash | ||
octez-client transfer 42 from account1 to account2 --fee-cap 0.9 | ||
``` | ||
|
||
You can use addresses or local aliases for the source and target accounts, but Octez must have the private key for the source account in order to sign the transaction. | ||
|
||
To check the balance of an account after a transaction, use the `octez-client get balance for` command and pass the alias or address of an account, as in this example: | ||
|
||
```bash | ||
octez-client get balance for account1 | ||
``` | ||
|
||
## Calling smart contracts | ||
|
||
To call a smart contract, use the `octez-client transfer` command, as in this example from the [Deploy a smart contract](../../tutorials/smart-contract) tutorial: | ||
|
||
```bash | ||
octez-client --wait none transfer 0 \ | ||
from $MY_TZ_ADDRESS to my-counter \ | ||
--entrypoint 'increment' --arg '5' --burn-cap 0.1 | ||
``` | ||
|
||
This command calls the `increment` entrypoint of the `my-counter` contract and includes 0 tez and up to 0.1 tez in fees with the transaction. | ||
It passes the parameter "5" to the endpoint. | ||
You can use a local alias or the full address for the smart contract. | ||
|
||
Because entrypoints accept parameters in Michelson code, you must encode the values that you send as Michelson values. | ||
The high-level languages have tools to help you encode values in Michelson. | ||
For example, if you are using LIGO to create an entrypoint that accepts an integer, address, and string as a parameter, you can pass the parameter values as a LIGO expression and get the Michelson version with this command: | ||
|
||
```bash | ||
ligo compile parameter MyContract.jsligo -e "myentrypoint" \ | ||
'[5, "tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx" as address, "hello"]' | ||
``` | ||
|
||
The compiled parameter value looks like this: | ||
|
||
``` | ||
(Pair 5 "tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx" "hello") | ||
``` | ||
|
||
Then you can use this value for the value of the `--arg` argument in the `octez-client transfer` command. | ||
|
||
## Originating (deploying) smart contracts | ||
|
||
To deploy (originate) a smart contract to the current network, use the `octez-client originate contract` command, as in this example from the [Deploy a smart contract](../../tutorials/smart-contract) tutorial: | ||
|
||
```bash | ||
octez-client originate contract my-counter \ | ||
transferring 0 from $MY_TZ_ADDRESS \ | ||
running increment.tz \ | ||
--init 10 --burn-cap 0.1 --force | ||
``` | ||
|
||
This command accepts the compiled version of the contract as a Michelson `.tz` file. | ||
See the documentation for the high-level language you are using for how to compile a contract. | ||
Like the command to call a smart contract, this command accepts the initial value of the contract storage as a Michelson-encoded value. | ||
|
||
After you originate the contract, you can use the local alias from this command to send transactions to its entrypoints. | ||
You can see the aliases of contracts by running the command `octez-client list known contracts`. |
Oops, something went wrong.
3462d09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs-staging – ./
docs-staging-iota.vercel.app
docs-staging-trili-tech.vercel.app
docs-staging-git-main-trili-tech.vercel.app