DeployRequest
public final class DeployRequest : Sendable
Request parameters for deploying a smart contract instance.
Deploying a contract creates a new instance from previously installed WASM code. The contract receives a unique contract ID and can optionally be initialized with constructor arguments.
Prerequisites:
- Contract WASM code must be installed first (use InstallRequest)
- You need the WASM hash from the installation
Required parameters:
- Source account keypair (with private key for signing)
- WASM hash from contract installation
- Network and RPC endpoint
Optional parameters:
- Constructor arguments (if contract has an __constructor function)
- Salt for deterministic contract ID generation
- Method options for transaction customization
Example:
// After installing contract and obtaining wasmHash
let constructorArgs = [
try SCValXDR.address(adminAddress),
SCValXDR.u32(1000)
]
let deployRequest = DeployRequest(
rpcUrl: "https://soroban-testnet.stellar.org",
network: Network.testnet,
sourceAccountKeyPair: sourceKeyPair,
wasmHash: wasmHash,
constructorArgs: constructorArgs,
salt: nil, // Random salt
methodOptions: MethodOptions(),
enableServerLogging: false
)
let client = try await SorobanClient.deploy(deployRequest: deployRequest)
print("Deployed at: \(client.contractId)")
See also:
- [SorobanClient.deploy] for deploying contracts
- [InstallRequest] for installing contract code
-
The URL of the RPC instance that will be used to deploy the contract.
Declaration
Swift
public let rpcUrl: String -
The Stellar network this contract is to be deployed
Declaration
Swift
public let network: Network -
Keypair of the Stellar account that will send this transaction. The keypair must contain the private key for signing.
Declaration
Swift
public let sourceAccountKeyPair: KeyPair -
The hash of the Wasm blob (in hex string format), which must already be installed on-chain.
Declaration
Swift
public let wasmHash: String -
Constructor/Initialization Args for the contract’s
__constructormethod.Declaration
Swift
public let constructorArgs: [SCValXDR]? -
Salt used to generate the contract’s ID. Default: random.
Declaration
Swift
public let salt: WrappedData32? -
Method options used to fine tune the transaction.
Declaration
Swift
public let methodOptions: MethodOptions -
Enable soroban server logging (helpful for debugging). Default: false.
Declaration
Swift
public let enableServerLogging: Bool -
init(rpcUrl:network: sourceAccountKeyPair: wasmHash: constructorArgs: salt: methodOptions: enableServerLogging: ) Constructor
Declaration
Swift
public init(rpcUrl: String, network: Network, sourceAccountKeyPair: KeyPair, wasmHash: String, constructorArgs: [SCValXDR]? = nil, salt: WrappedData32? = nil, methodOptions: MethodOptions = MethodOptions(), enableServerLogging: Bool)Parameters
rpcUrlThe URL of the RPC instance that will be used to deploy the contract.
networkThe Stellar network this contract is to be deployed.
sourceAccountKeyPairKeypair of the Stellar account that will send this transaction. The keypair must contain the private key for signing.
wasmHashThe hash of the Wasm blob (in hex string format), which must already be installed on-chain.
constructorArgsConstructor/Initialization Args for the contract’s
__constructormethod.saltSalt used to generate the contract’s ID. Default: random.
methodOptionsMethod options used to fine tune the transaction.
enableServerLoggingEnable soroban server logging (helpful for debugging). Default: false.
View on GitHub
Install in Dash