Skip to content

Commit

Permalink
Rename cli commands to stellar in smart contract dir (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
janewang authored Jun 21, 2024
1 parent d479ae5 commit 497a078
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
16 changes: 8 additions & 8 deletions docs/smart-contracts/example-contracts/deployer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ assert_eq!(sum, 5);

## Build the Contracts

To build the contract into a `.wasm` file, use the `soroban contract build` command. Build both the deployer contract and the test contract.
To build the contract into a `.wasm` file, use the `stellar contract build` command. Build both the deployer contract and the test contract.

```sh
soroban contract build
stellar contract build
```

Both `.wasm` files should be found in both contract `target` directories after building both contracts:
Expand All @@ -457,15 +457,15 @@ If you have [`stellar-cli`] installed, you can invoke the contract function to d
Before deploying the test contract with the deployer, install the test contract Wasm using the `install` command. The `install` command will print out the hash derived from the Wasm file (it's not just the hash of the Wasm file itself though) which should be used by the deployer.

```sh
soroban contract install --wasm contract/target/wasm32-unknown-unknown/release/soroban_deployer_test_contract.wasm
stellar contract install --wasm contract/target/wasm32-unknown-unknown/release/soroban_deployer_test_contract.wasm
```

The command prints out the hash as hex. It will look something like `7792a624b562b3d9414792f5fb5d72f53b9838fef2ed9a901471253970bc3b15`.

We also need to deploy the `Deployer` contract:

```sh
soroban contract deploy --wasm deployer/target/wasm32-unknown-unknown/release/soroban_deployer_contract.wasm --id 1
stellar contract deploy --wasm deployer/target/wasm32-unknown-unknown/release/soroban_deployer_contract.wasm --id 1
```

This will return the deployer address: `CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM`.
Expand All @@ -477,7 +477,7 @@ Then the deployer contract may be invoked with the Wasm hash value above.
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract invoke --id 1 -- deploy \
stellar contract invoke --id 1 -- deploy \
--deployer CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM
--salt 123 \
--wasm_hash 7792a624b562b3d9414792f5fb5d72f53b9838fef2ed9a901471253970bc3b15 \
Expand All @@ -490,7 +490,7 @@ soroban contract invoke --id 1 -- deploy \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract invoke --id 1 -- deploy `
stellar contract invoke --id 1 -- deploy `
--deployer CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM
--salt 123 `
--wasm_hash 7792a624b562b3d9414792f5fb5d72f53b9838fef2ed9a901471253970bc3b15 `
Expand All @@ -509,7 +509,7 @@ And then invoke the deployed test contract using the identifier returned from th
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract invoke \
stellar contract invoke \
--id ead19f55aec09bfcb555e09f230149ba7f72744a5fd639804ce1e934e8fe9c5d \
-- \
value
Expand All @@ -520,7 +520,7 @@ soroban contract invoke \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract invoke `
stellar contract invoke `
--id ead19f55aec09bfcb555e09f230149ba7f72744a5fd639804ce1e934e8fe9c5d `
-- `
value
Expand Down
12 changes: 6 additions & 6 deletions docs/smart-contracts/example-contracts/tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,10 @@ The eight tests created for this example contract test a range of possible condi

## Build the Contract

To build the contract, use the `soroban contract build` command.
To build the contract, use the `stellar contract build` command.

```sh
soroban contract build
stellar contract build
```

A `.wasm` file should be outputted in the `target` directory:
Expand All @@ -989,14 +989,14 @@ target/wasm32-unknown-unknown/release/soroban_token_contract.wasm

## Run the Contract

If you have [`soroban-cli`] installed, you can invoke contract functions using it.
If you have [`stellar-cli`] installed, you can invoke contract functions using it.

<Tabs groupId="platform" defaultValue={getPlatform()}>

<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract invoke \
stellar contract invoke \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--id 1 \
-- \
Expand All @@ -1009,7 +1009,7 @@ soroban contract invoke \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract invoke `
stellar contract invoke `
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm `
--id 1 `
-- `
Expand All @@ -1021,4 +1021,4 @@ soroban contract invoke `

</Tabs>

[`soroban-cli`]: ../../tools/developer-tools.mdx#cli
[`stellar-cli`]: ../../tools/developer-tools.mdx#cli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You can run these two steps separately. Let's try it with the Increment contract
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract install \
stellar contract install \
--network testnet \
--source alice \
--wasm target/wasm32-unknown-unknown/release/soroban_increment_contract.wasm
Expand All @@ -46,7 +46,7 @@ soroban contract install \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract install `
stellar contract install `
--network testnet `
--source alice `
--wasm target/wasm32-unknown-unknown/release/soroban_increment_contract.wasm
Expand All @@ -63,7 +63,7 @@ This returns the hash of the Wasm bytes, like `6ddb28e0980f643bb97350f7e3bacb0ff
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract deploy \
stellar contract deploy \
--wasm-hash 6ddb28e0980f643bb97350f7e3bacb0ff1fe74d846c6d4f2c625e766210fbb5b \
--source alice \
--network testnet
Expand All @@ -74,7 +74,7 @@ soroban contract deploy \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract deploy `
stellar contract deploy `
--wasm-hash 6ddb28e0980f643bb97350f7e3bacb0ff1fe74d846c6d4f2c625e766210fbb5b `
--source alice `
--network testnet
Expand All @@ -91,7 +91,7 @@ This command will return the contract id (e.g. `CACDYF3CYMJEJTIVFESQYZTN67GO2R5D
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract invoke \
stellar contract invoke \
--id CACDYF3CYMJEJTIVFESQYZTN67GO2R5D5IUABTCUG3HXQSRXCSOROBAN \
--source alice \
--network testnet \
Expand All @@ -104,7 +104,7 @@ soroban contract invoke \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract invoke `
stellar contract invoke `
--id CACDYF3CYMJEJTIVFESQYZTN67GO2R5D5IUABTCUG3HXQSRXCSOROBAN `
--source alice `
--network testnet `
Expand All @@ -131,6 +131,6 @@ Sometimes you'll need to run your own node:
- Production apps! Stellar maintains public test RPC nodes for Testnet and Futurenet, but not for Mainnet. Instead, you will need to run your own node, and point your app at that. If you want to use a software-as-a-service platform for this, [various providers](../../data/rpc/rpc-providers.mdx) are available.
- When you need a network that differs from the version deployed to Testnet.

The Soroban team maintains Docker containers that makes this as straightforward as possible. See the [RPC](../../data/rpc/admin-guide.mdx) reference for details.
The RPC team maintains Docker containers that makes this as straightforward as possible. See the [RPC](../../data/rpc/admin-guide.mdx) reference for details.

Up next, we'll use the deployed contracts to build a simple web app.
18 changes: 9 additions & 9 deletions docs/smart-contracts/getting-started/deploy-to-testnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { getPlatform } from "@site/src/helpers/getPlatform";
To recap what we've done so far, in [Setup](setup.mdx):

- we set up our local environment to write Rust smart contracts
- installed the soroban-cli
- configured the soroban-cli to communicate with the Soroban Testnet via RPC
- installed the stellar-cli
- configured the stellar-cli to communicate with the Stellar Testnet via RPC
- and configured an identity to sign transactions

In [Hello World](hello-world.mdx) we created a `hello-world` project, and learned how to test and build the `HelloWorld` contract. Now we are ready to deploy that contract to Testnet, and interact with it.
Expand All @@ -38,7 +38,7 @@ To deploy your HelloWorld contract, run the following command:
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract deploy \
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/hello_world.wasm \
--source alice \
--network testnet
Expand All @@ -49,7 +49,7 @@ soroban contract deploy \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract deploy `
stellar contract deploy `
--wasm target/wasm32-unknown-unknown/release/hello_world.wasm `
--source alice `
--network testnet
Expand All @@ -76,7 +76,7 @@ In the background, the CLI is making RPC calls. For information on that checkout
<TabItem value="unix" label="macOS/Linux">

```sh
soroban contract invoke \
stellar contract invoke \
--id CACDYF3CYMJEJTIVFESQYZTN67GO2R5D5IUABTCUG3HXQSRXCSOROBAN \
--source alice \
--network testnet \
Expand All @@ -90,7 +90,7 @@ soroban contract invoke \
<TabItem value="windows" label="Windows (PowerShell)">

```powershell
soroban contract invoke `
stellar contract invoke `
--id CACDYF3CYMJEJTIVFESQYZTN67GO2R5D5IUABTCUG3HXQSRXCSOROBAN `
--source alice `
--network testnet `
Expand All @@ -113,16 +113,16 @@ The following output should appear.

The `--` double-dash is required!

This is a general [CLI pattern](https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean) used by other commands like [cargo run](https://doc.rust-lang.org/cargo/commands/cargo-run.html). Everything after the `--`, sometimes called [slop](https://github.com/clap-rs/clap/issues/971), is passed to a child process. In this case, `soroban contract invoke` builds an _implicit CLI_ on-the-fly for the `hello` method in your contract. It can do this because Soroban SDK embeds your contract's schema / interface types right in the `.wasm` file that gets deployed on-chain. You can also try:
This is a general [CLI pattern](https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean) used by other commands like [cargo run](https://doc.rust-lang.org/cargo/commands/cargo-run.html). Everything after the `--`, sometimes called [slop](https://github.com/clap-rs/clap/issues/971), is passed to a child process. In this case, `stellar contract invoke` builds an _implicit CLI_ on-the-fly for the `hello` method in your contract. It can do this because Soroban SDK embeds your contract's schema / interface types right in the `.wasm` file that gets deployed on-chain. You can also try:

```sh
soroban contract invoke ... -- --help
stellar contract invoke ... -- --help
```

and

```sh
soroban contract invoke ... -- hello --help
stellar contract invoke ... -- hello --help
```

:::
Expand Down
6 changes: 3 additions & 3 deletions docs/smart-contracts/getting-started/storing-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ This tutorial assumes that you've already completed the previous steps in Gettin

## Adding the increment contract

The `soroban contract init` command allows us to initialize a new project with any of the example contracts from the [soroban-examples](https://github.com/stellar/soroban-examples) repo, using the `--with-example` (or `-w`) flag.
The `stellar contract init` command allows us to initialize a new project with any of the example contracts from the [soroban-examples](https://github.com/stellar/soroban-examples) repo, using the `--with-example` (or `-w`) flag.

It will not overwrite existing files, so we can also use this command to add a new contract to an existing project. Run the command again with a `--with-example` flag to add an `increment` contract to our project. From inside our `soroban-hello-world` directory, run:

```sh
soroban contract init ./ --with-example increment
stellar contract init ./ --with-example increment
```

This will create a new `contracts/increment` directory with the following files:
Expand Down Expand Up @@ -141,7 +141,7 @@ For now, it's worth knowing that there are three kinds of storage: `Persistent`,
From inside `soroban-hello-world`, run:

```sh
soroban contract build
stellar contract build
```

Check that it built:
Expand Down
36 changes: 18 additions & 18 deletions docs/smart-contracts/guides/dapps/initialization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ This action will compile the smart contracts and place them in the `token/target
After building, you're ready to deploy the smart contracts to Futurenet. To do this, open a terminal in the `soroban-examples/token` directory and execute the following:

```shell
soroban contract deploy \
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
--source <ADMIN_ACCOUNT_SECRET_KEY> \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase 'Test SDF Future Network ; October 2022'
```

This command deploys the smart contracts to Futurenet using the `soroban contract deploy` function.
This command deploys the smart contracts to Futurenet using the `stellar contract deploy` function.

## Initializing a Token Contract

With the contracts deployed, it's time to initialize the token contract:

```shell
soroban contract invoke \
stellar contract invoke \
--id <TOKEN_CONTRACT_ID> \
--source-account <ADMIN_ACCOUNT_SECRET_KEY> \
--rpc-url https://rpc-futurenet.stellar.org:443 \
Expand All @@ -72,7 +72,7 @@ This command requires certain inputs:
Lastly, you need to mint some tokens to the sender's account:

```shell
soroban contract invoke \
stellar contract invoke \
--id <TOKEN_CONTRACT_ID> \
--source-account <ADMIN_ACCOUNT_SECRET_KEY> \
--rpc-url https://rpc-futurenet.stellar.org:443 \
Expand Down Expand Up @@ -101,7 +101,7 @@ set -e

NETWORK="$1"

# If soroban-cli is called inside the soroban-preview docker container,
# If stellar-cli is called inside the soroban-preview docker container,
# it can call the stellar standalone container just using its name "stellar"
if [[ "$IS_USING_DOCKER" == "true" ]]; then
SOROBAN_RPC_HOST="http://stellar:8000"
Expand Down Expand Up @@ -136,18 +136,18 @@ esac


echo Add the $NETWORK network to cli client
soroban network add \
stellar network add \
--rpc-url "$SOROBAN_RPC_URL" \
--network-passphrase "$SOROBAN_NETWORK_PASSPHRASE" "$NETWORK"

if !(soroban keys ls | grep token-admin 2>&1 >/dev/null); then
if !(stellar keys ls | grep token-admin 2>&1 >/dev/null); then
echo Create the token-admin identity
soroban keys generate token-admin
stellar keys generate token-admin
fi
TOKEN_ADMIN_SECRET="$(soroban keys show token-admin)"
TOKEN_ADMIN_ADDRESS="$(soroban keys address token-admin)"
TOKEN_ADMIN_SECRET="$(stellar keys show token-admin)"
TOKEN_ADMIN_ADDRESS="$(stellar keys address token-admin)"

# TODO: Remove this once we can use `soroban keys` from webpack.
# TODO: Remove this once we can use `stellar keys` from webpack.
mkdir -p .soroban-example-dapp
echo "$TOKEN_ADMIN_SECRET" > .soroban-example-dapp/token_admin_secret
echo "$TOKEN_ADMIN_ADDRESS" > .soroban-example-dapp/token_admin_address
Expand All @@ -159,7 +159,7 @@ curl --silent -X POST "$FRIENDBOT_URL?addr=$TOKEN_ADMIN_ADDRESS" >/dev/null
ARGS="--network $NETWORK --source token-admin"

echo Deploy the Stellar asset contract
TOKEN_ID=$(soroban contract asset deploy $ARGS --asset "EXT:$TOKEN_ADMIN_ADDRESS")
TOKEN_ID=$(stellar contract asset deploy $ARGS --asset "EXT:$TOKEN_ADMIN_ADDRESS")
echo "Token deployed successfully with TOKEN_ID: $TOKEN_ID"

# TODO - remove this workaround when
Expand All @@ -174,15 +174,15 @@ make build

echo Deploy the crowdfund contract
CROWDFUND_ID="$(
soroban contract deploy $ARGS \
stellar contract deploy $ARGS \
--wasm target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm
)"
echo "Contract deployed successfully with ID: $CROWDFUND_ID"
echo "$CROWDFUND_ID" > .soroban-example-dapp/crowdfund_id

echo "Initialize the crowdfund contract"
deadline="$(($(date +"%s") + 86400))"
soroban contract invoke \
stellar contract invoke \
$ARGS \
--id "$CROWDFUND_ID" \
-- \
Expand All @@ -201,13 +201,13 @@ Here's a summary of what the `initialize.sh` script does:
- Determines the Soroban RPC host URL depending on its execution environment (either inside the soroban-preview Docker container or locally)
- Sets the Soroban RPC URL based on the previously determined host URL
- Sets the Soroban network passphrase and Friendbot URL depending on the chosen network
- Adds the network configuration to Soroban using `soroban network add`
- Generates a token-admin identity using `soroban keys generate`
- Adds the network configuration using `stellar network add`
- Generates a token-admin identity using `stellar keys generate`
- Fetches the TOKEN_ADMIN_SECRET and TOKEN_ADMIN_ADDRESS from the newly generated identity
- Saves the TOKEN_ADMIN_SECRET and TOKEN_ADMIN_ADDRESS in the .soroban directory
- Funds the token-admin account using Friendbot
- Deploy the Stellar asset contract with `soroban contract asset deploy` and stores the resulting TOKEN_ID
- Builds the crowdfund contract with `make build` and deploys it using `soroban contract deploy`, storing the returned CROWDFUND_ID
- Deploy the Stellar asset contract with `stellar contract asset deploy` and stores the resulting TOKEN_ID
- Builds the crowdfund contract with `make build` and deploys it using `stellar contract deploy`, storing the returned CROWDFUND_ID
- Initializes the crowdfund contract by invoking the initialize function with necessary parameters
- Prints "Done" to signify the end of the initialization process

Expand Down

0 comments on commit 497a078

Please sign in to comment.