diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 6c694bce8..877618d97 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -38,6 +38,101 @@ Anything after the `--` double dash (the "slop") is parsed as arguments to the c stellar contract invoke --id CCR6QKTWZQYW6YUJ7UP7XXZRLWQPFRV6SWBLQS4ZQOSAF4BOUD77OTE2 --source alice --network testnet -- hello --to world +## Contract Lifecycle + +### Create Alice +To create an identity for Alice: +``` +stellar keys generate alice +``` + +### Deploy Contract +To deploy a contract: +``` +stellar contract deploy --wasm /path/to/contract.wasm --source alice --network testnet +``` +This will then display the resulting contract ID: +``` +CBB65ZLBQBZL5IYHDHEEPCVUUMFOQUZSQKAJFV36R7TZETCLWGFTRLOQ +``` + +### Initialize Contract +After deployment, initialize the contract with its ID: +``` +stellar contract invoke --id --source alice --network testnet -- initialize --param1 value1 --param2 value2 +``` + +### Call Contract +Invoke a contract function: +``` +stellar contract invoke --id --source alice --network testnet -- function_name --arg1 value1 --arg2 value2 +``` + +### View Contract State +To view the contract's state: +``` +stellar contract read --id --network testnet --source alice --durability --key +``` +Note `` is either `persistent` or `temporary`. `KEY` provides the key of the storage entry being read. The output will show the hash of the ledger entry along with two numbers, the last modified ledger and the live until ledger number. If no `KEY` is provided, the output will show the details for the contract instance. + +### Manage Expired States +To bump the expiration of contract states: +``` +stellar contract extend --id --ledgers-to-extend 1000 --source alice --network testnet --durability --key +``` + +This will extend the state of the instance provided by the given key to at least 1000 ledgers from the current ledger. If the live until ledger is greater than this value, nothing will be done. If no key is provided, the contract instance will be extended. + +## Payments and Assets +Below describes the process for sending XLM, stellar classic, or a soroban asset. + +### Fund the accounts +Set up and fund our accounts, Alice and Bob: +``` +stellar keys generate alice --network testnet +stellar keys generate bob --network testnet +``` + +``` +stellar keys fund alice --network testnet +stellar keys fund bob --network testnet +``` + +### Payment of XLM +First we need the address of the `stellar asset` contract which will allow us to transfer funds. +Obtain the `stellar asset` address for the `native` asset (XLM): + +``` +stellar contract id asset --asset native --source-account alice --network testnet +``` +This will print out the contract id of the `stellar asset` contract used for sending `XLM`. If you would like to send a different token, change the `--asset` value to `:` where `` is the naming code of the asset, see [Naming an asset](https://developers.stellar.org/docs/tokens/control-asset-access#naming-an-asset), and `` is the account ID of the issuing account. For example, to obtain Alice's account ID, you can run + +``` +stellar keys address alice --network testnet +``` + +This will return an ID that starts with `G...`. + +### Send XLM from Alice to Bob: +Once the contract ID for the desired asset transfer is obtained, invoke it to send the token. + +First we will need to get the public key for Bob's account +``` +stellar keys address bob --network testnet +``` +Then invoke the `stellar asset` contract: +``` +stellar contract invoke --id --source-account alice --network testnet -- transfer --to --from alice --amount 100 +``` + +We can check that Alice or Bob's new balance by invoking the same `stellar asset` contract and invoking the balance function: + +``` +stellar contract invoke --id --source-account alice --network testnet -- balance --id +``` + +For more information on the functions available to the `stellar asset` contract, see the [token interface code](https://developers.stellar.org/docs/tokens/token-interface#code). + **Usage:** `stellar [OPTIONS] `