Skip to content

Commit

Permalink
docs: jenesis v2 updates (#67)
Browse files Browse the repository at this point in the history
* docs: jenesis v2 updates

* docs: small fix

* docs: small update

* docs: minor changes

* docs: contract profile updates

* docs: minor attach text change

* docs: fix quote typo

Co-authored-by: James Riehl <33920192+jrriehl@users.noreply.github.com>
  • Loading branch information
Alejandro-Morales and jrriehl authored Aug 26, 2022
1 parent 19c932a commit dd95b39
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 21 deletions.
20 changes: 15 additions & 5 deletions docs/add-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ An example of how to add the template **starter** with the name `my_first_contra
jenesis add contract starter my_first_contract
```

This ```add contract``` command will add a contract template to your jenesis project inside `contracts/my_first_contract/` folder. It will also update the `jenesis.toml` configuration file with the contract information:
This ```add contract``` command will add a contract template to your jenesis project inside `contracts/my_first_contract/` folder. It will also update the `jenesis.toml` configuration file with the contract information under all existing profiles.

```
[profile.testing.contracts.my_first_contract]
[profile.my_profile.contracts.my_first_contract]
contract = "my_first_contract"
network = "fetchai-testnet"
deployer_key = ""
[profile.testing.contracts.my_first_contract.init]
[profile.my_profile.contracts.my_first_contract.init]
count = ""
```
The `deployer_key` field can be manually specified, you can choose any private key locally available to deploy any specific contract. You can also leave this field empty since the ```deploy``` command has an optional argument to deploy all contracts inside a specified profile with the same key, overriding this `deployer_key` argument in the `jenesis.toml` file. See [deploy contracts](deploy-contracts.md) for more information.

Finally, the `init` section contains the parameters needed in the instantiation message for this contract to be deployed. The required parameters are taken from the `instantiate_msg.json` file inside the `contracts` directory. You will need to manually add the values for these parameters in their correct variable type, which are listed in `contracts/my_first_contract/schema/instantiate_msg.json`. For this contract **my_first_contract** we need to add an integer value to the `count` field.

```
[profile.testing.contracts.my_first_contract.init]
[profile.my_profile.contracts.my_first_contract.init]
count = 10
```

Expand All @@ -39,4 +39,14 @@ price = {amount = 1000, denom = DLS}
info = {performance = {max_speed = 200, unit = kph}, fuel = {consumption = 7, unit = kmpl}}
```

You can also add contracts manually by copying and pasting the contract directory from another project you may have, however, they need to follow the same directory structure as the **starter** template mentioned above. If you add a contract manually, you will need to run ```jenesis init``` again to update the `jenesis.toml` configuration file.
You can also add contracts manually by copying and pasting the contract directory from another project you may have, however, they need to follow the same directory structure as the **starter** template mentioned above.

# Attach deployed contracts

If you have added a contract into the project's contract folder that has already been deployed in the network, you can attach it to your project for future interaction using the ```attach``` command. You will need to specify the contract's name and deployment address. You can optionally specify the profile where you wish to insert the contract into. If this is not specified, the deployment will be attached to the default profile, which is the first profile created in your project, unless the `default` settings are manually changed.

```
jenesis attach my_first_contract fetch18xs97q6h9zgh4sz730a42pp0dqa9sh4eef7eutfkv69q3v2y3x8s72pkua
```

This will add the relevant deployment information into a `jenesis.lock` file and you will now be able to interact with `my_first_contract` using [contract interactions](use-contracts.md)
21 changes: 21 additions & 0 deletions docs/add-profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
You can add more profiles than the one specified using the ```new``` command by running the following ```add profile``` command:

```
jenesis add profile my_second_profile
```
By default, the profile's network will be set to `fetchai-testnet`, but you can specify it using the `--network` optional argument. The following will be added to the existing information in your `jenesis.toml` file:

```toml
[profile.my_second_profile.network]
name = "fetchai-testnet"
chain_id = "dorado-1"
fee_minimum_gas_price = 5000000000
fee_denomination = "atestfet"
staking_denomination = "atestfet"
url = "grpc+https://grpc-dorado.fetch.ai"
faucet_url = "https://faucet-dorado.fetch.ai"
is_local = false

[profile.my_second_profile.contracts]
```
If there are existing contracts in your project, all of them will be added to the new profile.
13 changes: 7 additions & 6 deletions docs/deploy-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

> *NOTE: ```deploy``` command is still under active development and currently only supported in MacOS*
Once you have successfully compiled your contracts, make sure to fill out the necessary instantiation message information under the `init` field in the `jenesis.toml` file.
Once you have successfully compiled your contracts, make sure to fill out the necessary instantiation message information under the `init` field in the `jenesis.toml` file, you can deploy your contracts.

> *Note: `jenesis deploy` currently requires that each contract's directory name matches the `.wasm` file name under the `artifacts` directory.
To deploy all the contracts inside a certain profile you have two options:
To deploy all the contracts inside a profile you have two options:

1. Fill the `deployer_key` field for each contract (they can be different) and run the following command:
1. Fill the `deployer_key` field for each contract inside the `jenesis.toml` file (keys can be different for each contract) and run the following command:

```
jenesis alpha deploy profile_name
jenesis alpha deploy --profile profile_name
```
Each contract inside the specified profile will be deployed with the specified key.

2. Simply specify a certain key as an argument of the deploy command:

```
jenesis alpha deploy profile_name key_name
jenesis alpha deploy key_name --profile profile_name
```

The `deployer_key` field will be ignored in this case and all contracts inside the specified profile will be deployed using the key `key_name`.

After running either of the commands mentioned above, all the deployment information will be saved in the `jenesis.lock` file inside your project's directory

```

```toml
[profile.testing.my_first_contract]
checksum = "ecf640a7512be3777c72ec42aff01fdb22897b71953011af3c41ee5dbf3d3bc5"
digest = "be4a4bdfeb4ed8f504c7b7ac84e31ad3876627398a6586b49cac586633af8b85"
Expand Down
63 changes: 53 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ There are multiple commands integrated into jenesis that allow you to perform a
- `new`
- `init`
- `add`
- `attach`
- `compile`
- `keys` (alpha)
- `deploy` (alpha)
Expand All @@ -25,23 +26,30 @@ There are multiple commands integrated into jenesis that allow you to perform a
## Create a new project
Create a project using the ```new``` command
```
jenesis new my_project
jenesis new my_project --profile my_profile
```

This will create a new directory called `my_project`. Inside this directory a `jenesis.toml` file will be created containing the following information:
This will create a new directory called `my_project`. You can use `--profile` and `--network` optional arguments, when they aren't used, profile and network will be set to `testing` and `fetchai-testnet` respectively. Inside this directory a `jenesis.toml` file will be created containing the following information:

```
```toml
[project]
name = "my_project"
authors = [Alice Tyler <alice.tyler@email.com>]
[profile.testing]
network = "fetchai-testnet"
[profile.testing.contracts]
authors = [ "Alice Tyler <alice@mail.com>",]

[profile.my_profile.network]
name = "fetchai-testnet"
chain_id = "dorado-1"
fee_minimum_gas_price = 5000000000
fee_denomination = "atestfet"
staking_denomination = "atestfet"
url = "grpc+https://grpc-dorado.fetch.ai"
faucet_url = "https://faucet-dorado.fetch.ai"
is_local = false

[profile.my_profile.contracts]
```

The project name is the argument passed to the ```new``` command while the authors field is populated by querying the user's GitHub username and email address. The profile network is automatically set to `fetchai-testnet`. The contracts field will remain empty until new contracts are added.
The project name is the argument passed to the ```new``` command while the authors field is populated by querying the user's GitHub username and email address. The profile's network will be filled with the relevant configuration variables. The contracts field will remain empty until new contracts are added.

An empty `contracts` folder will also be created inside `my_project` directory that will eventually contain all the information needed to compile and deploy the desired contracts.

Expand All @@ -52,3 +60,38 @@ jenesis init
```

This command will create the same files and folders inside your project directory as the ones described for the ```new``` command.

## Configure a network

By default, jenesis will configure the project to run on the latest stable Fetch.ai testnet. To test on a local node instead, pass the argument `--network fetchai-localnode` when creating a project:
```
jenesis new my_project --network fetchai-localnode
```
or
```
jenesis init --network fetchai-localnode
```

The configuration can be found under the `network` heading in the `jenesis.toml` file and can be changed as desired:

```toml
[profile.testing.network]
name = "fetchai-localnode"
chain_id = "localnode"
fee_minimum_gas_price = 5000000000
fee_denomination = "atestfet"
staking_denomination = "atestfet"
url = "grpc+http://127.0.0.1:9090/"
is_local = true
cli_binary = "fetchd"
validator_key_name = "validator"
mnemonic = "gap bomb bulk border original scare assault pelican resemble found laptop skin gesture height inflict clinic reject giggle hurdle bubble soldier hurt moon hint"
password = "12345678"
moniker = "test-node"
genesis_accounts = [ "fetch1vas6cc9650z0s08230ytqjphgzl5tcq9crqhhu",]
```
In particular, to fund some accounts for testing, replace the `genesis_accounts`
field with the addresses to be funded.

When running any of the commands `deploy`, `run`, `shell`, and `attach`,
jenesis will check for a currently running local node, and if there is none, a new one will be created in a docker container.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ site_author: developer@fetch.ai
nav:
- Getting started: 'index.md'
- Working with contracts:
- Add profiles: 'add-profile.md'
- Add contracts: 'add-contracts.md'
- Compile contracts: 'compile-contracts.md'
- Deploy contracts: 'deploy-contracts.md'
Expand Down

0 comments on commit dd95b39

Please sign in to comment.