deploy

suspend fun deploy(wasmBytes: ByteArray, constructorArgs: Map<String, Any?> = emptyMap(), source: String, signer: KeyPair, network: Network, rpcUrl: String, salt: ByteArray = secureRandomBytes(32), loadSpec: Boolean = true): ContractClient

Deploy a contract in one step (RECOMMENDED).

This is the primary deployment method that handles everything:

  1. Upload WASM (with duplicate detection)

  2. Load the contract spec from the uploaded code

  3. Deploy contract with optional constructor

  4. Return ready-to-use client

For advanced scenarios requiring WASM reuse, see install and deployFromWasmId.

Return

ContractClient for the deployed contract

Parameters

wasmBytes

The contract WASM code

constructorArgs

Constructor arguments as native Kotlin types

source

Source account for transactions

signer

KeyPair for signing

network

Network to deploy to

rpcUrl

RPC server URL

salt

Salt for contract ID generation (default: 32 bytes from the platform CSPRNG)

loadSpec

Whether to load the contract spec from the uploaded code before deploying, so the returned client carries it (default: true)

Throws

if the network refuses the upload or deployment transaction at submission

if constructor arguments are provided but the uploaded code cannot be found on the RPC to convert them

if constructor arguments are provided but the contract spec declares no __constructor function

if constructor arguments are provided but the uploaded code cannot be parsed

Samples