示例#1
0
        private static async Task InstantiateContract(IClient client)
        {
            var generalApi = new GeneralApi(client);

            // Create gen entry
            var arguments = new[] { "dummy" };
            var entry     = new ContractInstantiate(s_AssemblyId, ContractName, InstanceName, arguments);

            // Create signed transaction with builder. To generate instantiate contract,
            // table admin and contract owner private key is required.
            var txSigned = TransactionCreator.CreateTransactionBuilder(
                new [] { entry },
                new []
            {
                new SignatureCredential(Utils.GetTableAdminKeyPair().PublicKey),
                new SignatureCredential(Utils.GetOwnerKeyPair().PublicKey)
            })
                           .Sign(Utils.GetTableAdminKeyPair().PrivateKey)
                           .Sign(Utils.GetOwnerKeyPair().PrivateKey)
                           .Build();

            await generalApi.SendTransactionAsync(txSigned);

            var result = await Utils.WaitTx(generalApi, txSigned.Id);

            Console.WriteLine($"txid={txSigned.Id}, result={result}");
        }
示例#2
0
        //participantlist
        //:03c898153e55c32627422466a83ed40b9233c1583023dafa179a4f2a4804306574
        //:027774dc46331602d9cc57da74bfce060d636238f9a0d06f5818ac44800c584538
        //:0390fe3ec4769770ee89da70c72a6ebb7449e6e16cfdf973d9350bb9dd587773f1  //beneficiary
        //:02c31e96cfb1497e3312c28669bbb25bf32a9c28f1cd64a697bbc17ab57ed9e434  //beneficiary (2nd)
        //:03bdfe20157b5aeab5a6c47bf5abe887147fd7fff3ae7d9cd54186c8822711bf4c
        //:03f9e61ae23c85a6eb6b9260591d1793a4d0c2f0970b2d93fbc4434044a9880a4d
        private static async Task InvokeContract(IClient client)
        {
            string argument   = "0338f9e2e7ad512fe039adaa509f7b555fb88719144945bd94f58887d8d54fed78";
            var    generalApi = new GeneralApi(client);

            // Create gen entry
            var entry = new ContractInvoke(s_AssemblyId, ContractName, InstanceName, "vote", new[] { argument });

            // Create signed transaction with builder. To invoke a smart contract,
            // contract owner's private key is required.
            var txSigned = TransactionCreator.CreateTransactionBuilder(
                new [] { entry },
                new []
            {
                new SignatureCredential(Utils.GetContractuser5KeyPair().PublicKey)
            })
                           .Sign(Utils.GetContractuser5KeyPair().PrivateKey)
                           .Build();

            await generalApi.SendTransactionAsync(txSigned);

            var result = await Utils.WaitTx(generalApi, txSigned.Id);

            Console.WriteLine($"txid={txSigned.Id}, result={result}");
        }