public static ApplicationEngine Run(byte[] script, UInt256 ChainHash, IScriptContainer container = null, Block persisting_block = null) { BlockchainBase Chain = BlockchainBase.GetBlockchain(ChainHash); if (persisting_block == null) { persisting_block = new Block(ChainHash) { Version = 0, PrevHash = Chain.CurrentBlockHash, MerkleRoot = new UInt256(), Timestamp = Chain.GetHeader(Chain.Height).Timestamp + Chain.SecondsPerBlock, Index = Chain.Height + 1, ConsensusData = 0, NextConsensus = Chain.GetHeader(Chain.Height).NextConsensus, Script = new Witness { InvocationScript = new byte[0], VerificationScript = new byte[0] }, Transactions = new Transaction[0] } } ; DataCache <UInt160, AccountState> accounts = Chain.GetStates <UInt160, AccountState>(); DataCache <UInt256, AssetState> assets = Chain.GetStates <UInt256, AssetState>(); DataCache <UInt160, ContractState> contracts = Chain.GetStates <UInt160, ContractState>(); DataCache <StorageKey, StorageItem> storages = Chain.GetStates <StorageKey, StorageItem>(); CachedScriptTable script_table = new CachedScriptTable(contracts); using (StateMachine service = new StateMachine(persisting_block, accounts, assets, contracts, storages)) { ApplicationEngine engine = new ApplicationEngine(TriggerType.Application, container, script_table, service, Fixed8.Zero, true); engine.LoadScript(script, false); engine.Execute(); return(engine); } } }