invoke

pub fn invoke( contract_address: ContractAddress, entry_point_selector: felt252, calldata: Array::<felt252>, fee_settings: FeeSettings, nonce: Option<felt252> ) -> Result<InvokeResult, ScriptCommandError>

Invokes a contract and returns InvokeResult.

  • contract_address - address of the contract to invoke.
  • entry_point_selector - the selector of the function to invoke.
  • calldata - inputs to the function to be invoked.
  • fee_settings - fee settings for the transaction, see `FeeSettingsTrait.
  • nonce - nonce for declare transaction. If not provided, nonce will be set automatically.
use starknet::ContractAddress; use sncast_std::{invoke, FeeSettingsTrait}; fn main() { let contract_address: ContractAddress = 0x1e52f6ebc3e594d2a6dc2a0d7d193cb50144cfdfb7fdd9519135c29b67e427 .try_into() .expect('Invalid contract address value'); let fee_settings = FeeSettingsTrait::estimate(); let result = invoke( contract_address, selector!("put"), array![0x1, 0x2], fee_settings, Option::None ) .expect('invoke failed'); println!("invoke result: {}", result); println!("debug invoke result: {:?}", result); }

Structures used by the command:

#[derive(Drop, Clone, Debug)] pub struct InvokeResult { pub transaction_hash: felt252, }