Class SessionBuilder

Builder for creating Session transactions. Used to deploy new smart contracts or upgrade existing ones from WebAssembly bytecode.

Example

const wasmBytes = await fs.readFile('contract.wasm');
const transaction = new SessionBuilder()
.from(deployerPublicKey)
.wasm(wasmBytes)
.installOrUpgrade()
.runtimeArgs(args)
.chainName('casper')
.payment(100_000_000_000)
.build();

Hierarchy

Constructors

Properties

_chainName: string
_contractHash: string
_initiatorAddr: InitiatorAddr
_invocationTarget: TransactionTarget
_isInstallOrUpgrade: boolean = false
_pricingMode: PricingMode
_runtimeArgs: Args
_scheduling: TransactionScheduling = ...
_timestamp: Timestamp = ...
_ttl: Duration = ...

Methods

  • Protected

    Creates a default deploy header with the configured transaction settings.

    Returns

    A deploy header with account, chain name, timestamp, TTL, and gas price

    Returns DeployHeader

  • Builds and returns the Session transaction for Casper 1.5. Uses the legacy deploy format for backward compatibility.

    Returns

    A Transaction object compatible with Casper 1.5

    Throws

    If WASM bytecode is not specified

    Returns Transaction

  • Sets the chain name for the transaction.

    Returns

    The builder instance for method chaining

    Parameters

    • chainName: string

      The name of the Casper network chain (e.g., 'casper-test', 'casper')

    Returns SessionBuilder

  • Sets the contract hash for the transaction.

    Returns

    The builder instance for method chaining

    Parameters

    • contractHash: string

      The contract hash in hexadecimal format

    Returns SessionBuilder

  • Sets the payment amount for the transaction using a limited payment mode.

    Returns

    The builder instance for method chaining

    Parameters

    • paymentAmount: number

      The payment amount in motes

    • gasPriceTolerance: number = 1

      Gas price tolerance multiplier (default: 1)

    Returns SessionBuilder

  • Sets the time-to-live for the transaction.

    Returns

    The builder instance for method chaining

    Parameters

    • ttl: number

      Time-to-live in milliseconds (default: 1800000ms = 30 minutes)

    Returns SessionBuilder

Generated using TypeDoc