Example #1
0
        private byte[] LoadDeploymentScript(string nefFilePath, bool hasStorage, bool isPayable, out UInt160 scriptHash)
        {
            var info = new FileInfo(nefFilePath);

            if (!info.Exists || info.Length >= Transaction.MaxTransactionSize)
            {
                throw new ArgumentException(nameof(nefFilePath));
            }

            NefFile file;

            using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Encoding.UTF8, false))
            {
                file = stream.ReadSerializable <NefFile>();
            }
            scriptHash = file.ScriptHash;

            ContractFeatures properties = ContractFeatures.NoProperty;

            if (hasStorage)
            {
                properties |= ContractFeatures.HasStorage;
            }
            if (isPayable)
            {
                properties |= ContractFeatures.Payable;
            }
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall(InteropService.Neo_Contract_Create, file.Script, properties);
                return(sb.ToArray());
            }
        }
Example #2
0
        private byte[] LoadDeploymentScript(string avmFilePath, bool hasStorage, bool isPayable, out UInt160 scriptHash)
        {
            var info = new FileInfo(avmFilePath);

            if (!info.Exists || info.Length >= Transaction.MaxTransactionSize)
            {
                throw new ArgumentException(nameof(avmFilePath));
            }

            byte[] script = File.ReadAllBytes(avmFilePath);
            scriptHash = script.ToScriptHash();
            ContractFeatures properties = ContractFeatures.NoProperty;

            if (hasStorage)
            {
                properties |= ContractFeatures.HasStorage;
            }
            if (isPayable)
            {
                properties |= ContractFeatures.Payable;
            }
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall(InteropService.Neo_Contract_Create, script, properties);
                return(sb.ToArray());
            }
        }
Example #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="features">Specify the smart contract features</param>
 public FeaturesAttribute(ContractFeatures features)
 {
     Features = features;
 }