Пример #1
0
        public async Task <byte[]> DeploySmartContract(int category, byte[] contract)
        {
            SmartContractRegistration registration = new SmartContractRegistration
            {
                Category      = category,
                ContractBytes = ByteString.CopyFrom(contract),
                ContractHash  = Hash.FromRawBytes(contract)
            };

            var tx = Api.GetTransaction();

            ulong serialNumber = _serialNumber.Increment().Value;

            var creator = Api.GetTransaction().From;

            var info = new ContractInfo()
            {
                Owner        = creator,
                SerialNumber = serialNumber
            };

            var address = info.Address;
            // calculate new account address
            var account = DataPath.CalculateAccountAddress(tx.From, tx.IncrementId);

            await Api.DeployContractAsync(account, registration);

            Console.WriteLine("TestContractZero: Deployment success, {0}", account.DumpHex());
            return(account.DumpByteArray());
        }