deploy module provides types and functions for deploying contracts, uploading contract code, and managing contract lifecycles.
Overview
Contracts are deployed with a deterministic address derived from a deployer address and salt. Access deployment functions throughenv.deployer() in your contracts.
Types
Deployer
Provides access to contract deployment functions.env.deployer() in contract code.
DeployerWithAddress
A deployer configured with a specific address and salt for deterministic contract deployment.DeployerWithAsset
A deployer for Stellar Asset Contracts.Deployer Methods
with_current_contract
Creates a deployer that derives contract IDs from the current contract and provided salt.with_address
Creates a deployer that derives contract IDs from a specific address and salt.with_stellar_asset
Creates a deployer for a Stellar Asset Contract.serialized_asset- XDR-serialized StellarAsset
upload_contract_wasm
Uploads contract Wasm code to the network.update_current_contract_wasm
Replaces the current contract’s executable with new Wasm.extend_ttl
Extends the TTL (Time To Live) of contract instance and code.contract_address- Contract to extend TTL forthreshold- Only extend if current TTL is below thisextend_to- New TTL value in ledgers
extend_ttl_for_contract_instance
Extends only the contract instance TTL.extend_ttl_for_code
Extends only the contract code TTL.DeployerWithAddress Methods
deployed_address
Returns the deterministic address where the contract will be deployed.deploy_v2
Deploys a contract with the specified Wasm hash and constructor arguments.wasm_hash- Hash of uploaded Wasm codeconstructor_args- Arguments for the contract constructor (use()for none)
deploy (deprecated)
deploy_v2 instead.
DeployerWithAsset Methods
deployed_address
Returns the deterministic address for the Stellar Asset Contract.deploy
Deploys the Stellar Asset Contract.Examples
Deploy Without Constructor
Deploy With Constructor
Get Address Before Deploying
Test Utilities
When thetestutils feature is enabled, additional functions are available: