Beispiel #1
0
        public async Task ContractDeployAsync(string contract, string accountName, string password, WitnessScope witnessScope, bool force)
        {
            if (!TryGetSigningAccount(accountName, password, out var wallet, out var accountHash))
            {
                throw new Exception($"{accountName} account not found.");
            }

            var(nefFile, manifest) = await fileSystem.LoadContractAsync(contract).ConfigureAwait(false);

            if (!force)
            {
                var contracts = await expressNode.ListContractsAsync(manifest.Name).ConfigureAwait(false);

                if (contracts.Count > 0)
                {
                    throw new Exception($"Contract named {manifest.Name} already deployed. Use --force to deploy contract with conflicting name.");
                }
            }

            var txHash = await expressNode.DeployAsync(nefFile, manifest, wallet, accountHash, witnessScope).ConfigureAwait(false);

            await writer.WriteTxHashAsync(txHash, "Deployment", json).ConfigureAwait(false);
        }