Contract Lifecycle
To manage the lifecycle of a Stellar smart contract using the CLI, follow these steps:
- Set your preferred network. For this guide, we will use
testnet. A list of available networks can be found here
stellar network use testnet
- Create an identity for Alice:
stellar keys generate alice -q
- Fund the identity:
stellar keys fund alice
- Deploy a contract:
stellar keys use alice
stellar contract deploy --wasm /path/to/contract.wasm --alias mycontract
This will display the resulting contract ID, e.g.:
CBB65ZLBQBZL5IYHDHEEPCVUUMFOQUZSQKAJFV36R7TZETCLWGFTRLOQ
To learn more about how to build contract .wasm files, take a look at our getting started tutorial.
- Invoke a contract function:
stellar contract invoke --id mycontract -- <FUNCTION>
- View the contract's state:
stellar contract read --id mycontract --durability <DURABILITY> --key <KEY>
Note: <DURABILITY> is either persistent or temporary. KEY provides the key of the storage entry being read.
- Manage expired states:
stellar contract extend --id mycontract --ledgers-to-extend 1000 --durability <DURABILITY> --key <KEY>
This extends the state of the instance provided by the given key to at least 1000 ledgers from the current ledger.
Guides in this category:
Asset Management
Issue a Stellar Asset, deploy it's contract, and mint, burn, freeze, and clawback.
Add meta data to contract WASM on build
Include meta data in the contract WASM byte code on build
Contract Invoke: Argument Types
How to pass each argument type when invoking a Stellar smart contract using the CLI
Contract Lifecycle
Manage the lifecycle of a Stellar smart contract using the CLI
Deploy a contract from uploaded Wasm bytecode
Deploy an instance of a compiled contract that has already been uploaded on the network
Deploy the Stellar Asset Contract for a Stellar asset
Deploy an SAC for a Stellar asset so that it can interact with smart contracts
Extend a deployed contract instance's TTL
Use the CLI to extend the time to live (TTL) of a contract instance
Extend a deployed contract's storage entry TTL
Use the CLI to extend the time to live (TTL) of a contract's persistent storage entry
Extend a deployed contract's Wasm code TTL
Use Stellar CLI to extend contract's Wasm bytecode TTL, with or without local binary
Payments and Assets
Send XLM, stellar classic, or a soroban asset using the Stellar CLI
Restore an archived contract using the Stellar CLI
Restore an archived contract instance using the Stellar CLI
Restore archived contract data using the Stellar CLI
Restore archived contract storage entries using Stellar CLI
Stellar Keys
Manage stellar keys
Create Claimable Balance
Create claimable balances with various claim predicates using the Stellar CLI
tx Commands
Create stellar transactions using the Stellar CLI
tx op add
Create stellar transactions using the Stellar CLI
tx sign and tx send
Create stellar transactions using the Stellar CLI
Upload and deploy a smart contract
Combine the upload and deploy commands in the Stellar CLI to accomplish both tasks
Upload Wasm bytecode
Use the Stellar CLI to upload a compiled smart contract on the ledger