deploy

pub fn deploy( class_hash: ClassHash, constructor_calldata: Array::<felt252>, salt: Option<felt252>, unique: bool, fee_settings: FeeSettings, nonce: Option<felt252> ) -> Result<DeployResult, ScriptCommandError>

Deploys a contract and returns DeployResult.

#[derive(Drop, Clone, Debug)] pub struct DeployResult { pub contract_address: ContractAddress, pub transaction_hash: felt252, }
  • class_hash - class hash of a contract to deploy.
  • constructor_calldata - calldata for the contract constructor.
  • salt - salt for the contract address.
  • unique - determines if salt should be further modified with the account address.
  • fee_settings - fee settings for the transaction, see `FeeSettingsTrait.
  • nonce - nonce for declare transaction. If not provided, nonce will be set automatically.
use starknet::ClassHash; use sncast_std::{deploy, FeeSettingsTrait}; fn main() { let fee_settings = FeeSettingsTrait::max_fee(9999999); let salt = 0x1; let nonce = 0x1; let class_hash: ClassHash = 0x03a8b191831033ba48ee176d5dde7088e71c853002b02a1cfa5a760aa98be046 .try_into() .expect('Invalid class hash value'); let result = deploy( class_hash, ArrayTrait::new(), Option::Some(salt), true, fee_settings, Option::Some(nonce) ) .expect('deploy failed'); println!("deploy result: {}", result); println!("debug deploy result: {:?}", result); }